我正在使用parted
分区 a /dev/mapper/luks_device
.我知道我之后必须使用kpartx
加载分区映射(参考这个线程)。但是,在parted
by创建分区时mkpart swap 1 500
,我像往常一样收到以下错误。
(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?
做什么忽略和取消意思是?他们有什么区别?即使我输入“取消”,分区仍然会创建。
答案1
当分区表已经写入磁盘(并且写入成功)时,Parted 会问这个问题,因此分区存在,唯一剩下的就是告诉内核重新读取分区表。这是一个简单的系统调用 ( BLKRRPART
),但它失败了,因此 parted 现在只能通知您这一点。
两者之间唯一的区别是忽略和取消在这种情况下的答案是调用是否返回成功(如果您选择忽略)或失败(如果您选择取消)。因此,这个问题在交互模式下实际上没有意义,因为您没有检查返回代码,但在批处理模式下或使用 libparted 而不是 pared 时,它可能有意义。
在批处理模式下,命令返回代码根据您的选择进行设置。
为了忽略它返回 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
而对于取消它返回 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
失踪者信息:您可能需要更新 /etc/fstab。也是一个明显的区别。当命令被认为不成功时,parted 不会打印它。
注意:在上面的示例中,我尝试删除正在使用的分区以获得与您得到的相同错误,这是一种不同的情况,但行为是相同的,错误消息来自相同的 libparted 函数以将更改提交到磁盘。