• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

kpartx Command Examples in Linux

by Deepika

“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

Filed Under: Linux

Some more articles you might also be interested in …

  1. subscription-manager: command not found
  2. datamash: command not found
  3. Troubleshooting common NFS issues in Linux
  4. How to use the “screen” command in Linux
  5. CentOS / RHEL 6 : How to limit memory resources for a specific user using cgroups
  6. daemon Command Examples in Linux
  7. How to Reserve a Port Range for a Third Party Application in CentOS/RHEL
  8. How to configure kdump in Oracle Enterprise Linux (OEL 5,6)
  9. CentOS / RHEL 6 : How to completely remove device mapper multipath (dm-multipath)
  10. Connection using SSH to a Host Not in DNS/hosts Stalls for Some Time at Connection Initiation

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright