Working with kpartx Command in Red Hat Enterprise Linux

This tool, derived from util-linux’ partx, reads partition tables on specified device and create device maps over partitions segments detected. It is called from hotplug upon device maps creation and deletion.

kpartx [-a | -d | -l] [-v] wholedisk

Usage Example

To mount all the partitions in a raw disk image:

kpartx -av disk.img

This will output lines such as:

loop3p1 : 0 20964762 /dev/loop3 63

The loop3p1 is the name of a device file under /dev/mapper which you can use to access the partition, for example to fsck it:

fsck /dev/mapper/loop3p1

When you’re done, you need to remove the devices:

kpartx -d disk.img



  • -a Add partition mappings
  • -r Read-only partition mappings
  • -d Delete partition mappings
  • -u Update partition mappings
  • -l List partition mappings that would be added -a
  • -p set device name-partition number delimiter
  • -f force creation of mappings; overrides ‘no_partitions’ feature
  • -g force GUID partition table (GPT)
  • -v Operate verbosely
  • -s Sync mode. Don’t return until the partitions are created




I have started ( aka in 2009 as my own personal reference blog, and later sometime i have realized that my leanings might be helpful for other unixadmins if I manage my knowledge-base in more user friendly format. And the result is today's' You can connect me at -

What is in your mind, about this post ? Leave a Reply

  Our next learning article is ready, subscribe it in your email

What is your Learning Goal for Next Six Months ? Talk to us