如何挂载一个xen的.img
# parted 415-1348.img GNU Parted 1.8.1使用 /myData/xen/images/415-1348.imgWelcome to GNU Parted! Type 'help' to view a list of commands.(parted) U Unit?? b (parted) p Model:(file)Disk /myData/xen/images/415-1348.img: 5242879999BSector size (logical/physical): 512B/512BPartition Table: msdosNumberStart End Size Type File system标志1 32256B 106928639B 106896384B 主分区ext3 启动2 106928640B5239503359B5132574720B主分区 lvm (parted) q # dd if=415-1348.img of=415.img bs=512 skip=63 count=208782208782+0 records in208782+0 records out106896384 bytes (107 MB) copied, 1.83107 seconds, 58.4 MB/s输出文件是415.img,看下里面内容吧:
# mount 415.img /mnt -o loop# cd /mnt# lsconfig-2.6.18-194.el5grubinitrd-2.6.18-194.el5.imglost+foundmemtest86+-1.65messagesymvers-2.6.18-194.el5.gzSystem.map-2.6.18-194.el5vmlinuz-2.6.18-194.el5
--------------------------------------------
网上别人做法是:
1. First you need to find out the partitions and the startsector of partitions:
# file rheltest.imgrheltest.img: x86 boot sector, GRand Unified Bootloader (0.94); partition 1: ID=0x83, active, starthead 1, startsector 63, 208782 sectors; partition 2: ID=0x8e, starthead 0, startsector 208845, 3871665 sectors, code offset 0x48
There are 3 partitions inside the image file. The startsector of each partition is also listed. Boot partition will have start sector 63.
2. Now you need to get the sector size:
fdisk -lu rheltest.img
Disk rheltest.img: 0 MB, 0 bytes 255 heads, 63 sectors/track, 0 cylinders, total 0 sectors Units = sectors of 1 * 512 = 512 bytes Device Boot Start End Blocks IdSystem rheltest.img1 * 63 208844 104391 83Linux rheltest.img2 208845 4080509 1935832+8eLinux LVM
The above shows the sector byte size is 512 byte.
3. To calculating the offset: offset = start_sector x sector_byte_size.
The startsector is 63 for the first partition, therefore the first partition offset is: 63x512=32256
4. Finally, to mount the xen image, use:
mount -o loop,offset=32256test.img /foldername
版权声明:本文为博主原创文章,未经博主允许不得转载。
页:
[1]