Linux partprobe command
partprobe is a Linux utility that tells the operating system to reread the partition table. When you modify a disk's partition table without rebooting, partprobe helps the kernel recognize those changes.
Why do you need partprobe
On Linux, when you use tools like fdisk or parted to modify disk partitions, the changes are not immediately recognized by the kernel. The traditional approach is to reboot, but that is often not feasible in production environments. partprobe provides a way to have the kernel reread the partition table without a reboot.
Command syntax
partprobe [选项] [设备...]
Commonly used 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
Reread the partition table of a specified disk:
sudo partprobe /dev/sda
Display summary information
sudo partprobe -s
Example output:
/dev/sda: msdos partitions 1 2 3
Reread the partition tables of all disks
sudo partprobe
How It Works
partprobe triggers a partition table reread by sending a BLKRRPART ioctl request to the kernel. This process involves the following steps:
Example
sequenceDiagram
User->>partprobe: Execute command
partprobe->>Kernel: Send BLKRRPART request
Kernel->>Disk driver: Reread partition table
Disk driver-->>Kernel: Return new partition info
Kernel-->>partprobe: Operation result
partprobe-->>User: Display result or error
Notes
- Permission requirements: partprobe usually requires root privileges
- Use Cases: Mainly used after modifying the partition table with a partitioning tool
- Alternatives: You can also use
blockdev --rereadptCommand - Risk warning: Improper use may cause system instability
Frequently Asked Questions
Q: What is the difference between partprobe and partx?
A: partprobe tells the kernel to reread the entire partition table, while partx gives finer 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 written to disk correctly
- The device is in use by another process
- The kernel does not support the new partition type
Practical Application Scenarios
Scenario 1: Extend an LVM physical volume
Example
1. Use fdisk to delete the old partition and create a larger new one
sudo
fdisk
/
dev
/
sdb
2. Have 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
1. Use parted to create a new partition
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 -lVerify partition changes - In production environments, first verify the partitioning scheme on a test system
- Consider using
-sUse the option to view summary information first
Summary
partprobe is an important tool for Linux system administrators maintaining disk partitions; it solves the problem of having to reboot after changing the partition table. Mastering partprobe can significantly improve the efficiency of disk management, especially in environments where partitions are adjusted frequently.
Linux Command Reference