{"id":162,"date":"2011-05-07T15:19:10","date_gmt":"2011-05-07T20:19:10","guid":{"rendered":"http:\/\/soljerome.com\/blog\/?p=162"},"modified":"2011-08-17T18:39:00","modified_gmt":"2011-08-17T23:39:00","slug":"using-kpartx-to-read-lvm-volumes","status":"publish","type":"post","link":"https:\/\/www.soljerome.com\/blog\/2011\/05\/07\/using-kpartx-to-read-lvm-volumes\/","title":{"rendered":"Using kpartx to read LVM volumes"},"content":{"rendered":"<p>As mentioned in a <a href=\"http:\/\/soljerome.com\/blog\/2010\/09\/07\/using-lvm-volumes-with-virtualbox\/\">previous post<\/a>, I use LVM volumes directly to store the virtual disks for my Virtualbox VMs. This post will guide you through how to access the contents of the virtual disk directly (so that you don&#8217;t need to boot the VM). The disk I&#8217;m working with is called &#8216;debian&#8217;.<\/p>\n<pre># lvscan | grep debian\r\n  ACTIVE            '\/dev\/vbox\/debian' [5.00 GiB] inherit<\/pre>\n<p>We need to create device maps from this LVM device&#8217;s partition tables.<\/p>\n<pre># kpartx -av \/dev\/vbox\/debian\r\nadd map vbox-debian1 (253:8): 0 9912042 linear \/dev\/vbox\/debian 63\r\nadd map vbox-debian2 (253:9): 0 562275 linear \/dev\/vbox\/debian 9912105\r\nadd map vbox-debian5 : 0 562212 linear 253:9 9912168<\/pre>\n<p>Now we can mount the image and grab any files we may need.<\/p>\n<pre># mkdir foo\r\n# mount \/dev\/mapper\/vbox-debian1 foo\/\r\n# ls foo\/\r\nbin   cdrom  etc  home        lib    lost+found  mnt  proc  sbin     srv  tmp  var\r\nboot  dev    foo  initrd.img  lib64  media       opt  root  selinux  sys  usr  vmlinuz<\/pre>\n<p>Once we are done accessing our files, we can go ahead and unmount the partition and delete the partition mappings.<\/p>\n<pre># umount foo\/\r\n# kpartx -d \/dev\/vbox\/debian<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>As mentioned in a previous post, I use LVM volumes directly to store the virtual disks for my Virtualbox VMs. This post will guide you through how to access the contents of the virtual disk directly (so that you don&#8217;t need to boot the VM). The disk I&#8217;m working with is called &#8216;debian&#8217;. # lvscan <a href='https:\/\/www.soljerome.com\/blog\/2011\/05\/07\/using-kpartx-to-read-lvm-volumes\/' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.soljerome.com\/blog\/wp-json\/wp\/v2\/posts\/162"}],"collection":[{"href":"https:\/\/www.soljerome.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.soljerome.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.soljerome.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.soljerome.com\/blog\/wp-json\/wp\/v2\/comments?post=162"}],"version-history":[{"count":6,"href":"https:\/\/www.soljerome.com\/blog\/wp-json\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":208,"href":"https:\/\/www.soljerome.com\/blog\/wp-json\/wp\/v2\/posts\/162\/revisions\/208"}],"wp:attachment":[{"href":"https:\/\/www.soljerome.com\/blog\/wp-json\/wp\/v2\/media?parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.soljerome.com\/blog\/wp-json\/wp\/v2\/categories?post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.soljerome.com\/blog\/wp-json\/wp\/v2\/tags?post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}