sfdisk --no-read 不起作用

vvn*_*hil 4 debian sfdisk

我正在尝试在 debian 8 上使用 sfdisk 扩展分区。我正在运行以下命令:

    sfdisk -H 255 -S 63 --quiet --Linux --leave-last -uM --force --no-reread /dev/md1 -N4 < /tmp/abc
Run Code Online (Sandbox Code Playgroud)

运行命令时出现以下错误:

    Successfully wrote the new partition table
    Re-reading the partition table ...
    sfdisk: BLKRRPART: Device or resource busy
    sfdisk: The command to re-read the partition table failed.
    Run partprobe(8), kpartx(8) or reboot your system now,before using mkfs
    sfdisk: If you created or changed a DOS partition, /dev/foo7, say, then use dd(1) to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1 (See fdisk(8).)
Run Code Online (Sandbox Code Playgroud)

为什么当我提到时会发生重读--no-reread?我sfdisk从 util-linux 2.25.2运行它。当我sfdisk从 sfdisk (util-linux-ng 2.17.2)运行相同的命令时,我没有遇到此错误。导致此错误发生的两者之间有什么区别吗?

Ste*_*ris 5

--no-reread选项告诉sfdisk不检查设备是否正在使用(例如安装或交换)。

你得到的错误是sfdisk告诉内核分区信息已经改变了;内核响应“嘿,此设备已在使用中;我不打算读取新的分区数据”。

所以现在分区数据的内核副本与磁盘上的实际数据不同。

没有--no-rereadthensfdisk根本不会让您进行分区。

  • `sfdisk` 告诉你;`partprobe`、`kpartx` 或重启。如果磁盘正在使用中(例如,它是与其他分区共享的根磁盘),则可能是重新启动是唯一的方法。为了安全,这就是我要做的:-) (2认同)