{"id":165,"date":"2016-02-13T11:04:33","date_gmt":"2016-02-13T10:04:33","guid":{"rendered":"https:\/\/tollana.d-tor.org\/notes-to-self\/?p=165"},"modified":"2016-11-27T00:47:43","modified_gmt":"2016-11-26T23:47:43","slug":"mount-partition-from-qcow2-image","status":"publish","type":"post","link":"https:\/\/tollana.d-tor.org\/notes-to-self\/?p=165","title":{"rendered":"Mount partition from qcow2-image"},"content":{"rendered":"<p>It&#8217;s surprisingly easy if you have the right tools. That would be:<\/p>\n<ul>\n<li>The kernel module nbd (Network Block Device)<\/li>\n<li>qemu (specifically qemu-nbd)<\/li>\n<\/ul>\n<p>To expose the whole image as \/dev\/nbd0:<\/p>\n<pre># qemu-nbd -c \/dev\/nbd0 &lt;\/path\/to\/qcow2&gt;<\/pre>\n<p>If you only want a specific partition:<\/p>\n<pre># qemu-nbd -c \/dev\/nbd0 -P 2 &lt;\/path\/to\/qcow2&gt;<\/pre>\n<p>gives you the 2nd Partition on \/dev\/nbd0. If it contains a valid filesystem, mount it with:<\/p>\n<pre># mount \/dev\/nbd0 \/mnt\/point<\/pre>\n<p>To get rid of it:<\/p>\n<ul>\n<li>Unmount it<\/li>\n<li>kill the according qemu-nbd process<\/li>\n<\/ul>\n<p>Share and enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s surprisingly easy if you have the right tools. That would be: The kernel module nbd (Network Block Device) qemu (specifically qemu-nbd) To expose the whole image as \/dev\/nbd0: # qemu-nbd -c \/dev\/nbd0 &lt;\/path\/to\/qcow2&gt; If you only want a specific partition: # qemu-nbd -c \/dev\/nbd0 -P 2 &lt;\/path\/to\/qcow2&gt; gives you the 2nd Partition on \/dev\/nbd0. &hellip; <a href=\"https:\/\/tollana.d-tor.org\/notes-to-self\/?p=165\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Mount partition from qcow2-image<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[77],"tags":[85,84],"class_list":["post-165","post","type-post","status-publish","format-standard","hentry","category-linux","tag-nbd","tag-qemu"],"_links":{"self":[{"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=\/wp\/v2\/posts\/165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=165"}],"version-history":[{"count":1,"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=\/wp\/v2\/posts\/165\/revisions"}],"predecessor-version":[{"id":166,"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=\/wp\/v2\/posts\/165\/revisions\/166"}],"wp:attachment":[{"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}