Package: fdisk
Version: 2.31.1-0.5
Severity: normal

Hi,

I think I found a bug in sfdisk (or rather in libfdisk). I'm trying to
(programmatically) add a partition filling the whole free space on an
64G sdcard after burning a raspbian lite image on it.

Device preparation:

wget https://downloads.raspberrypi.org/raspbian_lite_latest
unzip rasbian_lite_latest
dd if=2018-04-18-raspbian-stretch-lite.img of=/dev/mmcblk0 bs=4M conv=fsync

The resulting partition table on the sdcard is:

sfdisk -d /dev/mmcblk0
label: dos
label-id: 0xc7cb7e34
device: /dev/mmcblk0
unit: sectors

/dev/mmcblk0p1 : start=        8192, size=       88262, type=c
/dev/mmcblk0p2 : start=       98304, size=     3538944, type=83

There's approximately 58G available at the end of the device (from cyl
3538944 to 125042688).

According to the manpage, I think adding a new partition for a vfat
filesystem filling the free space could be done with:

echo "type=c" |  sfdisk -a /dev/mmcblk0

But it doesn't seem to work:

echo "type=c" |  sfdisk -an /dev/mmcblk0
Disk /dev/mmcblk0: 59.6 GiB, 64021856256 bytes, 125042688 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: 0xc7cb7e34

Old situation:

Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk0p1       8192   96453   88262 43.1M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      98304 3637247 3538944  1.7G 83 Linux

/dev/mmcblk0p3: Created a new partition 3 of type 'W95 FAT32 (LBA)' and of size 
3 MiB.
/dev/mmcblk0p4: Done.

New situation:
Disklabel type: dos
Disk identifier: 0xc7cb7e34

Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk0p1       8192   96453   88262 43.1M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      98304 3637247 3538944  1.7G 83 Linux
/dev/mmcblk0p3       2048    8191    6144    3M  c W95 FAT32 (LBA)

Partition table entries are not in disk order.
The partition table is unchanged (--no-act).

The log with LIBFDISK_DEBUG=all is attached in full, but here is the
excerpt:

13671: libfdisk:    LABEL: DOS: adding partition 2
13671: libfdisk:    LABEL: DOS: last possible sector for #2 is 125042687
13671: libfdisk:      CXT: [0x632cdf814110]: LBA         2048 already aligned
13671: libfdisk:      CXT: [0x632cdf814110]: LBA    125042687 aligned-down    
125040640 [grain=2048s]
13671: libfdisk:      CXT: [0x632cdf814110]: LBA         2048 already aligned
13671: libfdisk:      CXT: [0x632cdf814110]: 2048 in range <2048..125040640> 
aligned to 2048
13671: libfdisk:    LABEL: DOS: start is 2048
13671: libfdisk:    LABEL: DOS: last possible sector for #2 is 125042687
13671: libfdisk:    LABEL: DOS: unused sector for #2 is 8191
13671: libfdisk:    LABEL: DOS: raw stop: 8191 [limit 8191]
13671: libfdisk:    LABEL: DOS: setting partition 2, offset=0, start=2048, 
size=6144, sysid=0c
13671: libfdisk:    LABEL: DOS: setting 2 partition to changed
13671: libfdisk:      ASK: [0x632cdf81caf0]: alloc
13671: libfdisk:      ASK: [0x632cdf81caf0]: do_ask for 'info'
/dev/mmcblk0p3: Created a new partition 3 of type 'W95 FAT32 (LBA)' and of size 
3 MiB.

If you need more information, please ask.

Regards,
-- 
Yves-Alexis

-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (450, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.15.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.utf8, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8), 
LANGUAGE=fr_FR.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages fdisk depends on:
ii  libc6          2.27-3
ii  libfdisk1      2.31.1-0.5
ii  libmount1      2.31.1-0.5
ii  libncursesw5   6.1+20180210-2
ii  libsmartcols1  2.31.1-0.5
ii  libtinfo5      6.1+20180210-2

fdisk recommends no packages.

fdisk suggests no packages.

-- no debconf information
13774: libfdisk:     INIT: library debug mask: 0xffff
13774: libfdisk:     INIT: library version: 2.31.1
Available "LIBFDISK_DEBUG=<name>[,...]|<mask>" debug masks:
   all      [0xffff] : info about all subsystems
   ask      [0x0010] : fdisk dialogs
   help     [0x0001] : this help
   cxt      [0x0004] : library context (handler)
   label    [0x0008] : disk label utils
   part     [0x0040] : partition utils
   parttype [0x0080] : partition type utils
   script   [0x0200] : sfdisk-like scripts
   tab      [0x0100] : table utils
   wipe     [0x0400] : wipe area utils
   item     [0x0400] : disklabel items
13774: libfdisk:      CXT: [0x56bf399ef110]: alloc
13774: libfdisk:      CXT: [0x56bf399ef110]: assigning device /dev/mmcblk0
13774: libfdisk:      CXT: [0x56bf399ef110]: *** resetting context
13774: libfdisk:      CXT: [0x56bf399ef110]: /dev/mmcblk0: discovering 
topology...
13774: libfdisk:      CXT: [0x56bf399ef110]: initialize libblkid prober
13774: libfdisk:      CXT: [0x56bf399ef110]: result: log/phy sector size: 
512/512
13774: libfdisk:      CXT: [0x56bf399ef110]: result: fdisk/optimal/minimal io: 
512/0/512
13774: libfdisk:      CXT: [0x56bf399ef110]: /dev/mmcblk0: discovering 
geometry...
13774: libfdisk:      CXT: [0x56bf399ef110]: total sectors: 125042688 
(ioctl=125042688)
13774: libfdisk:      CXT: [0x56bf399ef110]: result: C/H/S: 1953792/4/16
13774: libfdisk:      CXT: [0x56bf399ef110]: applying user device properties
13774: libfdisk:      CXT: [0x56bf399ef110]: resetting alignment...
13774: libfdisk:      CXT: [0x56bf399ef110]: alignment reset to: first 
LBA=2048, last LBA=125042687, grain=1048576 [rc=0]
13774: libfdisk:      CXT: [0x56bf399ef110]: initialize in-memory first sector 
buffer [sector_size=512]
13774: libfdisk:      CXT: [0x56bf399ef110]: reading: offset=0, size=512
13774: libfdisk:      CXT: [0x56bf399ef110]: new C/H/S: 1953792/4/16
13774: libfdisk:      CXT: [0x56bf399ef110]: new log/phy sector size: 512/512
13774: libfdisk:      CXT: [0x56bf399ef110]: zeroize in-memory first sector 
buffer
13774: libfdisk:      CXT: [0x56bf399ef110]: reading: offset=0, size=512
13774: libfdisk:      CXT: [0x56bf399ef110]: probing for gpt
13774: libfdisk:    LABEL: GPT probe failed
13774: libfdisk:      CXT: [0x56bf399ef110]: probing for dos
13774: libfdisk:    LABEL: DOS: initialize, first sector buffer 0x56bf399f5d00
13774: libfdisk:    LABEL: DOS: initialize: #1 start=8192 size=88262 sysid=0c
13774: libfdisk:    LABEL: DOS: initialize: #2 start=98304 size=3538944 sysid=83
13774: libfdisk:    LABEL: DOS: initialize: #3 start=0 size=0 sysid=00
13774: libfdisk:    LABEL: DOS: initialize: #4 start=0 size=0 sysid=00
13774: libfdisk:    LABEL: DOS PT geometry: heads=0, sectors=0
13774: libfdisk:      CXT: [0x56bf399ef110]: --> switching context to dos!
13774: libfdisk:      CXT: [0x56bf399ef110]: appling label device properties...
13774: libfdisk:      CXT: [0x56bf399ef110]: initialized for /dev/mmcblk0 
[READ-WRITE]
13774: libfdisk:   SCRIPT: [0x56bf399efff0]: alloc
13774: libfdisk:      TAB: [0x56bf399f0050]: alloc
13774: libfdisk:      CXT: [0x56bf399ef110]: setting reference to script 
0x56bf399efff0
13774: libfdisk:     PART: [0x56bf399f5f10]: alloc
13774: libfdisk:     PART: [0x56bf399f5f10]: reset
13774: libfdisk:     PART: [0x56bf399f5f10]: reset
13774: libfdisk:     PART: [0x56bf399f5f10]: free
13774: libfdisk:      ASK: [0x56bf399f6670]: alloc
13774: libfdisk:      ASK: [0x56bf399f6670]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f6670]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f6670]: reset
13774: libfdisk:      ASK: [0x56bf399f6670]: free
13774: libfdisk:      ASK: [0x56bf399f6740]: alloc
13774: libfdisk:      ASK: [0x56bf399f6740]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f6740]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f6740]: reset
13774: libfdisk:      ASK: [0x56bf399f6740]: free
13774: libfdisk:      ASK: [0x56bf399f67a0]: alloc
13774: libfdisk:      ASK: [0x56bf399f67a0]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f67a0]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f67a0]: reset
13774: libfdisk:      ASK: [0x56bf399f67a0]: free
13774: libfdisk:      ASK: [0x56bf399f6870]: alloc
13774: libfdisk:      ASK: [0x56bf399f6870]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f6870]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f6870]: reset
13774: libfdisk:      ASK: [0x56bf399f6870]: free
13774: libfdisk:      ASK: [0x56bf399f6940]: alloc
13774: libfdisk:      ASK: [0x56bf399f6940]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f6940]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f6940]: reset
13774: libfdisk:      ASK: [0x56bf399f6940]: free
13774: libfdisk:      CXT: [0x56bf399ef110]: asking for disk dos ID
13774: libfdisk:      CXT: [0x56bf399ef110]: asking for disk dos item 0
13774: libfdisk:      ASK: [0x56bf399f69a0]: alloc
13774: libfdisk:      ASK: [0x56bf399f69a0]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f69a0]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f69a0]: reset
13774: libfdisk:      ASK: [0x56bf399f69a0]: free
13774: libfdisk:      ASK: [0x56bf399f6a00]: alloc
13774: libfdisk:      ASK: [0x56bf399f6a00]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f6a00]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f6a00]: reset
13774: libfdisk:      ASK: [0x56bf399f6a00]: free
13774: libfdisk:      CXT: [0x56bf399ef110]:  -- get table --
13774: libfdisk:      TAB: [0x56bf399f6a60]: alloc
13774: libfdisk:     PART: [0x56bf399f6a90]: alloc
13774: libfdisk:      TAB: [0x56bf399f6a60]: add entry 0x56bf399f6a90 
[start=8192, end=96453, size=88262,   primary]
13774: libfdisk:     PART: [0x56bf399f6b50]: alloc
13774: libfdisk:      TAB: [0x56bf399f6a60]: add entry 0x56bf399f6b50 
[start=98304, end=3637247, size=3538944,   primary]
13774: libfdisk:      ASK: [0x56bf399f7af0]: alloc
13774: libfdisk:      ASK: [0x56bf399f7af0]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f7af0]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f7af0]: reset
13774: libfdisk:      ASK: [0x56bf399f7af0]: free
13774: libfdisk:      TAB: [0x56bf399f6a60]: wrong older check
13774: libfdisk:      TAB: [0x56bf399f6a60]: reset
13774: libfdisk:      TAB: [0x56bf399f6a60]: remove entry 0x56bf399f6a90
13774: libfdisk:     PART: [0x56bf399f6a90]: reset
13774: libfdisk:     PART: [0x56bf399f6a90]: free
13774: libfdisk:      TAB: [0x56bf399f6a60]: remove entry 0x56bf399f6b50
13774: libfdisk:     PART: [0x56bf399f6b50]: reset
13774: libfdisk:     PART: [0x56bf399f6b50]: free
13774: libfdisk:      TAB: [0x56bf399f6a60]: free
13774: libfdisk:   SCRIPT: [0x56bf399efff0]: setting new header label='dos'
13774: libfdisk:   SCRIPT: [0x56bf399efff0]:  parsing line 0
13774: libfdisk:   SCRIPT: [0x56bf399efff0]:   parsing buffer
13774: libfdisk:   SCRIPT: [0x56bf399efff0]:    parse script line: 'type=c'
13774: libfdisk:     PART: [0x56bf399f79f0]: alloc
13774: libfdisk:   SCRIPT: [0x56bf399efff0]:  parsing 'type=c'
13774: libfdisk:   SCRIPT: [0x56bf399efff0]: label 'dos'
13774: libfdisk:    LABEL: [0x56bf399ef370]: parsing 'c' (dos) partition type
13774: libfdisk: PARTTYPE: [0x7ac35c379040]: returns parsed 'W95 FAT32 (LBA)' 
[] partition type
13774: libfdisk:      TAB: [0x56bf399f0050]: add entry 0x56bf399f79f0 
[start=18446744073709551615, end=18446744073709551613, 
size=18446744073709551615,   primary]
13774: libfdisk:      CXT: [0x56bf399ef110]: adding new partition 0x56bf399f79f0
13774: libfdisk:      CXT: [0x56bf399ef110]:   defaults: start=yes, end=yes, 
partno=yes
13774: libfdisk:    LABEL: DOS: new partition wanted
13774: libfdisk:    LABEL: DOS: dialog driven partitioning
13774: libfdisk:     PART: [0x56bf399f79f0]: next partno (follow default)
13774: libfdisk:    LABEL: DOS: adding partition 2
13774: libfdisk:    LABEL: DOS: last possible sector for #2 is 125042687
13774: libfdisk:      CXT: [0x56bf399ef110]: LBA         2048 already aligned
13774: libfdisk:      CXT: [0x56bf399ef110]: LBA    125042687 aligned-down    
125040640 [grain=2048s]
13774: libfdisk:      CXT: [0x56bf399ef110]: LBA         2048 already aligned
13774: libfdisk:      CXT: [0x56bf399ef110]: 2048 in range <2048..125040640> 
aligned to 2048
13774: libfdisk:    LABEL: DOS: start is 2048
13774: libfdisk:    LABEL: DOS: last possible sector for #2 is 125042687
13774: libfdisk:    LABEL: DOS: unused sector for #2 is 8191
13774: libfdisk:    LABEL: DOS: raw stop: 8191 [limit 8191]
13774: libfdisk:    LABEL: DOS: setting partition 2, offset=0, start=2048, 
size=6144, sysid=0c
13774: libfdisk:    LABEL: DOS: setting 2 partition to changed
13774: libfdisk:      ASK: [0x56bf399f7af0]: alloc
13774: libfdisk:      ASK: [0x56bf399f7af0]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f7af0]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f7af0]: reset
13774: libfdisk:      ASK: [0x56bf399f7af0]: free
13774: libfdisk:      CXT: [0x56bf399ef110]: add partition done (rc=0)
13774: libfdisk:     PART: [0x56bf399f7630]: alloc
13774: libfdisk:     PART: [0x56bf399f7630]: start probe #2 partition [cxt 
0x56bf399ef110] >>>
13774: libfdisk:     PART: [0x56bf399f7630]: blkid prober: 0x56bf399f90b0
13774: libfdisk:     PART: [0x56bf399f7630]: <<< end probe #2 partition[cxt 
0x56bf399ef110, rc=1]
13774: libfdisk:     PART: [0x56bf399f7630]: reset
13774: libfdisk:     PART: [0x56bf399f7630]: free
13774: libfdisk:   SCRIPT: [0x56bf399efff0]:  parsing line 1
13774: libfdisk:      ASK: [0x56bf399f6dc0]: alloc
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f6dc0]: reset
13774: libfdisk:      ASK: [0x56bf399f6dc0]: free
13774: libfdisk:      ASK: [0x56bf399f6dc0]: alloc
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f6dc0]: reset
13774: libfdisk:      ASK: [0x56bf399f6dc0]: free
13774: libfdisk:      CXT: [0x56bf399ef110]: asking for disk dos ID
13774: libfdisk:      CXT: [0x56bf399ef110]: asking for disk dos item 0
13774: libfdisk:      ASK: [0x56bf399f6dc0]: alloc
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f6dc0]: reset
13774: libfdisk:      ASK: [0x56bf399f6dc0]: free
13774: libfdisk:      CXT: [0x56bf399ef110]:  -- get table --
13774: libfdisk:      TAB: [0x56bf399f76f0]: alloc
13774: libfdisk:     PART: [0x56bf399f9c80]: alloc
13774: libfdisk:      TAB: [0x56bf399f76f0]: add entry 0x56bf399f9c80 
[start=8192, end=96453, size=88262,   primary]
13774: libfdisk:     PART: [0x56bf399f9d40]: alloc
13774: libfdisk:      TAB: [0x56bf399f76f0]: add entry 0x56bf399f9d40 
[start=98304, end=3637247, size=3538944,   primary]
13774: libfdisk:     PART: [0x56bf399f9e00]: alloc
13774: libfdisk:      TAB: [0x56bf399f76f0]: add entry 0x56bf399f9e00 
[start=2048, end=8191, size=6144,   primary]
13774: libfdisk:      ASK: [0x56bf399f6dc0]: alloc
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f6dc0]: reset
13774: libfdisk:      ASK: [0x56bf399f6dc0]: free
13774: libfdisk:      TAB: [0x56bf399f76f0]: wrong older check
13774: libfdisk:      ASK: [0x56bf399f6dc0]: alloc
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f6dc0]: reset
13774: libfdisk:      ASK: [0x56bf399f6dc0]: free
13774: libfdisk:      ASK: [0x56bf399f6dc0]: alloc
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f6dc0]: reset
13774: libfdisk:      ASK: [0x56bf399f6dc0]: free
13774: libfdisk:      TAB: [0x56bf399f76f0]: reset
13774: libfdisk:      TAB: [0x56bf399f76f0]: remove entry 0x56bf399f9c80
13774: libfdisk:     PART: [0x56bf399f9c80]: reset
13774: libfdisk:     PART: [0x56bf399f9c80]: free
13774: libfdisk:      TAB: [0x56bf399f76f0]: remove entry 0x56bf399f9d40
13774: libfdisk:     PART: [0x56bf399f9d40]: reset
13774: libfdisk:     PART: [0x56bf399f9d40]: free
13774: libfdisk:      TAB: [0x56bf399f76f0]: remove entry 0x56bf399f9e00
13774: libfdisk:     PART: [0x56bf399f9e00]: reset
13774: libfdisk:     PART: [0x56bf399f9e00]: free
13774: libfdisk:      TAB: [0x56bf399f76f0]: free
13774: libfdisk:      ASK: [0x56bf399f6dc0]: alloc
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask for 'info'
13774: libfdisk:      ASK: [0x56bf399f6dc0]: do_ask done [rc=0]
13774: libfdisk:      ASK: [0x56bf399f6dc0]: reset
13774: libfdisk:      ASK: [0x56bf399f6dc0]: free
13774: libfdisk:      CXT: [0x56bf399ef110]: de-assigning device /dev/mmcblk0

Reply via email to