Home Linux 如何加载raw文件 Qemu Kvm Qemu Img
Post
Cancel

Linux 如何加载raw文件 Qemu Kvm Qemu Img

refer to: https://www.aikaiyuan.com/10526.html

一般这样的raw 文件都很大。属于虚拟机的最原始文件。

可以这样查看

 fdisk -lu m-xx_data_xvdb.raw
Disk m-xx_data_xvdb.raw: 500 GiB, 536870912000 bytes, 1048576000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

这样的文件,可以直接加载:

mkdir /mnt/xx

mnt sudo mount -o loop m-xx_data_xvdb.raw /mnt/xx

对于有的文件,需要计算偏移量,再mnt:

Disk m-yy.raw: 200 GiB, 214748364800 bytes, 419430400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x77ba45a4

Device                             Boot Start           End      Sectors  Size   Id  Type
m-yy-raw1                          *    2048      419428351    419426304  200G   83  Linux

从上面可以看到, m-yy-raw1 对应的 start = 2048 ,所以mnt命令是:

sudo mount -o loop,offset=$((2048 * 512 )) m-yy.raw /mnt/yy

This post is licensed under CC BY 4.0 by the author.