How to mount a QCOW2 drive

2023-06-25 11:10:03

[开发运维 | Dev Ops] ,

qcow2 file is a common disk file for virtual machines. We don't have to run the VM to gain access to the qcow file system.
It can be mounted directly with a little tweak to the host machine.

We first need to locate the libvirt image folder. It is usually located at /var/lib/libvirt/images
And enabled mod nbd

sudo modprobe nbd max_part=8
sudo qemu-nbd --connect=/dev/nbd0 /var/lib/libvirt/images/ayaka.qcow2

We create perform a disk check on the block device

sudo fdisk /dev/nbd0 -l
# list block devices
lsblk

And then mount the disk

sudo mkdir /mnt/ayaka
mount /dev/nbd0p2 /mnt/ayaka

After you are done, we need to unmount and disconnect the disk

sudo umount /mnt/ayaka
sudo qemu-nbd -d /dev/nbd0
这篇博文发表在 开发运维 | Dev Ops 目录下,标签为 ,
如需引用,请使用链接:https://note.mc256.dev/?p=2112

This article published in 开发运维 | Dev Ops with tags , .
Cite this page using this link:https://note.mc256.dev/?p=2112

您的邮箱地址不会被公开,评论使用Gravatar头像。
Your email address will not be published. This blog is using Gravatar.

正在提交评论... Submitting ...
正在为您准备评论控件 Loading Comment Plugin
Copyright © 2013-2024 mc256. All Rights Reserved.
Powered by WordPress on top of a dual-stack k3s Cluster using JuiceFS.
Wordpress Theme Designed By mc256.
Encrypted By Let's Encrypt.  Hosted On Linode + OVH + AWS.
DNS Provided By Hostker.
Status Page by CloudFlare Worker.