← 返回命令列表

Linux command

kpartx 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Add

kpartx -av [whole_disk.img]

Delete

kpartx -d [whole_disk.img]

List

kpartx -l [whole_disk.img]

说明

kpartx creates device mapper entries for the partitions within a disk image or block device. This allows individual partitions to be accessed as separate block devices, enabling mounting and manipulation. When adding mappings, kpartx creates entries like /dev/mapper/loop0p1, /dev/mapper/loop0p2, etc., corresponding to each partition found in the image.

参数

-a
Add partition mappings
-d
Delete partition mappings
-l
List partition mappings without adding them
-v
Verbose output
-s
Sync mode (wait for udev to update)
-f
Force creation of mappings

FAQ

What is the kpartx command used for?

kpartx creates device mapper entries for the partitions within a disk image or block device. This allows individual partitions to be accessed as separate block devices, enabling mounting and manipulation. When adding mappings, kpartx creates entries like /dev/mapper/loop0p1, /dev/mapper/loop0p2, etc., corresponding to each partition found in the image.

How do I run a basic kpartx example?

Run `kpartx -av [whole_disk.img]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a do in kpartx?

Add partition mappings