Parted on /dev/mapper/, What are the differences between Ignore and Cancel?

I am using parted to partition a /dev/mapper/luks_device. I know that I have to use kpartx to load the partition mappings afterwards (with reference to this thread). However while creating partition in parted by mkpart swap 1 500, I get the following error as usual.

(parted) mkpart swap 1 500
Error: Partition(s) 1 on /dev/mapper/luks_device have been written, but we have been
unable to inform the kernel of the change, probably because it/they are in use.  As a
result, the old partition(s) will remain in use.  You should reboot now before making
further changes.
Ignore/Cancel? 

What do Ignore and Cancel mean? What are their differences? Even if I type "Cancel", the partition is still created.

Asked By: midnite

||

Parted asks this question when the partition table is already written to the disk (and the write was successful) so the partition exists and only thing that’s left is to tell kernel to re-read the partition table. That’s a simple syscall (BLKRRPART) and it failed so parted can only inform you about that now.

The only difference between the Ignore and Cancel answer in this case is whether the call returns success (in case you choose Ignore) or failure (in case you choose Cancel). So the question doesn’t really make sense in interactive mode because you are not checking the return code, but it can make sense in batch mode or when using libparted instead of parted.

In batch mode the command return code is set accordingly to your choice.

For Ignore it returns 0

$ sudo parted /dev/sdc rm 1
Warning: Partition /dev/sdc1 is being used. Are you sure you want to continue?
Yes/No? Yes                                                               
Error: Partition(s) 1 on /dev/sdc have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You
should reboot now before making further changes.
Ignore/Cancel? Ignore                                                     
Information: You may need to update /etc/fstab.

$ echo $?                                              
0

And for Cancel it returns 1:

$ sudo parted /dev/sdc rm 1
Warning: Partition /dev/sdc1 is being used. Are you sure you want to continue?
Yes/No? Yes                                                               
Error: Partition(s) 1 on /dev/sdc have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You
should reboot now before making further changes.
Ignore/Cancel? Cancel

$ echo $?
1

The missing Information: You may need to update /etc/fstab. is also one visible difference. It’s simply not printed by parted when the command is considered unsuccessful.

Note: In the example above I’ve tried to remove a partition in use to get the same error you got, it’s a different situation but the behaviour is the same, the error message comes from the same libparted function to commit changes to the disk.

Answered By: Vojtech Trefny
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.