今天在给服务器加一个硬盘分区,按照之前的Linux下添加硬盘分区的教程(详见https://blog.terrynow.com/2021/05/10/linux-ubuntu-centos-physical-or-virtual-machine-add-new-hard-disk/)
发现到添加好分区,有一个warning
Command (m for help): w The partition table has been altered! calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. 设备或资源忙. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
后面格式化分区的时候,报错,如下:
[root@localhost ~]# mkfs -t ext4 -c /dev/sdb1 ▽ mke2fs 1.42.9 (28-Dec-2013) Could not stat /dev/sdb1 --- No such file or directory The device apparently does not exist; did you specify it correctly?
查了网上的解决方案,大多数都说用mknod或者start_udev,在我这里都不管用,后来发现这个管用:
partprobe
让kernel更新分区表,可能之前因为硬盘已经在使用了,没有更新分区表,上面的提示就是重启系统,也可以不重启系统,那就是执行partprobe手动更新分区表
[root@localhost ~]# partprobe [root@localhost ~]# mkfs -t ext4 -c /dev/sdb1 # 接下来OK
文章评论