Mount disk image files in lvm format

Source: Internet
Author: User
If it is not in lvm format, it is very convenient to pass the offset parameter to the mount command, for example: [root @ jcwkylxen-images] # fdisk-lucentos_vm1last_lba (): Idontknowhowtohandlefileswithmode81edYoumustsetcylinders.

If the format is not lvm, it is very convenient to pass the offset parameter to the mount command. for example:
[Root @ jcwkylXen-Images] # fdisk-luCentos_ Vm1
Last_lba (): I don't know how to handle files with mode 81ed
You must set cylinders.
You can do this from the extra functions menu.

Disk centos_vm1: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1*512 = 512 bytes

DeviceBoot Start End Blocks Id System
Centos_vm1p1 * 63 208844 104391 83 Linux
Centos_vm1p2 208845 4192964 1992060 8e Linux LVM
We can see that the first disk partition is a Linux partition, starting from 63 sectors and directly mounting:
[Root @ jcwkyl xen-images] # mkdir-p/mnt/disk
[Root @ jcwkyl xen-images] # mount-o loop, offset = $ [63*512] centos_vm1/mnt/disk/
[Root @ jcwkyl xen-images] # ls/mnt/disk/
Config-2.6.18-92.el5xen lost + found System. map-2.6.18-92.el5xen xen-syms-2.6.18-92.el5
Grub message Co., vmlinuz-2.6.18-92.el5xen.
Initrd-2.6.18-92.el5xen.img symvers-2.6.18-92.el5xen.gz xen.gz-2.6.18-92. el5
It is displayed that the linux partition is/boot, and the root file system is in the lvm area of centos_vm1p2. try to mount it by using the following method:

First, find its starting offset. use the-u parameter of fdisk to list disk partitions in units of sectors (sector); otherwise, cylinder is used as the unit:
[Root @ jcwkyl xen-images] # fdisk-lu centos_vm1
Last_lba (): I don't know how to handle files with mode 81ed
You must set cylinders.
You can do this from the extra functions menu.

Disk centos_vm1: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1*512 = 512 bytes

DeviceBoot Start End Blocks Id System
Centos_vm1p1 * 63 208844 104391 83 Linux
Centos_vm1p2 208845 4192964 1992060 8e Linux LVM

From the above, we can see that the lvm partition starts from the 208845 sector, and mount the partition at this address as a loop device:
The-f parameter indicates that the available loop device file is automatically searched, and-o specifies the offset.
[Root @ jcwkyl xen-images] # losetup-f-o $ [208845*512] centos_vm1
[Root @ jcwkyl xen-images] # losetup-
/Dev/loop0: [0, 0806]: 1097730 (centos_vm1), offset 106928640

Scan lvm volumns:
[Root @ jcwkyl xen-images] # lvm pvscan
PV/dev/loop0 VG VolGroup00 lvm2 [1.88 GB/0 free]
Total: 1 [1.88 GB]/in use: 1 [1.88 GB]/in no VG: 0 [0]

Activate lvm volumn:
[Root @ jcwkyl xen-images] # lvm vgchange-ay
2 logical volume (s) in volume group "VolGroup00" nowactive
[Root @ jcwkyl xen-images] # ls/dev/mapper/
Control VolGroup00-LogVol00 VolGroup00-LogVol01
[Root @ jcwkyl xen-images] # lvmLvs
Lv vg Attr LSize Origin Snap % Move Log Copy % Convert
LogVol00 VolGroup00-wi-a-1.50G
LogVol01 VolGroup00-wi-a-384.00M

Usage:
[Root @ maid] # mount/dev/mapper/VolGroup00-LogVol00/mnt/usb
[Root @ jcwkyl xen-images] # ls/mnt/usb
Bin dev home lost + found misc opt proc sbin srv tmp var
Boot etc lib media mnt poweroff root selinux sys usr

Finally, after the operation, umount the device and then set the lvm volumn to inactive:
[Root @ jcwkyl xen-images] # umount/mnt/usb
[Root @ jcwkyl xen-images] # lvm vgchange-
0 logical volume (s) in volume group "VolGroup00" nowactive
[Root @ jcwkyl xen-images] # losetup-
/Dev/loop0: [0, 0806]: 1097730 (centos_vm1), offset 106928640
[Root @ jcwkyl xen-images] # losetup-d/dev/loop0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.