Linux 格式化分区 报错Could not stat --- No such file or directory

添加分区后,无法格式化
原先分区情况如下:
[root@test /]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 13 104391 83 Linux

/dev/sda2 14 650 5116702+ 83 Linux

/dev/sda3 651 841 1534207+ 82 Linux swap / Solaris

使用fdisk添加一个分区之后分区情况如下
[root@test /]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 13 104391 83 Linux

/dev/sda2 14 650 5116702+ 83 Linux

/dev/sda3 651 841 1534207+ 82 Linux swap / Solaris

/dev/sda4 842 2610 14209492+ 83 Linux

格式化磁盘分区的时候报错
[root@test /]# mkfs.ext3 /dev/sda4

mke2fs 1.39 (29-May-2006)

Could not stat /dev/sda4 — No such file or directory

 

The device apparently does not exist; did you specify it correctly?

解决方法:执行下partprobe 命令,问题就可以解决
partprobe包含在parted的rpm软件包中。partprobe可以修改kernel中分区表,使kernel重新读取分区表。 因此,使用该命令就可以创建分区并且在不重新启动机器的情况下系统能够识别新的分区。
使用命令前确认安装了parted软件包
[root@test /]# rpm -qa | grep parted
执行命令解决问题
[root@test/]# partprobe

Warning: Unable to open /dev/hdc read-write (Read-only file system). /dev/hdc has been opened read-only.
最后再执行格式化,发现一切OK,