“kpartx” is a command-line tool that is used to create device maps from partition tables. It is commonly used in Linux to create device maps for partitions on block devices like disk images and loop devices.
A device map is a special file that provides access to a specific partition on a block device. When you create a device map for a partition, you can access the partition as if it were a separate block device. This allows you to mount the partition, read and write data to it, and perform other operations on it, just as you would with a regular block device.
kpartx is typically used to create device maps for partitions on disk images and loop devices. Disk images are files that contain a complete copy of a disk, including the partition table and file system. Loop devices are virtual block devices that can be used to access files as if they were block devices.
The kpartx command takes a block device as an argument and creates device maps for each partition on the device. The device maps are named /dev/mapper/[device_name]p[partition_number].
kpartx Command Examples
1. Add partition mappings:
# kpartx -a whole_disk.img
2. Delete partition mappings:
# kpartx -d whole_disk.img
3. List partition mappings:
# kpartx -l whole_disk.img