fdisk does not show boot flag
I normally use fdisk -l to look at partitions. I recently installed ubuntu 17.10 on a computer, and noticed that fdisk is not showing me the boot flag as it used to do. The output now looks for example like this
Device Start End Sectors Size Type
/dev/sda1 2048 1050623 1048576 512M EFI System
/dev/sda2 1050624 1953523711 1952473088 931G Linux filesystemI've not been able to find any info on why the boot column is missing, or how to get it back. Any links/info on this?
fdisk --version gives me fdisk from util-linux 2.30.1. I have another computer with version 2.27 (ubuntu 16.04), and this does show me the boot flag.
2 Answers
This is because of GPT.
On my Ubuntu 16.04 LTS system fdisk -l /dev/sda shows the following:
Disk /dev/sda: xxx GiB, yyyyyyyyyyyyy bytes, zzzzzzzzz sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
**Disklabel type: gpt**
Disk identifier: AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE
Device Start End Sectors Size Type
/dev/sda1 2048 616447 614400 300M EFI System
...But sudo parted /dev/sda shows almost the same:
(parted) p
Model: ATA ... (scsi)
Disk /dev/sda: xxxGB
Sector size (logical/physical): 512B/512B
**Partition Table: gpt**
Disk Flags:
Number Start End Size File system Name Flags 1 1049kB 316MB 315MB fat32 EFI system partition **boot**, esp
...So parted correctly shows boot flag.
If you need to find this information programmatically (like I did) this command should do the trick for you.sudo parted -l 2>/dev/null | grep -B7 boot > temp.fil; grep Disk temp.fil; grep boot temp.fil; rm temp.fil
This command produces output similar to this:
Disk /dev/nvme0n1: 120GB
Disk Flags: 1 1049kB 577MB 576MB primary ntfs bootFor those who are unfamiliar with these commands, they work together as follows:
from man parted
-l, --list lists partition layout on all block devicesthis is piped through grep
this was cleaned up by redirecting error output to dev/null with 2>/dev/null to eliminate the error message that my optical drive was generating in parted output.
From man grep
-B NUM, --before-context=NUM Print NUM lines of leading context before matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given.I chose to grab the first 7 lines and redirect into a temporary file temp.fil for ease of obtaining the output I required, You may find that you require a different number of lines before the match to get what you need. Each ; indicates the start of a new command. grep Disk temp.fil returns the line in the temporary file that identifies the boot drive and grep boot temp.fil returns the line in the temporary file that identifies the boot partition. The rm temp.fil simply removes the temporary file previously created.
NOTE: This command string will overwrite any file called temp.fil in the current directory and then delete the result. If this is a problem for you change the name accordingly.