通过loop方式挂载raw格式镜像

来源:互联网 发布:天知地知你知我知 编辑:程序博客网 时间:2024/06/05 11:47

虚拟机的镜像可以直接通过loop的方式来进行挂载,这种方式你必须先计算出镜像中每个分区的偏移量(fdisk -lu可查看),然后通过loop的方式的挂载,加上偏移量


详细命令如下

[root@centos images]# cd /var/lib/libvirt/images/[root@centos images]# fdisk -lu ubuntu.raw You must set cylinders.You can do this from the extra functions menu.Disk ubuntu.raw: 0 MB, 0 bytes255 heads, 63 sectors/track, 0 cylinders, total 0 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000ccae5     Device Boot      Start         End      Blocks   Id  Systemubuntu.raw1   *        2048    38862847    19430400   83  LinuxPartition 1 has different physical/logical endings:     phys=(1023, 254, 63) logical=(2419, 25, 38)ubuntu.raw2        38864894    40957951     1046529    5  ExtendedPartition 2 has different physical/logical beginnings (non-Linux?):     phys=(1023, 254, 63) logical=(2419, 58, 6)Partition 2 has different physical/logical endings:     phys=(1023, 254, 63) logical=(2549, 131, 14)ubuntu.raw5        38864896    40957951     1046528   82  Linux swap / Solaris[root@centos images]# echo $((2048*512))1048576[root@centos images]# mount -o loop,offset=1048576 ubuntu.raw /image/[root@centos images]# umount /image/

PS:这个方式的镜像必须是Raw格式的。


当然你也可以通过kpartx的方式进行挂载,详见 通过kpartx方式挂载raw格式镜像




                                             
0 0
原创粉丝点击