#3570 PR merged: Use get_disk_size to show current disk size

Labels: fixed / solved / done, minor bug

svlv opened issue at 2026-02-21 07:36:

Pull Request Details:
  • Type: Bug Fix

  • Impact: Normal

  • Reference to related issue (URL): No issue created

  • How was this pull request tested?
    Manually recovered Debian 13

  • Description of the changes in this pull request:
    Use the get_disk_size function to show current disk size.

Before the fix the output is the following:

Switching to manual disk layout configuration (GiB sizes rounded down to integer)
/dev/vda had size 10737418240 (10 GiB) but is now 12884901888 (12 GiB)
/dev/vdb had size 10737418240 (10 GiB) but is now 12884901888 (12 GiB)
/dev/md0 was not used on the original system and has now 24747442176 (23 GiB)
Original disk /dev/vda does not exist (with same size) in the target system
The size of /dev/md0 is
The size of /dev/vda is
The size of /dev/vdb is
Choose an appropriate replacement for /dev/vda with size 10737418240
1) /dev/md0
2) /dev/vda
3) /dev/vdb
4) Do not map /dev/vda
5) Use Relax-and-Recover shell and return back to here

Please pay attention to lines such as The size of /dev/vda is. It is not very convenient to choose an appropriate replacement when sizes are not displayed.

The root cause is that blockdev currently returns the error Inappropriate ioctl for device when used with /sys/block/*

blockdev --getsize64 /sys/block/vda
blockdev: ioctl error on BLKGETSIZE64: Inappropriate ioctl for device

After the fix sizes are displayed as expected:

Switching to manual disk layout configuration (GiB sizes rounded down to integer)
/dev/vda had size 10737418240 (10 GiB) but is now 12884901888 (12 GiB)
/dev/vdb had size 10737418240 (10 GiB) but is now 12884901888 (12 GiB)
/dev/md0 was not used on the original system and has now 24747442176 (23 GiB)
Original disk /dev/vda does not exist (with same size) in the target system
The size of /dev/md0 is 24747442176
The size of /dev/vda is 12884901888
The size of /dev/vdb is 12884901888
Choose an appropriate replacement for /dev/vda with size 10737418240
1) /dev/md0
2) /dev/vda
3) /dev/vdb
4) Do not map /dev/vda
5) Use Relax-and-Recover shell and return back to here

jsmeix commented at 2026-02-23 07:43:

@svlv
thank you for your enhancement that makes it work
in more cases!

@rear/contributors
I would like to merge it on Wednesday (25. Feb.) afternoon
unless there are objections.


[Export of Github issue for rear/rear.]