← 返回命令列表

Linux command

partx 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

List

sudo partx -l [path/to/device_or_disk_image]

Add

sudo partx -a -v [path/to/device_or_disk_image]

Delete

sudo partx -d [path/to/device_or_disk_image]

说明

partx tells the Linux kernel about the presence and numbering of on-disk partitions. It parses a partition table and updates the kernel's in-memory representation without modifying the disk. This is useful when partitions have been added or removed while the disk was in use. The tool can read partition tables from both block devices and disk image files. It supports multiple partition table formats including DOS/MBR, GPT, BSD, and others.

参数

-a, --add
Add specified partitions to the kernel
-d, --delete
Delete specified partitions from the kernel
-s, --show
List partitions (default if no action specified)
-l, --list
Same as --show (list partitions)
-u, --update
Update specified partitions
-n, --nr _M_:_N_
Specify range of partitions (M to N)
-t, --type _type_
Specify partition table type (dos, gpt, etc.)
-o, --output _list_
Define which columns to show
-g, --noheadings
Do not print headings
-b, --bytes
Print sizes in bytes
-r, --raw
Use raw output format
-v, --verbose
Verbose mode

FAQ

What is the partx command used for?

partx tells the Linux kernel about the presence and numbering of on-disk partitions. It parses a partition table and updates the kernel's in-memory representation without modifying the disk. This is useful when partitions have been added or removed while the disk was in use. The tool can read partition tables from both block devices and disk image files. It supports multiple partition table formats including DOS/MBR, GPT, BSD, and others.

How do I run a basic partx example?

Run `sudo partx -l [path/to/device_or_disk_image]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a, --add do in partx?

Add specified partitions to the kernel