Mounting a Root Partition in a Logical Volume
Novell Cool Solutions: Tip
By Ren Purcell
|
Digg This -
Slashdot This
Posted: 28 Sep 2007 |
Problem:
You have created a Logical Volume to receive a Xen VM. During the VM installation you created two partitions inside the LV, one swap and one for the root and you want to mount the root partition inside the LV.
So it looks like this:
sda (physical disk)
sda1 ( / Dom0 )
sda2 ( swap Dom0 )
sda3 (partition system id=8e LVM)
VG1
LV1 DomU (virtual hda for the Xen VM)
sda1 ext3 /
sda2 swap
Solution:
You need to know the exact starting point of the partition inside your LV to mount it.Example:
There's a partition table in: /dev/vg1/lv1With this command you can see the partition contained in your LV
-----------------------------------------------------------------------------
fdisk -l -u /dev/vg1/lv1
"Don't forget the "-u" it's important this will show you the size in sector"
Disk /dev/vg1/lv1: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders, total 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/vg1/lv1p1 63 899639 449788+ 82 Linux
swap / Solaris
/dev/vg1/lv1p2 * 899640 8385929 3743145 83 Linux
-----------------------------------------------------------------------------
Now if you want to mount the second partition in your LV type:
mount -o loop,offset=460615680 /dev/vg1/lv1p2 /mnt/vm01
460615680 is equal to 899640 * 512 (512 are the size of each sector and 899640 the starting point of the partition. (You can get these numbers with the fdisk command..)
Special thanks to Jean-Francois Saucier for the tips.
Environment:
- SUSE Linux Enterprise Server
- Xen
- LVM
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

