partprobe Command: Tutorial & Examples
Re-read the partition table
In the Linux world, when you deal with storage devices such as hard drives or solid-state drives, managing partitions is
a crucial task. Partitions are sections on a storage device that divide it into separate logical units. Linux provides a
powerful command called
partprobe that plays a vital role in the management of partitions.
partprobe command is used to inform the operating system about any changes in the partition table of a storage
device without requiring a system reboot. This means that when you create, delete, or modify partitions on a
partprobe can be used to update the system and make it aware of the changes immediately. This is especially
useful when working on remote servers or virtual machines (VMs) where rebooting the system to apply partition changes
might not be feasible.
partprobe work and why is it important?
When you create, delete, or modify partitions on a storage device, the partition table needs to be updated to reflect those changes accurately. The Linux kernel, which is the core of the operating system, maintains this partition table in memory. Normally, the kernel detects these changes automatically, but sometimes, it may not recognize the new or modified partitions until you perform some action.
This is where
partprobe comes to the rescue. It sends a signal to the kernel to re-read the partition table of the
specified device, which allows the kernel to detect any changes. After
partprobe has been executed, the system will be
aware of the new or updated partitions, and you can immediately start using them without rebooting the entire system.
Typical problems solved with
Imagine you are working on a remote Linux server, and you need to resize a partition to accommodate more data. Using
traditional methods, you would have to unmount the partition, modify the partition table, and then remount the
partition. However, without
partprobe, the system wouldn't recognize the changes until you reboot it, causing
inconvenience and downtime for users.
partprobe, you can instantly update the partition table without a reboot, minimizing disruption and ensuring
the changes take effect immediately. This can be a lifesaver in critical server environments where downtime must be
avoided whenever possible.
Examples of using
1. Basic Usage
partprobe, you typically specify the device you want to update. For example, to update partitions
/dev/sdb, you can run:
sudo partprobe /dev/sdb
2. Using with
Since updating partition information requires administrative privileges, you'll likely use
sudo partprobe /dev/sdc
3. Automating with
udev is a Linux subsystem responsible for device handling, including handling device changes. If you're automating
partition management, you can use
udev rules to automatically trigger
partprobe whenever a partition change occurs.
The rule would look something like this:
ACTION=="change", KERNEL=="sdb*", RUN+="/sbin/partprobe /dev/%k"
This rule will automatically execute
partprobe on any device starting with "sdb" when a change is detected.
partprobe command is a handy tool that makes managing partitions on Linux servers and VMs more convenient and less
disruptive. By allowing the kernel to recognize partition changes without requiring a reboot, it saves time, minimizes
downtime, and ensures your server runs efficiently. Whether you're a beginner or an experienced sysadmin,
a valuable addition to your Linux toolkit.