Bug#973924: cfdisk: display more free space than actually available, and partition not resizable

2020-11-09 Thread gregoire roumache
Hello Chris,

I understand that I wasn't very clear, so I'm going
to explain step by step everything I did (I skipped
very few steps). You may want to check the list of
problems and the final notes I wrote at the end as
they may be more helpful in categorizing the bugs I
found than the rest of this post.

Sincerely,

Grégoire Roumache


1. I created a virtual machine (VM) on Virtual Box, with a 20 Gio virtual
hard drive.

2. After inserting the debian .iso file in the optical drive, I started the
machine.

3. In the "Debian GNU/Linux installer menu (BIOS mode)", I selected the
"Install" option,
not the "Graphical install" option.

4. I selected the following options:
- Language: English
- Country: United States
- Keymap: Belgian
- Hostname: debian
- Domain name: (left empty)
- Time zone: Eastern
- Partitioning method: Manual

5. In the "Partition disks", I selected the hard drive:
"SCSI2 (0,0,0) (sda) - 21.5 GB ATA VBOX HARDDISK".

6. At the question "Create new empty partition table on this device?", I
selected "Yes".

7. I selected the "pri/log 21.5 GB FREE SPACE" option, then I selected the
following options:
- How to use this free space: Create a new partition
- New partition size: 256 MB
- Type for the new partition: Primary
- Location for the new partition: Beginning
- Mount point: /boot
- Bootable flag: on
Then I selected "Done setting up the partition"

8. I selected the "pri/log 21.2 GB FREE SPACE" option, then:
- How to use this free space: Create a new partition
- New partition size: 1 GB
- Type for the new partition: Primary
- Location for the new partition: Beginning
- Use as: swap area

9. I selected the "pri/log 20.2 GB FREE SPACE" option, then:
- How to use this free space: Create a new partition
- New partition size: 10 GB
- Type for the new partition: Primary
- Location for the new partition: End (/!\ this is important)
- Mount point: /

10. I selected the "pri/log 10.2 GB FREE SPACE" option, then:
- How to use this free space: Create a new partition
- New partition size: 2 GB
- Type for the new partition: Logical
- Location for the new partition: Beginning
- Mount point: /home

11. I selected the "pri/log 8.2 GB FREE SPACE" option, then:
- How to use this free space: Create a new partition
- New partition size: 2 GB
- Location for the new partition: Beginning
- Mount point: /tmp
Note: it doesn't ask for the type of the new partition as it can only be:
Logical.

The partitions' list should now be:
#1 primary 254.8 MB B f ext4   /boot
#2 primary   1.0 GB   f swap   swap
#5 logical   2.0 GB   f ext4   /home
#6 logical   2.0 GB   f ext4   /tmp
   logical   6.2 GB FREE SPACE
#3 primary  10.0 GB   f ext4   /

12. Select "Finish partitioning and write change to disk", then confirm.

13. At "Software selection", select only "standard system utilities".

14. Install the GRUB loader to the master boot record on: /dev/sda.

15. The installation is now over, so let's check the partitions:

# fdisk -l
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk model: VBOX HARDDISK
...
Disklabel type: dos
Disk identifier: 0xe76778c5

DeviceBootStart  End  Sectors Size Id Type
/dev/sda1 *2048   499711   497664 243M 83 Linux
/dev/sda2499712  2453503  1953792 954M 82 Linux swap / Solaris
/dev/sda3  22411264 41940991 19529728 9.3G 83 Linux
/dev/sda4   240 10264575  7809026 3.7G  5 Extended
/dev/sda5   242  6359039  3903488 1.9G 83 Linux
/dev/sda6   6361088 10264575  3903488 1.9G 83 Linux

# cfdisk
Disk: /dev/sda
Size: 20 GiB, 21474836480 bytes, 41943040 sectors
Label: dos, identifier: 0xe76778c5

Device   BootStart  End  Sectors Size Id Type
/dev/sda1*2048   499711   497664 243M 83 Linux
/dev/sda2   499712  2453503  1953792 954M 82 Linux swap / Solaris
/dev/sda3 22411264 41940991 19529728 9.3G 83 Linux
/dev/sda4  240 10264575  7809026 3.7G  5 Extended
|- /dev/sda5   242  6359039  3903488 1.9G 83 Linux
|- /dev/sda6   6361088 10264575  3903488 1.9G 83 Linux
FREE SPACE10264576 22411263 12146688 5.8G

# parted --list
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start  EndSize   Type File systemFlags
1  1049kB 256MB  255MB  primary  ext4   boot
2  256MB  1256MB 1000MB primary  linux-swap(v1)
4  1257MB 5255MB 3998MB extended
5  1257MB 3256MB 1999MB logical  ext4
6  3257MB 5255MB 1999MB logical  ext4
3  11.5GB 21.5GB MB primary  ext4

16. At this point, I shut down my machine to duplicate it. The goal is
to check whether the problem would still appear with fdisk or parted.



With cfdisk:

1. I sorted the partitions, note that there's 15.1 G of free space in sda4
eventhough 

Bug#973924: cfdisk: display more free space than actually available, and partition not resizable

2020-11-08 Thread Chris Hofstaedtler
Hello gregoire roumache,

Thank you for your report.

* gregoire roumache  [201108 14:52]:
> I installed this debian with a HDD of 20 Gio, and partitioned it manually.
> 
> Here are the partitions I made, in order:
> 
>1. 256 MB - primary - beginning - ext4 – /boot – bootable flag = on
>2. 1 GB - primary - beginning - swap area
>3. 10 GB - primary - end - ext4 - /
>4. 2 GB - logical - beginning - ext4 - /home
>5. 2 GB - logical - beginning - ext4 - /tmp
> 
> [..]

I don't understand your bug report.

Could you please do these things / answer these questions:

1) Make a detailed reproduction steps list. What does "installed...
and partitioned manually" mean? Partitioned using cfdisk?

2) Provide output of fdisk -l before/after each step.

3) Do you think, this is 
   a) a bug in cfdisk?
   b) your partition table?
   c) in whatever tool that partitioned this disk initially?

4) Does the same problem appear if you use fdisk instead of cfdisk?

5) Does parted show the same problem?

Chris



Bug#973924: cfdisk: display more free space than actually available, and partition not resizable

2020-11-07 Thread gregoire roumache
Package: fdisk
Version: 2.33.1-0.1
File: /sbin/cfdisk

debian version: 10.6.0

I installed this debian with a HDD of 20 Gio, and partitioned it manually.

Here are the partitions I made, in order:

   1. 256 MB - primary - beginning - ext4 – /boot – bootable flag = on
   2. 1 GB - primary - beginning - swap area
   3. 10 GB - primary - end - ext4 - /
   4. 2 GB - logical - beginning - ext4 - /home
   5. 2 GB - logical - beginning - ext4 - /tmp

Here's the structure I get:
# cfdisk
sda1 - 243 M
sda2 - 954 M
sda3 - 9.3 G
sda4 - 3.7 G
| - sda5 - 1.9 G
| - sda6 - 1.9 G
Free space - 5.8 G

So far so good, but after sorting the partitions:
sda1 - 243 M
sda2 - 954 M
sda3 - 3.7 G
Free space - 5.8 G
sda4 - 9.3 G
| - sda5 - 1.9 G
| - sda6 - 1.9 G
| - Free space - 15.1 G

As you can see, there's only 9.3 G in sda4, but inside it, there's 15.1 G
of free space.
Worse, if you create a new partition of maximum size (15.1 G) on the free
space in sda4, it gives this:
sda1 - 243 M
sda2 - 954 M
sda3 - 3.7 G
Free space - 5.8 G
sda4 - 9.3 G
| - sda5 - 1.9 G
| - sda6 - 1.9 G
| - sda7 - 5.8 G
| - Free space - 9.3 G

Worse again, if you write the partition data to the disk, quit and relaunch
cfdisk, you get this:
sda1 - 243 M
sda2 - 954 M
sda3 - 3.7 G
| - sda5 - 1.9 G
| - sda6 - 1.9 G
| - sda7 - 5.8 G
Free space - 5.8 G
sda4 - 9.3 G

It shows 5.8 G of free space, however, the HDD is actually full. And the
size of sda3 does
not correspond to the combined size of sda5, sda6 and sda7.

Note that the new partition sda7 will work just fine. But if you delete
sda7, you get this:
sda1 - 243 M
sda2 - 954 M
sda3 - 3.7 G
| - sda5 - 1.9 G
| - sda6 - 1.9 G
Free space - 5.8 G
sda4 - 9.3 G

I can't resize sda3 for some reason, so it's now impossible to write any
new partition.
Note that rebooting does not help whatsoever.

Sincerely,
Grégoire Roumache