Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-82162

fdisk does not wipe the vfat signature despite claiming so

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • rhel-10.2
    • rhel-10.0
    • util-linux
    • None
    • util-linux-2.40.2-14.el10
    • No
    • Low
    • rhel-base-utils-core
    • ssg_core_services
    • 22
    • 22
    • 0
    • False
    • False
    • Hide

      None

      Show
      None
    • No
    • None
    • Requested
    • None
    • Unspecified Release Note Type - Unknown
    • Unspecified
    • Unspecified
    • Unspecified
    • None

      What were you trying to do that didn't work?

      I have a disk that was formatted as a FAT filesystem. I created two DOS partitions using fdisk on it:

      # lsblk
      NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
      vdb    253:16   0  10G  0 disk 
      ├─vdb1 253:17   0   5G  0 part 
      └─vdb2 253:18   0   5G  0 part 
      

      fdisk shows these two partitions properly:

      # fdisk -l /dev/vdb
      Disk /dev/vdb: 10 GiB, 10737418240 bytes, 20971520 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: dos
      Disk identifier: 0x00000000
      
      Device     Boot    Start      End  Sectors Size Id Type
      /dev/vdb1           2048 10485759 10483712   5G 83 Linux
      /dev/vdb2       10485760 20971519 10485760   5G 83 Linux
      

      but parted does not even show the partition table (it says that the partition table is loop, not msdos and lists one single FAT partition):

      # parted /dev/vdb
      GNU Parted 3.6
      Using /dev/vdb
      Welcome to GNU Parted! Type 'help' to view a list of commands.
      (parted) p                                                                
      Model: Virtio Block Device (virtblk)
      Disk /dev/vdb: 10.7GB
      Sector size (logical/physical): 512B/512B
      Partition Table: loop
      Disk Flags: 
      
      Number  Start  End     Size    File system  Flags
       1      0.00B  10.7GB  10.7GB  fat32
      

      Similarly blkid:

      # blkid /dev/vdb
      /dev/vdb: LABEL_FATBOOT="ephemeral0" LABEL="ephemeral0" UUID="6FC7-A4A5" BLOCK_SIZE="512" TYPE="vfat"
      

      I investigated and the reason for this inconsistency seems to be "leftovers" of the FAT file system superblock in the MBR. Using the 'o' command of fdisk (create a new empty DOS partition table) before creating the partitions avoids the issue.

      Note though that when fdisk starts, it prints this:

      The device contains 'vfat' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.
      

      So I should not be expected to use the 'o' command. The wiping of the signature should happen automatically.

      In RHEL 8 and RHEL 7 the actual behavior is the same, but fdisk at least does not pretend that it will do it when it will not.

      What is the impact of this issue to you?

      It results in a disk that some parts of the system (fdisk, kernel) interpret differently than other parts of the system (parted, blkid). This can lead to very confusing behavior, as one usually repartitions disks using fdisk, but parted is often used in automated scripts.

      Please provide the package NVR for which the bug is seen:

      util-linux-2.37.4-21.el9.x86_64 util-linux-2.40.2-10.el10.x86_64

      How reproducible is this bug?:

      well reproducible

      Steps to reproduce

      1. 1minutetip --flavor ci.m1.medium.ephemeral -n rhel9
      2. in the VM
      3. fdisk /dev/vdb
      4. n
      5. <ENTER>
      6. <ENTER>
      7. <ENTER>
      8. 10485759
      9. n
      10. <ENTER>
      11. <ENTER>
      12. <ENTER>
      13. <ENTER>
      14. w
      15. blkid /dev/vdb

      Expected results

      /dev/vda: .... PTTYPE="dos"

      Actual results

      /dev/vdb: LABEL_FATBOOT="ephemeral0" LABEL="ephemeral0" UUID="6FC7-A4A5" BLOCK_SIZE="512" TYPE="vfat"

              rhn-engineering-kzak Karel Zak
              rhn-support-pcahyna Pavel Cahyna
              Karel Zak
              Karel Zak Karel Zak
              Radka Brychtova Radka Brychtova
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated: