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

[root@localhost ~]# fdisk /dev/sda

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。


命令(输入 m 获取帮助):m
命令操作
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

命令(输入 m 获取帮助):n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
分区号 (3,4,默认 3):
起始 扇区 (3907024896-3907029167,默认为 3907024896):
将使用默认值 3907024896
Last 扇区, +扇区 or +size{K,M,G} (3907024896-3907029167,默认为 3907029167):
将使用默认值 3907029167
分区 3 已设置为 Linux 类型,大小设为 2.1 MiB

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
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)
正在同步磁盘。
[root@localhost ~]# fdisk -l

磁盘 /dev/sda:2000.4 GB, 2000398934016 字节,3907029168 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节
磁盘标签类型:dos
磁盘标识符:0x0001e77a

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048  3774896127  1887447040   83  Linux
/dev/sda2      3774896128  3907024895    66064384   82  Linux swap / Solaris
/dev/sda3      3907024896  3907029167        2136   83  Linux
分区正常,格式化错误。
[root@localhost ~]# mkfs  /dev/sda3
mke2fs 1.42.9 (28-Dec-2013)
无法对 /dev/sda3 进行 stat 调用 --- 没有那个文件或目录

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

原因是分区信息尚未到分区表里,

解决方法:执行下partprobe 命令

[root@localhost ~]# partprobe
[root@localhost ~]# mkfs -t ext4 /dev/sda3
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=4 blocks, Stripe width=4 blocks
272 inodes, 2136 blocks
106 blocks (4.96%) reserved for the super user
第一个数据块=1
Maximum filesystem blocks=2228224
1 block group
8192 blocks per group, 8192 fragments per group
272 inodes per group


Allocating group tables: 完成                            
正在写入inode表: 完成                            
Creating journal (1024 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

原文地址:https://www.cnblogs.com/weikunzz/p/6710532.html