Re-read the partition table without rebooting Linux system

by LinuxTitli · 11 comments

If you are using hot swappable hard disk and created new partition using fdisk then you need to reboot Linux based system to get partition recognized. Without reboot you will NOT able to create filesystem on your newly created or modified partitions with the mke2fs command.

However with partprobe command you should able to create new file system without a reboot. It is a program that informs the operating system kernel of partition table changes, by requesting that the operating system re-read the partition table.

After fdisk session just type command:
# partprobe
Now you will able to create filesystem on with the mke2fs command.

Inform the OS of partition table changes

partprobe command is part of GNU parted software. parted is a disk partitioning and partition resizing program. It allows you to create, destroy, resize, move and copy ext2, ext3, linux-swap, FAT, FAT32, and reiserfs partitions. It can create, resize and move Macintosh HFS partitions, as well as detect jfs, ntfs, ufs, and xfs partitions. It is useful for creating space for new operating systems, reorganising disk usage, and copying data to new hard disks.

Install parted

In order to use partprobe command you need to install parted:
If you are using Debian / Ubuntu Linux, enter:
# apt-get install parted
OR if you are using RHEL version <= 4, enter:
# up2date parted
OR if you are using Fedora Linux / CentOS / RHEL 5, enter:
# yum install parted

See also:

=> See official parted home page for download and other information.

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 11 comments… read them below or add one }

1 Jeganatham 06.21.06 at 3:28 pm

Its a very good tip that can be used in a production evironment without any downtime

2 domen 12.07.06 at 12:48 pm

Thank you!

And to make this a bit more googlable:
fdisk printout: “Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy”

3 Jason 04.17.07 at 9:29 pm

When partprobe isn’t available you can also (sometimes) use:

# hdparm -z /dev/sdX

which will re-read that device’s partition table.

4 James Cassell 09.11.08 at 1:51 am

Thank You!

You saved me from having to restart my server!

(restarting is a real pain in the neck)

5 Romaric 09.15.08 at 8:49 pm

Thanks a lot !

And in order to install parted for gentoo users :

emerge -av parted

;)

6 Matti 02.12.09 at 8:30 am

Thanks for the tips (LINUXTITLI, Jason) and also thanks domen for making this more googlable!

Created a new partition from unformatted disk space (got error in re-reading the partition table: device busy) , partprobed, mkfs.ext3′d, e2labeled and mounted!
No reboot needed, thanks again. :)

7 jason 05.27.09 at 10:21 pm

I found this website while I was trying to figure out what the difference between the three ways I’ve found so far (partprobe, hdparm -z /dev/disk, and blockdev –rereadpt /dev/disk) is.

8 Schmoove 09.02.09 at 11:12 am

Boy was I happy to find this post. Just added a new partition to my gentoo production server after 463 days uptime and stumbled across the above mentioned ioctl warning. Thanks guys for the post and the comments :)

9 Harish 10.18.09 at 5:16 pm

Never was able to get the disk formatting re-read using partprobe. Had to reboot servers. May be to note that I am working on Redhat clusters with gfs. That shouldn’t matter much, as I run partprobe on both nodes.

10 Eric 10.24.09 at 12:32 pm

on RH systems you may need to run udevstart after partprobe

11 DaveQB 11.27.09 at 1:33 am

A 4th way is:

echo 1 > /sys/block/sdc/device/rescan

And follow dmesg to see the kernel rescan the disk. I found this worked on a server that partprobe did not.

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: