Partprobe Command

If you are getting the following error after creating the partition using fdisk or parted tools and tyring to format the new partiton to support ext3 or other file system using mkfs.

 

Could not stat /dev/sdaX — No such file or directory
The device apparently does not exist; did you specify it correctly?

 

SOLUTION :

 

When we create a partition, an entry goes in the partition table of that device. This partition table is maintained in the 1st sector of that device. During booting kernel reads the partition table and loads it in memory. Apparently rebooting the system can helps the kernel to update the new addition while booting but if you still don’t want to reboot your server. You can try the partprob command fix.

 

Check the current partitions on the kernel table using

 

  • # cat /proc/partitions

 

Run the partprobe for a manual probe and update in the kernel table.

 

  • #partprobe

 

Now check the kernel partition table using cat /proc/partitions to see if you are able to list the new partiton. I have attached a screencaps below which helped adding /dev/sda4 partiton on the kernel table. You can now proceed with the mkfs command.

 

 

Partprobe

 

If still the partprobe command is not useful to update the kernel table you can try a direct rescan using the /sys for example (replace the sdX with your drive no) :

 

  • # echo 1 > /sys/block/sdX/device/rescan