Linux partprobe Command
partprobe is a utility in Linux systems used to notify the operating system to re-read the partition table. When you modify the disk partition table without restarting the system, partprobe helps the kernel recognize these changes.
Why do you need partprobe
In Linux systems, when you use tools such as fdisk or parted to modify disk partitions, these changes are not immediately recognized by the kernel. The traditional approach is to restart the system, but this is often not feasible in production environments. partprobe provides a way to have the kernel re-read the partition table without restarting.
Command Syntax
partprobe [选项] [设备...]
Common Options
| Option | Description |
|---|---|
-d |
Do not update the kernel |
-s |
Display summary information |
-h |
Display help information |
-v |
Display version information |
Usage Examples
Basic Usage
Re-read the partition table of the specified disk:
sudo partprobe /dev/sda
Display summary information
sudo partprobe -s
Output example:
/dev/sda: msdos partitions 1 2 3
Re-read the partition tables of all disks
sudo partprobe
How it works
partprobe triggers a partition table re-read by sending a BLKRRPART ioctl request to the kernel. This process involves the following steps:
Example
User ->> partprobe: Execute command
partprobe ->> Kernel: Send BLKRRPART request
Kernel ->> Disk driver: Re-read partition table
Disk driver -->> Kernel: Return new partition information
Kernel -->> partprobe: Operation result
partprobe -->> User: Display result or error
Notes
- Permission requirements: partprobe usually requires root privileges
- Usage scenarios: Mainly used after modifying the partition table with partition tools
- Alternatives: You can also use
blockdev --rereadptcommand - Risk warning: Improper use may cause system instability
FAQ
Q: What is the difference between partprobe and partx?
A: partprobe notifies the kernel to re-read the entire partition table, while partx allows more fine-grained control over adding or removing specific partitions.
Q: Why are my partitions still not visible after running partprobe?
A: Possible reasons include:
- The partition table changes were not correctly written to the disk
- The device is occupied by another process
- The kernel does not support the new partition type
Practical Application Scenarios
Scenario 1: Extending an LVM physical volume
Example
sudo fdisk /dev/sdb
# 2. Let the kernel recognize the new partition table
sudo partprobe /dev/sdb
# 3. Extend the physical volume
sudo pvresize /dev/sdb1
Scenario 2: Handling after adding a new partition
Example
sudo parted /dev/sdc mkpart primary ext4 1GB 5GB
# 2. Notify the kernel
sudo partprobe /dev/sdc
# 3. Format the new partition
sudo mkfs.ext4 /dev/sdc1
Best Practices
- Back up important data before performing partition operations
- Use
lsblkorfdisk -lto verify partition changes - In production environments, first validate the partitioning scheme on a test system
- Consider using the
-soption to view summary information first
Summary
partprobe is an important tool for Linux system administrators to maintain disk partitions. It solves the problem of needing to restart the system after modifying the partition table. Mastering the use of partprobe can significantly improve disk management efficiency, especially in environments where partitions need to be adjusted frequently.
Other Extensions
Linux Command Encyclopedia