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

4

I used fdisk /dev/sda to create an sda6 partition. Now I want to format it using the mkfs.ext4 command. I am using CentOS 6.5 Linux distro. But when I run this command I get following error

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

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

I am new to Linux and will appreciate any and all help. I have tried this with and without "sudo" and in both cases I get the same result.

[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?

After restart - >

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 ~]# partx /dev/sda

1: 2048- 8194047 ( 8192000 sectors, 4194 MB)

2: 8194048- 16386047 ( 8192000 sectors, 4194 MB)

3: 16386048- 24578047 ( 8192000 sectors, 4194 MB)

4: 24578048- 52428799 ( 27850752 sectors, 14259 MB)

5: 24582144- 32774143 ( 8192000 sectors, 4194 MB)

6: 32788665- 32901119 ( 112455 sectors, 57 MB)

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

mke2fs 1.41.12 (17-May-2010)

/dev/sda6 is apparently in use by the system; will not make a filesystem here!

[root@server1 ~]#

IMPORTANT i noticed that fdisk /dev/sda - n - 6 - w, partx, mkfs.ext4 /dev/sda6 worked on red hat 6.5 rhel i have but is not working for CentOS 6.5. i don't know why. Thanks

linux
partitioning
asked on Super User Sep 12, 2014 by linux_rhcsa • edited Sep 13, 2014 by linux_rhcsa

1 Answer

7

The kernal does not see the changes as you are partitioning your boot drive...

This is because you could have removed the partition that contains your kernel.

You need to reboot or run partprobe.

answered on Super User Sep 13, 2014 by mjz19910

User contributions licensed under CC BY-SA 3.0