When we use qemu-img to create one image, if we want to copy some files to this image,
we can mount the image file to one directory.
We may think of one command line as the following to mount this image:
#mount -o loop fedora.img /mount/dir
But we always encountered one problem, as the following:
[root@localhost]# mount -o loop fedora.img mountdir
mount: you must specify the filesystem type
What I am doing is as the following:
1. check the system of the image
[root@localhost kvm-test]# fdisk -lu fedora2.img
Disk fedora2.img: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders, total 62914560 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
Disk identifier: 0xa0690800
Device Boot Start End Blocks Id System
fedora2.img1 * 2048 10239 4096 41 PPC PReP Boot
fedora2.img2 10240 1034239 512000 83 Linux
fedora2.img3 1034240 62914559 30940160 8e Linux LVM
2. Now, according to this information, we know can see the block size is 512 bytes.
So we need to calculate the offset of the image.
My image it equals 10240*512
Then with the following command to mount the second partition
#mount -o loop,offset=$((10240*512)) fedora.img /mount/dir
Then you can see the system under /mount/dir
[root@localhost mountdir]# ls
config-3.1.0-0.rc9.git0.2.fc16.kh.ppc64 initramfs-3.1.0-0.rc9.git0.2.fc16.kh.ppc64.img
efika.forth lost+found
etc System.map-3.1.0-0.rc9.git0.2.fc16.kh.ppc64
grub vmlinuz-3.1.0-0.rc9.git0.2.fc16.kh.ppc64
3. When we trying to mount the third parition, it will always complain this error:
[root@ltckvmopal2 kvm-test]# mount -o loop,offset=$((1034240*512)) /dev/loop0 mountdir
mount: unknown filesystem type 'LVM2_member'
Continue to fix this problem...
阅读(1522) | 评论(0) | 转发(0) |