fdisk/cfdisk crashes and wrong data

Bug #1390819 reported by Evan Langlois
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gnu-fdisk (Ubuntu)
New
Undecided
Unassigned

Bug Description

This is an odd bug. cfdisk and fdisk are both showing opposite labels for my 9th and 10th partitions (GPT). The same bug is present in gdisk/cgdisk (likely shares the same code). blkid, the linux kernel, and parted/gparted show the correct partition table (or rather the kernel matches what I configured into gparted, so that defines "correct").

Also, if you select "Info" when "Free Space" is highlighted in cfdisk, the program will crash.

Partitioning disks and having it done in a manner that is deterministic and reliable is extremely important. It looks like the linux-tools packages are totally outdated and dangerous on new systems (don't support GPT), the gdisk/cgdisk packages only support GPT and are buggy, the gnu-fdisk packages share the bugs and instabilities of gdisk.

Only parted/gparted is reliable. Please make note of this and either get someone to fix/upgrade gnu-fdisk or just cancel fdisk completely in support of parted.

Thanks

Revision history for this message
Rod Smith (rodsmith) wrote :

Please post example output; it's unclear to me what you mean by "showing opposite labels for my 9th and 10th partitions (GPT)." Also, be aware that the versions of fdisk and cfdisk delivered with Ubuntu through version 14.04 don't support GPT, although 14.10's fdisk and cfdisk add GPT support. Identifying the version of what you're running is critically important in this case.

Furthermore, GPT fdisk (gdisk, cgdisk, and sgdisk) all share most of their code with each other, but almost none with the util-linux programs (fdisk, cfdisk, and sfdisk). If you're seeing what seems to be an inconsistency between fdisk and cfdisk and a similar inconsistency between gdisk and cgdisk, the most likely explanation that occurs to me is that your partitions are out of order -- both fdisk and gdisk display partitions by their sequence number (/dev/sda1 followed by /dev/sda2 followed by /dev/sda3, and so on), whereas both cfdisk and cgdisk display partitions by their on-disk order (the partition that occupies the lowest-numbered sectors first, then the partition occupying the next sequence of sectors, and so on). The two sequences need not be the same; it's easy to generate a partition table in which /dev/sda10 comes before /dev/sda9 in terms of on-disk extents. GParted is like cfdisk and cgdisk in this respect. I don't recall what parted does, offhand.

Revision history for this message
Evan Langlois (uudruid74) wrote : Re: [Bug 1390819] Re: fdisk/cfdisk crashes and wrong data
Download full text (7.4 KiB)

Sorry it has taken me so long to get back to you.

Here is blkid from util-linux 2.20.1 (libblkid 2.20.0, 19-Oct-2011)

ekl@Taro ~ $ blkid
/dev/sda1: LABEL="Elementary" UUID="7f117018-5bf9-4294-b268-a84176c057cc"
TYPE="ext4"
/dev/sda2: LABEL="GParted-live" TYPE="udf"
/dev/sda3: SEC_TYPE="msdos" LABEL="EFI" UUID="5D94-05DA" TYPE="vfat"
/dev/sda4: LABEL="/home" UUID="e57eb743-b91c-401c-8a45-92bcec9f8ba2"
TYPE="ext4"
/dev/sda5: LABEL="Sabayon" UUID="09c2e3c2-28dd-4f36-80ae-8df05f18ae4b"
TYPE="ext4"
/dev/sda6: LABEL="GuestSwap" UUID="cbbde82c-9fed-4af5-9c9c-69e2cef89032"
TYPE="swap"
/dev/sda7: LABEL="/media" UUID="8761ae41-8541-4e5a-8c3d-e35a063ad9b1"
TYPE="ext4"
/dev/sda8: LABEL="HostSwap" UUID="46196490-44bc-45aa-9ebb-246b62387374"
TYPE="swap"
/dev/sda9: LABEL="Funtoo" UUID="7c3903a5-4a80-4c75-b616-cc8a6176e2dc"
TYPE="ext4"
/dev/sda10: LABEL="TestSystem" UUID="20837010-382a-4bf7-81be-9a8b20503797"
TYPE="ext4"

ekl@Taro ~ $ parted
WARNING: You are not superuser. Watch out for permissions.
GNU Parted 2.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: ATA HGST HTS541075A9 (scsi)
Disk /dev/sda: 750GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number Start End Size File system Name Flags
 1 1049kB 62.9GB 62.9GB ext4 Linux filesystem
 9 62.9GB 126GB 62.9GB ext4 TestSystem
10 126GB 210GB 83.9GB ext4 Funtoo
 2 210GB 210GB 210MB GNU Parted msftdata
 4 210GB 218GB 8389MB ext4 Home
 6 218GB 220GB 2097MB linux-swap(v1) GuestSwap
 8 220GB 223GB 2097MB linux-swap(v1) HostSwap
 7 223GB 742GB 520GB ext4 Storage
 3 742GB 742GB 123MB fat16 EFI System boot
 5 742GB 750GB 7733MB ext4 Sabayon

Now the above is the correct information that the kernel sees. Below you
will notice that the Funtoo partition and TestSystem are being shown with
the wrong partition numbers. Partitions 9 and 10 are "swapped". This is
going to lead to some problems. I've given the version numbers of each
tool in the output.

                                GNU cfdisk 1.2.5

                              ATA HGST HTS541075A9
        Disk: /dev/sda Disk type: gpt Size: 750156374015B, 750156MB
             Heads: 255 Sectors per track: 63 Cylinders: 91201

   Number Flags Part Type Filesystem Label
 Size
 ------------------------------------------------------------------------------
                       Primary Free space
 1.03MB
      1 Primary ext4 Linux filesys
 62915MB
      9 Primary ext4 TestSystem
62915MB
     10 Primary ext4 Funtoo
83890MB
      2 Primary GNU Parted
210MB
      4 Primary ext4 Home
 8389MB
      6 Primary linux-swap(v1) GuestSwap
2097MB
      8 Primary linux-swap(v1) HostSwap
 2097MB
      7 Primary ext4 ...

Read more...

Revision history for this message
Evan Langlois (uudruid74) wrote :
Download full text (8.2 KiB)

Odd .. small update. I just noticed that parted was wrong, too! I don't
normally use it, but I had erroneously assumed that parted and gparted
shared the same code and would give the same results. The graphical
gparted and the gnome "Disks" tool both show the same output as blkid,
which is showing what the kernel shows. Everything else is wrong.

How can this be?

On Fri, Apr 10, 2015 at 9:52 AM Evan Langlois <email address hidden> wrote:

>
> Sorry it has taken me so long to get back to you.
>
> Here is blkid from util-linux 2.20.1 (libblkid 2.20.0, 19-Oct-2011)
>
> ekl@Taro ~ $ blkid
> /dev/sda1: LABEL="Elementary" UUID="7f117018-5bf9-4294-b268-a84176c057cc"
> TYPE="ext4"
> /dev/sda2: LABEL="GParted-live" TYPE="udf"
> /dev/sda3: SEC_TYPE="msdos" LABEL="EFI" UUID="5D94-05DA" TYPE="vfat"
> /dev/sda4: LABEL="/home" UUID="e57eb743-b91c-401c-8a45-92bcec9f8ba2"
> TYPE="ext4"
> /dev/sda5: LABEL="Sabayon" UUID="09c2e3c2-28dd-4f36-80ae-8df05f18ae4b"
> TYPE="ext4"
> /dev/sda6: LABEL="GuestSwap" UUID="cbbde82c-9fed-4af5-9c9c-69e2cef89032"
> TYPE="swap"
> /dev/sda7: LABEL="/media" UUID="8761ae41-8541-4e5a-8c3d-e35a063ad9b1"
> TYPE="ext4"
> /dev/sda8: LABEL="HostSwap" UUID="46196490-44bc-45aa-9ebb-246b62387374"
> TYPE="swap"
> /dev/sda9: LABEL="Funtoo" UUID="7c3903a5-4a80-4c75-b616-cc8a6176e2dc"
> TYPE="ext4"
> /dev/sda10: LABEL="TestSystem" UUID="20837010-382a-4bf7-81be-9a8b20503797"
> TYPE="ext4"
>
>
> ekl@Taro ~ $ parted
> WARNING: You are not superuser. Watch out for permissions.
> GNU Parted 2.3
> Using /dev/sda
> Welcome to GNU Parted! Type 'help' to view a list of commands.
> (parted) print
> Model: ATA HGST HTS541075A9 (scsi)
> Disk /dev/sda: 750GB
> Sector size (logical/physical): 512B/4096B
> Partition Table: gpt
>
> Number Start End Size File system Name Flags
> 1 1049kB 62.9GB 62.9GB ext4 Linux filesystem
> 9 62.9GB 126GB 62.9GB ext4 TestSystem
> 10 126GB 210GB 83.9GB ext4 Funtoo
> 2 210GB 210GB 210MB GNU Parted msftdata
> 4 210GB 218GB 8389MB ext4 Home
> 6 218GB 220GB 2097MB linux-swap(v1) GuestSwap
> 8 220GB 223GB 2097MB linux-swap(v1) HostSwap
> 7 223GB 742GB 520GB ext4 Storage
> 3 742GB 742GB 123MB fat16 EFI System boot
> 5 742GB 750GB 7733MB ext4 Sabayon
>
>
> Now the above is the correct information that the kernel sees. Below you
> will notice that the Funtoo partition and TestSystem are being shown with
> the wrong partition numbers. Partitions 9 and 10 are "swapped". This is
> going to lead to some problems. I've given the version numbers of each
> tool in the output.
>
>
> GNU cfdisk 1.2.5
>
> ATA HGST HTS541075A9
> Disk: /dev/sda Disk type: gpt Size: 750156374015B, 750156MB
> Heads: 255 Sectors per track: 63 Cylinders: 91201
>
> Number Flags Part Type Filesystem Label
> Size
>
> ------------------------------------------------------------------------------
> ...

Read more...

Revision history for this message
Rod Smith (rodsmith) wrote :

I suspect that what you're seeing is a mis-match in the labels. Both GPT and most filesystems support disk labels, but there's no mechanism to keep them synchronized. You can try changing the disk labels in gdisk or cgdisk and see if the problem disappears.

Revision history for this message
Evan Langlois (uudruid74) wrote :

Well, you were right about the problem, although changing disk labels
isn't going to find the problem, just make it worse. The
/dev/disk/by-name and /dev/disk/by-partlabel directories show symlinks to
the device numbers and by comparing you can see really quick that some
tools are using by-label while others use by-partlabel.

I really think this inconsistency, even if not a bug, is about one of the
stupidest things I've seen in a long time. The tools should be smarter
and make this stuff more bullet-proof. Rather than showing half the
information and confusing the user, why not keep the stuff in sync or at
least tell the user when things aren't in sync and give them the option to
fix it.

Quality software doesn't do half the job. This should be improved, and I
think the potential for harm (imagine deleting a partition) is high enough
to call this a bug. Granted few people ever edit partitions as I've done
(I should have used LVM or something, but I never expected to get that
crazy on a laptop). Anyway, corner car usages are what does where the
flaws are.

On Fri, Apr 10, 2015, 10:35 AM Roderick Smith <email address hidden>
wrote:

> I suspect that what you're seeing is a mis-match in the labels. Both GPT
> and most filesystems support disk labels, but there's no mechanism to
> keep them synchronized. You can try changing the disk labels in gdisk or
> cgdisk and see if the problem disappears.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1390819
>
> Title:
> fdisk/cfdisk crashes and wrong data
>
> Status in gnu-fdisk package in Ubuntu:
> New
>
> Bug description:
> This is an odd bug. cfdisk and fdisk are both showing opposite labels
> for my 9th and 10th partitions (GPT). The same bug is present in
> gdisk/cgdisk (likely shares the same code). blkid, the linux kernel,
> and parted/gparted show the correct partition table (or rather the
> kernel matches what I configured into gparted, so that defines
> "correct").
>
> Also, if you select "Info" when "Free Space" is highlighted in cfdisk,
> the program will crash.
>
> Partitioning disks and having it done in a manner that is
> deterministic and reliable is extremely important. It looks like the
> linux-tools packages are totally outdated and dangerous on new systems
> (don't support GPT), the gdisk/cgdisk packages only support GPT and
> are buggy, the gnu-fdisk packages share the bugs and instabilities of
> gdisk.
>
> Only parted/gparted is reliable. Please make note of this and either
> get someone to fix/upgrade gnu-fdisk or just cancel fdisk completely
> in support of parted.
>
> Thanks
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ubuntu/+source/gnu-fdisk/+bug/
> 1390819/+subscriptions
>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.