HowTo: Reload (re-read) Partition Table In Ubuntu Linux

Posted on in Categories last updated May 25, 2010

How do I reload the partition table in Ubuntu Linux without rebooting the systems?

You need to install the parted package as follows
sudo apt-get update
sudo apt-get install parted

Once installed type the following command to re-read / reload the partition:
sudo partprobe
Finally, use mkfs.ext3 or mkfs.ext4 to create the file systems:
sudo mkfs.ext3 /dev/sdXY
Make sure you replace /dev/sdXY with actual device name and be careful do not type wrong device same. You may end up destroying working data. Please note that on server with RAID and SAS disk you may need to type the following command to rescan changes:
sudo echo 1 > /sys/block/sdd/device/rescan
sudo fdisk -l
sudo mkfs.ext3 /dev/sdXY

Again replace sdd with actual device name. Please note that above commands should work with all Linux distributions.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

10 comment

  1. Not only RPM, even Arch Linux and others if you use the default installation configuration.

    Ubuntu, Debian has always been weird and different from others !! :)^

    One who is used to RPM and others will have a tough time migrating to Debain/Ubuntu and vice-versa as it happened to me, though not migrating. Had to help a friend setup his Ubuntu VPS.

      1. In the era of multicore multiGHz CPUs, multiGB RAM and multiTB hard drives you would think that Linux could handle it autoFUCKINGmaticaly.
        Can you imagine how many man/hours around the world are wasted on doing this by hand, while system could do it in a fraction of a second. So here. Now I told how it should be done. Do you think it took a lot of brain power? You could probably come up with it on your own, but then again you’re Linux user. It’s all about being a slave to your computer, isn’t it?

        1. Sorry, but you still have to tell. HOW to do it without causing any other problem, like losing data.
          What you have done here is just been ranting like you actually know HOW to do this. But you have just told us how you WANT it to be done, not HOW it actually NEEDS to be done, without losing any data.
          But I guess it is easier to produce hot air then actually producing a sollution and/or some real code…

  2. I don’t think this works :
    sudo echo 1 > /sys/block/sdd/device/rescan

    You have to start a new shell with sudo, like this :
    sudo bash -c “echo 1 > /sys/block/sdd/device/rescan”

    Otherwise only echo is done with sudo permissions. The redirection “>” is done by your current shell which does not have sudo permissions.

  3. sudo -i

    # locate the scsi_disk

    ll /sys/class/scsi_disk/
    lrwxrwxrwx 1 root root 0 Mar 17 08:03 2:0:0:0 -> ../../devices/pci0000:00/0000:00:10.0/host2/target2:0:0/2:0:0:0/scsi_disk/2:0:0:0
    lrwxrwxrwx 1 root root 0 Mar 17 08:03 2:0:1:0 -> ../../devices/pci0000:00/0000:00:10.0/host2/target2:0:1/2:0:1:0/scsi_disk/2:0:1:0
    lrwxrwxrwx 1 root root 0 Mar 17 08:03 2:0:2:0 -> ../../devices/pci0000:00/0000:00:10.0/host2/target2:0:2/2:0:2:0/scsi_disk/2:0:2:0
    lrwxrwxrwx 1 root root 0 Mar 17 08:03 2:0:3:0 -> ../../devices/pci0000:00/0000:00:10.0/host2/target2:0:3/2:0:3:0/scsi_disk/2:0:3:0

    # In our case we have expanded the last disk (/devices/pci0000:00/0000:00:10.0/host2/target2:0:3/2:0:3:0/scsi_disk/2:0:3:0)
    # rescan the device

    echo 1 > /sys/class/scsi_disk/2\:0\:3\:0/device/rescan

    # create the new partition
    fdisk /dev/sdd
    # type “n”
    # write the partition number. e.g. “2”
    # type “t”
    # On Debian, CentOS 6 etc. is “8e”, on CentOS 7 “15”
    # type “w” to write to disk
    # As we already know write will fail

    # to re-read the partitions properly run partx on the device

    partx -v -a /dev/sdd
    # just for the sake of it
    pvcreate /dev/sdd2

    # add the physical volume to the corresponding volume group
    vgextend mainvg /dev/sdd2

    # confirm the disk has been added
    VG #PV #LV #SN Attr VSize VFree
    mainvg 5 6 0 wz–n- 102.90g 35.07g

    # expand the capacity of the logical volume
    lvextend -L+10G /dev/mainvg/LVopt

    # expand the file system capacity
    xfs_growfs /dev/mainvg/LVopt

    # df -hT to confirm all is done
    df -hT

Leave a Comment