mkfs - 该设备显然不存在;您是否正确指定了它?

lin*_*csa 4 linux partitioning

我曾经fdisk /dev/sda创建过一个 sda6 分区。现在我想使用mkfs.ext4命令对其进行格式化。我正在使用 CentOS 6.5 Linux 发行版。但是当我运行这个命令时,我收到以下错误

mkfs.ext4 
Could not stat /dev/sda6 --- No such file or directory

The device apparently does not exist; did you specify it correctly?
Run Code Online (Sandbox Code Playgroud)

我是 Linux 新手,将感谢任何和所有帮助。我在有和没有“sudo”的情况下都试过这个,在这两种情况下我都得到了相同的结果。

[root@server1 ~]# sudo fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
First cylinder (1530-3264, default 1530): 2042
Last cylinder, +cylinders or +size{K,M,G} (2042-3264, default 3264): +50MB

Command (m for help): p

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00002158

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         511     4096000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2             511        1020     4096000   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3            1020        1530     4096000   83  Linux
/dev/sda4            1530        3264    13925376    5  Extended
/dev/sda5            1531        2041     4096000   83  Linux
/dev/sda6            2042        2048       56227+  83  Linux

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@server1 ~]# mkfs.ext4 /dev/sda6

mke2fs 1.41.12 (17-May-2010)
Could not stat /dev/sda6 --- No such file or directory

The device apparently does not exist; did you specify it correctly?
Run Code Online (Sandbox Code Playgroud)

重启后->

命令(m 寻求帮助):p

磁盘 /dev/sda:26.8 GB,26843545600 字节 255 个磁头,63 个扇区/磁道,3263 个柱面 单位 = 16065 个柱面 * 512 = 8225280 字节 扇区大小(逻辑/物理):512 字节 / 512 字节大小(最小 I/O) /optimal):512 字节 / 512 字节磁盘标识符:0x00002158

Device Boot Start End Blocks Id System /dev/sda1 * 1 511 4096000 83 Linux 分区 1 未在柱面边界上结束。/dev/sda2 511 1020 4096000 82 Linux 交换区 / Solaris 分区 2 未在柱面边界处结束。/dev/sda3 1020 1530 4096000 83 Linux /dev/sda4 1530 3264 13925376 5 扩展 /dev/sda5 1531 2041 4096000 83 Linux /dev/sda6 2087+2 3 Linux 8

命令 (m for help): w 分区表已更改!

调用 ioctl() 重新读取分区表。

警告:重新读取分区表失败,错误 16:设备或资源繁忙。内核仍然使用旧表。新表将在下次重新启动或运行 partprobe(8) 或 kpartx(8) 同步磁盘后使用。

[root@server1 ~]# partx /dev/sda

1:2048-8194047(8192000 个扇区,4194 MB)

2:8194048-16386047(8192000 个扇区,4194 MB)

3:16386048-24578047(8192000 个扇区,4194 MB)

4:24578048-52428799(27850752 个扇区,14259 MB)

5:24582144-32774143(8192000 个扇区,4194 MB)

6:32788665-32901119(112455 个扇区,57 MB)

[root@server1 ~]# mkfs.ext4 /dev/sda6

mke2fs 1.41.12(2010 年 5 月 17 日)

/dev/sda6 显然正在被系统使用;不会在这里创建文件系统!

[root@server1 ~]#

重要 我注意到 fdisk /dev/sda - n - 6 - w, partx, mkfs.ext4 /dev/sda6 在我拥有的 red hat 6.5 rhel 上工作,但不适用于 CentOS 6.5。我不知道为什么。谢谢

小智 7

当您对引导驱动器进行分区时,内核看不到更改...

这是因为您可以删除包含内核的分区。

您需要重新启动或运行 partprobe。