Bug 1232707 - RFE: sfdisk auto partition renumbering to disk order
Summary: RFE: sfdisk auto partition renumbering to disk order
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-06-17 11:08 UTC by Peter Robinson
Modified: 2015-09-02 13:11 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-09-02 12:58:27 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Peter Robinson 2015-06-17 11:08:10 UTC
A use case I use quite a bit and which would be useful for more easily supporting certain ARM devices such as the Raspberry Pi is the ability to automatically reorder partitions on a disk to disk order.

At the moment I use the following work flow and manually edit the order/partition numbers in vi. The ability to be able to it with a single command line option would make it easier to script without error due to other possible issues.

[root@host ~]# sfdisk -d /dev/mmcblk0 > dp.txt
[root@host ~]# vi dp.txt
[root@host ~]# sfdisk -f /dev/mmcblk0 < dp.txt
Checking that no-one is using this disk right now ... OK

Disk /dev/mmcblk0: 14.7 GiB, 15720251392 bytes, 30703616 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: 0xbcdd5210

Old situation:

Device         Boot   Start     End Sectors  Size Id Type
/dev/mmcblk0p1       104448  690175  585728  286M 83 Linux
/dev/mmcblk0p2       690176 1087487  397312  194M 83 Linux
/dev/mmcblk0p3      1087488 3432447 2344960  1.1G 83 Linux
/dev/mmcblk0p4         2048  104447  102400   50M  b W95 FAT32

Partition table entries are not in disk order.

>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0xbcdd5210.
Created a new partition 1 of type 'W95 FAT32' and of size 50 MiB.
/dev/mmcblk0p2: Created a new partition 2 of type 'Linux' and of size 286 MiB.
/dev/mmcblk0p3: Created a new partition 3 of type 'Linux' and of size 194 MiB.
/dev/mmcblk0p4: Created a new partition 4 of type 'Linux' and of size 1.1 GiB.
All partitions used.

New situation:

Device         Boot   Start     End Sectors  Size Id Type
/dev/mmcblk0p1         2048  104447  102400   50M  b W95 FAT32
/dev/mmcblk0p2       104448  690175  585728  286M 83 Linux
/dev/mmcblk0p3       690176 1087487  397312  194M 83 Linux
/dev/mmcblk0p4      1087488 3432447 2344960  1.1G 83 Linux

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@host ~]#

Comment 1 Karel Zak 2015-09-02 12:58:27 UTC
I have added --reorder command line option to sfdisk. The feature will be available in v2.28 (probably f24). Thanks.

https://github.com/karelzak/util-linux/commit/b17431e6a048829bf2852ec5b50db48862c98d77

Comment 2 Peter Robinson 2015-09-02 13:11:00 UTC
That's really awesome! Thank you!


Note You need to log in before you can comment on or make changes to this bug.