Red Hat Bugzilla – Bug 1278767
parted doesnt tokenize "free" keyword when there is a warning for the partition
Last modified: 2015-11-09 17:43:11 EST
Description of problem:
parted doesnt tokenize "free" keyword when there is a warning for the partition.
Example of issue faced
[root@slab290vm4 omc]# parted /dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:8:0 unit MB print free
Warning: Not all of the space available to /dev/sde appears to be used, you can fix the GPT to use all of the space (an extra 20971520 blocks) or continue with the
parted: invalid token: free
Why is free an invalid token ? its valid if there is no warning associated with the partition.
[root@nkshirsa nkshirsa]# parted /dev/sda unit MB print free
Model: ATA SAMSUNG MZ7TE256 (scsi)
Disk /dev/sda: 256061MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
0.03MB 1.05MB 1.02MB Free Space
1 1.05MB 3222MB 3221MB primary ext4 boot
2 3222MB 256060MB 252838MB primary
256060MB 256061MB 0.35MB Free Space
Version-Release number of selected component (if applicable):
[root@slab290vm4 omc]# rpm -qa | grep parted
[root@slab290vm4 omc]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.7 (Santiago)
Steps to Reproduce:
1. run parted with "free" or possible any other supported token for a partition which has some warning associate with it, for instance, Warning: Not all of the space a appears to be used, or in case there is no backup partition table stored at the end of the disk.
parted should not claim free is an invalid token even if there is an associated warning for the partition.
I also would like a feature to suppress warnings in parted, in case the user tries to automate parted using the -s switch, the warnings require intervention and defeat the automation..
[root@sprintlab423vm4 ~]# /sbin/parted -s /dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:2:0 mkpart primary 65927MB 68075MB
Error: The backup GPT table is not at the end of the disk, as it should be. This might mean that another operating system believes the disk is smaller. Fix, by moving the backup to the end (and removing the old backup)?
Warning: Not all of the space available to /dev/sdc appears to be used, you can fix the GPT to use all of the space (an extra 4194304 blocks) or continue with the current setting?
Error: Unable to satisfy all constraints on the partition. <--------
You need to pass -s on the cmdline when using multiple commands. Also note that you are still prompted to fix/ignore when this happens.
is there also a way to suppress the parted warnings that break the automation ?
for instance, as soon as there is a warning and parted expected ignore/fix responses, the automation breaks.. how do we supress this warning to always ignore?
parted reads the commands from the cmdline as needed, the warning interrupts this and when not using -s it is processed as an invalid response.
You cannot suppress the warnings, and even if you could you wouldn't want to -- you'd end up losing data or with unexpected results. When -s is used any error or warning fails safe, preventing data loss.
If you are going to automate things by scripting with parted you need to use -s and check parted's return code.