1. 要搞清楚文件是 是由整个分区来的,还是整个硬盘来的
也就是说,是 dd if=/dev/sda1 还是 dd if=/dev/sda
[root@oraclevmserver43 test_pvm_centos5.4_route]# file System.img
System.img: x86 boot sector; partition 1: ID=0x83, active, starthead 1, startsector 63, 208782 sectors; partition 2: ID=0x8e, starthead 0, startsector 208845, 16563015 sectors, code offset 0x48
[root@oraclevmserver43 test_pvm_centos5.4_route]# fdisk -l -u System.img
last_lba(): I don't know how to handle files with mode 81a4
You must set cylinders.
You can do this from the extra functions menu.
Disk System.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 Id System
System.img1 * 63 208844 104391 83 Linux
System.img2 208845 16771859 8281507+ 8e Linux LVM
Partition 2 has different physical/logical endings:
phys=(1023, 254, 63) logical=(1043, 254, 63)
2. 计算出 offset = 63*512
3. mount 非 lvm分区 mount -o loop,offset=32256 System.img /mnt/sda1
4. mount lvm 分区:
losetup -o 16515072 -f System.img
5. 激活它:
vgchange -a y
2 logical volume(s) in volume group "VolGroup00" now active
6. 查看;
ls /dev/mapper/
7. 如何反激活?