You are viewing a read-only archive of the Blogs.Harvard network. Learn more.
Skip to content

Rereading a disk partition table in Linux without rebooting

Ran into a problem with trying to partition up a disk on a running system. The idea is I wanted to create a new partition on a disk with partitions already mounted and use it without rebooting.

Here’s what you’ll mostly likely run into…

# sudo fdisk /dev/sda
... Steps for adding disk  elided ...

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.
Syncing disks.

ahoang@jp-db-3:~$ sudo mke2fs -m 0 -j /dev/sda3
mke2fs 1.40.2 (12-Jul-2007)
Could not stat /dev/sda3 --- No such file or directory

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

# ls -la /dev/sda*
/dev/sda   /dev/sda1  /dev/sda2  

The simplest thing to do is just reboot and Linux will redetect everything on restart. However, sometimes you just can’t reboot. After Googling around it seems that partprobe does the job handily. Luckily this tool is already on an Ubuntu system so no need to apt-get install but it’s only a few keystrokes away.

Here’s the rest of the log once I ran partprobe and was humming along…

# sudo partprobe
# ls /dev/sda*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3
# sudo mke2fs -m 0 -j /dev/sda3
mke2fs 1.40.2 (12-Jul-2007)
... Creating a file system output elided ...
Be Sociable, Share!