Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux partprobe command

Linux partprobe command

Linux Command Reference Linux Command Reference


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

  1. Permission requirements: partprobe usually requires root privileges
  2. Use Cases: Mainly used after modifying the partition table with a partitioning tool
  3. Alternatives: You can also use blockdev --rereadpt Command
  4. 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:

  1. The partition table changes were not written to disk correctly
  2. The device is in use by another process
  3. 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

  1. Back up important data before performing partition operations
  2. Use lsblk or fdisk -l Verify partition changes
  3. In production environments, first verify the partitioning scheme on a test system
  4. Consider using -s Use 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 Linux Command Reference