How do I mount a qcow2 disk image?












20














I have a QEMU virtual machine that uses a qcow2 disk image.



How can I mount its filesystem without powering on the virtual machine?










share|improve this question



























    20














    I have a QEMU virtual machine that uses a qcow2 disk image.



    How can I mount its filesystem without powering on the virtual machine?










    share|improve this question

























      20












      20








      20


      2





      I have a QEMU virtual machine that uses a qcow2 disk image.



      How can I mount its filesystem without powering on the virtual machine?










      share|improve this question













      I have a QEMU virtual machine that uses a qcow2 disk image.



      How can I mount its filesystem without powering on the virtual machine?







      mount virtualization qemu






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 19 '10 at 22:36









      ændrükændrük

      41.7k61194337




      41.7k61194337






















          4 Answers
          4






          active

          oldest

          votes


















          16














          A quick google search turns up the qemu-nbd program, mentioned here. It is part of the qemu-kvm package, so you'll have to install KVM if you aren't using that already. Not sure about any direct GNOME/KDE solutions, if that is what you were looking for. Here is an example for using it:



          sudo modprobe nbd
          sudo qemu-nbd -c /dev/nbd0 --read-only /path/to/image.qcow2
          udisksctl mount -b /dev/nbd0p1





          share|improve this answer



















          • 2




            Looks like qemu-nbd is the best way to go, as long as I remember to modprobe nbd first. qemu-nbd fails silently if this module has not been loaded!
            – ændrük
            Sep 24 '10 at 16:03












          • That's unfortunate. You should be able to add nbd to /etc/modules, anyway.
            – Tim Yates
            Sep 24 '10 at 16:54










          • I wrote a little tool to wrap this up: github.com/JonathonReinhart/qcow2-explore
            – Jonathon Reinhart
            Nov 23 '16 at 1:49



















          4














          There's also libguestfs, but it's not yet available from official repositories1. There are binaries in libguestfs.org though.






          share|improve this answer























          • While libguestfs looks really nice, but is heavyweight. It has a ton of dependencies (It recommends up to 55 dependencies, and installs an entire supermin appliance.
            – Stefan Lasiewski
            Mar 4 '13 at 5:53



















          -1














          xmount can make the disk images of some VMs look like a raw disk (which can then be partitioned with losetup, and the partitions mounted). I don't know if it supports qcow2, however.






          share|improve this answer





















          • The xmount manual states that only EWF and raw disk images can be used.
            – ændrük
            Sep 21 '10 at 2:21



















          -2














          you can directly mount as a normal mount like this



          mount /dev/sdb1 /mount-point


          But if u have n number of device mean you want again mount it to another directory for
          that you can follow this one:



          Mounting a partition from raw image is pretty simple:



          losetup /dev/loop0 image.img
          kpartx -a /dev/loop0
          mount /dev/mapper/loop0p1 /mnt/image





          share|improve this answer



















          • 1




            A qcow2 image is not a raw image, and can't be mounted through either of those approaches.
            – Twirrim
            Mar 15 '18 at 23:03











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f4396%2fhow-do-i-mount-a-qcow2-disk-image%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          16














          A quick google search turns up the qemu-nbd program, mentioned here. It is part of the qemu-kvm package, so you'll have to install KVM if you aren't using that already. Not sure about any direct GNOME/KDE solutions, if that is what you were looking for. Here is an example for using it:



          sudo modprobe nbd
          sudo qemu-nbd -c /dev/nbd0 --read-only /path/to/image.qcow2
          udisksctl mount -b /dev/nbd0p1





          share|improve this answer



















          • 2




            Looks like qemu-nbd is the best way to go, as long as I remember to modprobe nbd first. qemu-nbd fails silently if this module has not been loaded!
            – ændrük
            Sep 24 '10 at 16:03












          • That's unfortunate. You should be able to add nbd to /etc/modules, anyway.
            – Tim Yates
            Sep 24 '10 at 16:54










          • I wrote a little tool to wrap this up: github.com/JonathonReinhart/qcow2-explore
            – Jonathon Reinhart
            Nov 23 '16 at 1:49
















          16














          A quick google search turns up the qemu-nbd program, mentioned here. It is part of the qemu-kvm package, so you'll have to install KVM if you aren't using that already. Not sure about any direct GNOME/KDE solutions, if that is what you were looking for. Here is an example for using it:



          sudo modprobe nbd
          sudo qemu-nbd -c /dev/nbd0 --read-only /path/to/image.qcow2
          udisksctl mount -b /dev/nbd0p1





          share|improve this answer



















          • 2




            Looks like qemu-nbd is the best way to go, as long as I remember to modprobe nbd first. qemu-nbd fails silently if this module has not been loaded!
            – ændrük
            Sep 24 '10 at 16:03












          • That's unfortunate. You should be able to add nbd to /etc/modules, anyway.
            – Tim Yates
            Sep 24 '10 at 16:54










          • I wrote a little tool to wrap this up: github.com/JonathonReinhart/qcow2-explore
            – Jonathon Reinhart
            Nov 23 '16 at 1:49














          16












          16








          16






          A quick google search turns up the qemu-nbd program, mentioned here. It is part of the qemu-kvm package, so you'll have to install KVM if you aren't using that already. Not sure about any direct GNOME/KDE solutions, if that is what you were looking for. Here is an example for using it:



          sudo modprobe nbd
          sudo qemu-nbd -c /dev/nbd0 --read-only /path/to/image.qcow2
          udisksctl mount -b /dev/nbd0p1





          share|improve this answer














          A quick google search turns up the qemu-nbd program, mentioned here. It is part of the qemu-kvm package, so you'll have to install KVM if you aren't using that already. Not sure about any direct GNOME/KDE solutions, if that is what you were looking for. Here is an example for using it:



          sudo modprobe nbd
          sudo qemu-nbd -c /dev/nbd0 --read-only /path/to/image.qcow2
          udisksctl mount -b /dev/nbd0p1






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 4 at 3:34









          Mihai Capotă

          1,46911318




          1,46911318










          answered Sep 20 '10 at 1:08









          Tim YatesTim Yates

          27624




          27624








          • 2




            Looks like qemu-nbd is the best way to go, as long as I remember to modprobe nbd first. qemu-nbd fails silently if this module has not been loaded!
            – ændrük
            Sep 24 '10 at 16:03












          • That's unfortunate. You should be able to add nbd to /etc/modules, anyway.
            – Tim Yates
            Sep 24 '10 at 16:54










          • I wrote a little tool to wrap this up: github.com/JonathonReinhart/qcow2-explore
            – Jonathon Reinhart
            Nov 23 '16 at 1:49














          • 2




            Looks like qemu-nbd is the best way to go, as long as I remember to modprobe nbd first. qemu-nbd fails silently if this module has not been loaded!
            – ændrük
            Sep 24 '10 at 16:03












          • That's unfortunate. You should be able to add nbd to /etc/modules, anyway.
            – Tim Yates
            Sep 24 '10 at 16:54










          • I wrote a little tool to wrap this up: github.com/JonathonReinhart/qcow2-explore
            – Jonathon Reinhart
            Nov 23 '16 at 1:49








          2




          2




          Looks like qemu-nbd is the best way to go, as long as I remember to modprobe nbd first. qemu-nbd fails silently if this module has not been loaded!
          – ændrük
          Sep 24 '10 at 16:03






          Looks like qemu-nbd is the best way to go, as long as I remember to modprobe nbd first. qemu-nbd fails silently if this module has not been loaded!
          – ændrük
          Sep 24 '10 at 16:03














          That's unfortunate. You should be able to add nbd to /etc/modules, anyway.
          – Tim Yates
          Sep 24 '10 at 16:54




          That's unfortunate. You should be able to add nbd to /etc/modules, anyway.
          – Tim Yates
          Sep 24 '10 at 16:54












          I wrote a little tool to wrap this up: github.com/JonathonReinhart/qcow2-explore
          – Jonathon Reinhart
          Nov 23 '16 at 1:49




          I wrote a little tool to wrap this up: github.com/JonathonReinhart/qcow2-explore
          – Jonathon Reinhart
          Nov 23 '16 at 1:49













          4














          There's also libguestfs, but it's not yet available from official repositories1. There are binaries in libguestfs.org though.






          share|improve this answer























          • While libguestfs looks really nice, but is heavyweight. It has a ton of dependencies (It recommends up to 55 dependencies, and installs an entire supermin appliance.
            – Stefan Lasiewski
            Mar 4 '13 at 5:53
















          4














          There's also libguestfs, but it's not yet available from official repositories1. There are binaries in libguestfs.org though.






          share|improve this answer























          • While libguestfs looks really nice, but is heavyweight. It has a ton of dependencies (It recommends up to 55 dependencies, and installs an entire supermin appliance.
            – Stefan Lasiewski
            Mar 4 '13 at 5:53














          4












          4








          4






          There's also libguestfs, but it's not yet available from official repositories1. There are binaries in libguestfs.org though.






          share|improve this answer














          There's also libguestfs, but it's not yet available from official repositories1. There are binaries in libguestfs.org though.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 20 '15 at 19:21









          Community

          1




          1










          answered Sep 16 '11 at 22:14









          sendmoreinfosendmoreinfo

          22437




          22437












          • While libguestfs looks really nice, but is heavyweight. It has a ton of dependencies (It recommends up to 55 dependencies, and installs an entire supermin appliance.
            – Stefan Lasiewski
            Mar 4 '13 at 5:53


















          • While libguestfs looks really nice, but is heavyweight. It has a ton of dependencies (It recommends up to 55 dependencies, and installs an entire supermin appliance.
            – Stefan Lasiewski
            Mar 4 '13 at 5:53
















          While libguestfs looks really nice, but is heavyweight. It has a ton of dependencies (It recommends up to 55 dependencies, and installs an entire supermin appliance.
          – Stefan Lasiewski
          Mar 4 '13 at 5:53




          While libguestfs looks really nice, but is heavyweight. It has a ton of dependencies (It recommends up to 55 dependencies, and installs an entire supermin appliance.
          – Stefan Lasiewski
          Mar 4 '13 at 5:53











          -1














          xmount can make the disk images of some VMs look like a raw disk (which can then be partitioned with losetup, and the partitions mounted). I don't know if it supports qcow2, however.






          share|improve this answer





















          • The xmount manual states that only EWF and raw disk images can be used.
            – ændrük
            Sep 21 '10 at 2:21
















          -1














          xmount can make the disk images of some VMs look like a raw disk (which can then be partitioned with losetup, and the partitions mounted). I don't know if it supports qcow2, however.






          share|improve this answer





















          • The xmount manual states that only EWF and raw disk images can be used.
            – ændrük
            Sep 21 '10 at 2:21














          -1












          -1








          -1






          xmount can make the disk images of some VMs look like a raw disk (which can then be partitioned with losetup, and the partitions mounted). I don't know if it supports qcow2, however.






          share|improve this answer












          xmount can make the disk images of some VMs look like a raw disk (which can then be partitioned with losetup, and the partitions mounted). I don't know if it supports qcow2, however.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 20 '10 at 23:59









          GillesGilles

          44.6k1399140




          44.6k1399140












          • The xmount manual states that only EWF and raw disk images can be used.
            – ændrük
            Sep 21 '10 at 2:21


















          • The xmount manual states that only EWF and raw disk images can be used.
            – ændrük
            Sep 21 '10 at 2:21
















          The xmount manual states that only EWF and raw disk images can be used.
          – ændrük
          Sep 21 '10 at 2:21




          The xmount manual states that only EWF and raw disk images can be used.
          – ændrük
          Sep 21 '10 at 2:21











          -2














          you can directly mount as a normal mount like this



          mount /dev/sdb1 /mount-point


          But if u have n number of device mean you want again mount it to another directory for
          that you can follow this one:



          Mounting a partition from raw image is pretty simple:



          losetup /dev/loop0 image.img
          kpartx -a /dev/loop0
          mount /dev/mapper/loop0p1 /mnt/image





          share|improve this answer



















          • 1




            A qcow2 image is not a raw image, and can't be mounted through either of those approaches.
            – Twirrim
            Mar 15 '18 at 23:03
















          -2














          you can directly mount as a normal mount like this



          mount /dev/sdb1 /mount-point


          But if u have n number of device mean you want again mount it to another directory for
          that you can follow this one:



          Mounting a partition from raw image is pretty simple:



          losetup /dev/loop0 image.img
          kpartx -a /dev/loop0
          mount /dev/mapper/loop0p1 /mnt/image





          share|improve this answer



















          • 1




            A qcow2 image is not a raw image, and can't be mounted through either of those approaches.
            – Twirrim
            Mar 15 '18 at 23:03














          -2












          -2








          -2






          you can directly mount as a normal mount like this



          mount /dev/sdb1 /mount-point


          But if u have n number of device mean you want again mount it to another directory for
          that you can follow this one:



          Mounting a partition from raw image is pretty simple:



          losetup /dev/loop0 image.img
          kpartx -a /dev/loop0
          mount /dev/mapper/loop0p1 /mnt/image





          share|improve this answer














          you can directly mount as a normal mount like this



          mount /dev/sdb1 /mount-point


          But if u have n number of device mean you want again mount it to another directory for
          that you can follow this one:



          Mounting a partition from raw image is pretty simple:



          losetup /dev/loop0 image.img
          kpartx -a /dev/loop0
          mount /dev/mapper/loop0p1 /mnt/image






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 28 '14 at 5:52

























          answered Feb 28 '14 at 4:50









          PremkumarPremkumar

          310211




          310211








          • 1




            A qcow2 image is not a raw image, and can't be mounted through either of those approaches.
            – Twirrim
            Mar 15 '18 at 23:03














          • 1




            A qcow2 image is not a raw image, and can't be mounted through either of those approaches.
            – Twirrim
            Mar 15 '18 at 23:03








          1




          1




          A qcow2 image is not a raw image, and can't be mounted through either of those approaches.
          – Twirrim
          Mar 15 '18 at 23:03




          A qcow2 image is not a raw image, and can't be mounted through either of those approaches.
          – Twirrim
          Mar 15 '18 at 23:03


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f4396%2fhow-do-i-mount-a-qcow2-disk-image%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How did Captain America manage to do this?

          迪纳利

          南乌拉尔铁路局