Reload partition table without rebooting a Linux system

Submitted by Renan on Tue, 20/07/2010 - 22:17

After buying a new 500Gb hard-drive for my laptop(the 120Gb old one is without room :) ) I took to partitionate it and install my operating systems. As usual, first I've installed Windows(although I did not use frequently, it's impossible don't have it) and then Sidux(Sidux, Debian Sid based, stable, rolling-release, I recommend).

After all installed, I've forgoted creating some partitions for the Gentoo installation(learning purposes :) ) and my "file backup" partition(to share files between my systems). After creating the first ext4 partition using the KDE Partition Manager ( btw, KDE > Gnome ;) ), it could not format or do other operation in this fresh partition.

Searching arround for some time, I notice that the system are not listing the partition id at /dev. There have all the other partitions(/dev/sda1, /dev/sda2, /dev/sda5, etc) but not the new one(/dev/sda8, for example). After rebooting, it showed up. Then I conclude that the Linux Kernel, at booting, read the partition table and create all the resources in /dev -- a process that does not occour(at least, automatically) in runtime.

But, if cannot be done automatically, it can be done manually! :)

I've found 3 methods that force the Kernel reload the partition table and repopulate its ids in /dev.

Partprobe

This program has the objective to tell the Kernel reload the partition table of a device(Hard-disks, flash-drives, etc) in runtime. To use, install it in your distribution using the package management tools provided(in my case, it's Debian's apt-get):

# apt-get install partprobe

After, execute partprobe as root telling what device you want to reload the partition table:

# partprobe /dev/sdX (Where X is your device letter)

Done! Your system should have recognized the new partitions you have created! Now, just return to KPM and do the stuff(format/label/etc) your freshly created partition!

Hdparm

If partprobe did not work, its possible to do the same procedure using Hdparm: a general hard-disk utilitary. Just execute the following command as root:

#  hdparm -z /dev/sdX (Where X is your device letter)

Via Kernel interface

This method does not use any previous programs because it comunicates directly with the kernel interface. Because of that, there is no error recovering if something wrong happens while reloading your partition table. You are warned. I'm not responsible for any data loss or kryptonite damage you might suffer. :)

As root user, send the following signal to the kernel interface:

# echo 1 > /sys/block/sdX/device/rescan (Where X is your device letter)

Then, check the dmesg reported messages to confirm that the kernel done the reloading of the device's partition table.

After this, your partition(s) should be recognized and enabled in /dev, making it possible to format, label and mount them!

If you work with Linux servers, you know how painfull is to reboot a system. Using this tip you can work with partitions and avoid the downtime that one simple restart could do. ;)

0 comments

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <css>, <drupal6>, <html>, <java>, <javascript>, <jquery>, <php>, <python>, <ruby>, <sql>. The supported tag styles are: <foo>, [foo].

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.
"If debugging is the process of removing bugs, then programming must be the process of putting them in." Drupal theme by Kiwi Themes.