KPARTX(8)

๐Ÿ“ฆ
version 0.14.3 ยท 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

๐ŸŽ€ KPARTX(8) โ€” the kpartx manual ๐ŸŽ€

โœจ NAME โœจ

okay so kpartx is the tool that turns partitions into device maps ๐Ÿ’… It creates device maps from partition tables.

๐ŸŒธ SYNOPSIS ๐ŸŒธ

kpartx [-a|-d|-u|-l] [-r] [-p] [-f] [-g] [-s|-n] [-v] wholedisk

๐Ÿ’– DESCRIPTION ๐Ÿ’–

bestie, this one is lowkey iconic. It's derived from util-linux' partx ๐Ÿฆ‹ It reads the partition tables on the device you give it and creates device maps over the partition segments it finds. Hotplug calls it when device maps get created and deleted, so you don't have to do that part yourself โœจ

๐Ÿ‘‘ OPTIONS ๐Ÿ‘‘

  • -a โ€” add partition mappings ๐Ÿซถ
  • -d โ€” delete partition mappings ๐Ÿ’€
  • -u โ€” update partition mappings ๐Ÿ”ฅ
  • -l โ€” list the partition mappings that would be added by -a ๐Ÿ‘€
  • -r โ€” make the partition mappings read-only ๐Ÿ™ˆ
  • -p โ€” set the delimiter between the device name and the partition number ๐Ÿงš
  • -f โ€” force the creation of mappings, even if it overrides the no_partitions feature ๐Ÿ˜ญ
  • -g โ€” force a GUID partition table (GPT) ๐Ÿ’œ
  • -s โ€” sync mode, which is the default โœจ it won't return until the partitions are created, so no cap, you can rely on it being done
  • -n โ€” nosync mode ๐ŸŒˆ it returns before the partitions are created
  • -v โ€” operate verbosely ๐Ÿ“ฃ

๐Ÿงš EXAMPLE ๐Ÿงš

okay so say you want to mount all the partitions in a raw disk image ๐Ÿฅน you'd run:

kpartx -av disk.img

and it'll print lines that look like this:

add map loop1p1 (254:4): 0 409597 linear 7:1 3

the loop1p1 bit is the name of a device file under /dev/mapper, and that's what you use to get at the partition. for example, to fsck it:

fsck /dev/mapper/loop1p1

when you're finished, you need to remove the devices too, so run:

kpartx -d disk.img

๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

multipath(8) multipathd(8) hotplug(8)

๐Ÿ’… AUTHORS ๐Ÿ’…

this man page was assembled By Patrick Caulfield for the Debian project ๐Ÿ“

multipath-tools was developed by Christophe Varoqui <christophe.varoqui@opensvc.com> and others ๐Ÿซถ


that's the whole tea, bestie ๐ŸŒˆโœจ this page is from the Linux manual, dated 2019-04-27, and it's all about KPARTX(8) ๐Ÿ’– love you, mwah ๐Ÿ˜˜๐ŸŽ€