Pheeew, long title this time...
I've been a VCP for a while now and working with VMware products. Since Linux on VMware is becomming pretty ordinary right now, you can still see that there are some missing features left to implement. Especially VCB is not there yet completely for Linux (it does do the complete Linux vmdk file, but not the files inside the vmdk like it does with Windows filesystems). Since IBM's p-Series Power virtualisation rules more than VMware, you can see that the Unix-part will be more integrated to a VMware w/ Linux sollution due to the hardware- and license costs. Also the Virtual Center Server/Client combination is very intuitive to work with, compared to the IBM's HMC/VIO combination.
Here is a little howto to mount a Linux vmdk file within a host (e.g. Linux host or Service console) and mount the vmdk to a directory. With a regular filesystem, this seems to be no problem, BUT if you have equipped the Linux partitions with LVM, you need to do some extra commands to alter, change and view the filesystems under LVM.
#
# mount a Linux vmdk file with LVM partitions on a Linux host:
#
1. Existing Linux vmdk file: RHES4-i386-clean.vmdk, mount as a flat file:
[root@linux-1 RHES4-i386-clean]# vmware-mount -p RHEL4-U2-i386-ES_thin.vmdk
Nr Start Size Type Id Sytem
-- ---------- ---------- ---- -- ------------------------
1 63 208782 BIOS 83 Linux
2 208845 20755980 BIOS 8E Unknown
2. Mount the second partition to a directory using the -f flag:
[root@linux-1 RHES4-i386-clean]# vmware-mount -f RHEL4-U2-i386-ES_thin.vmdk test
[root@linux-1 RHES4-i386-clean]# cd test
[root@linux-1 test]# ls
flat
3. Search for the offset in the sectors:
[root@linux-1 test]# sfdisk -luS ./flat
last_lba(): I don't know how to handle files with mode 81b0
Disk ./flat: cannot get geometry
Disk ./flat: 1305 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
./flat1 * 63 208844 208782 83 Linux
./flat2 208845 20964824 20755980 8e Linux LVM
./flat3 0 - 0 0 Empty
./flat4 0 - 0 0 Empty
Look for the used sectors of /flat1 (=208782) and multiply with 512. That's the offset we are going to use.
[root@linux-1 test]# bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
208782*512
106896384
4. Connect the second partition (Linux LVM) to a loopdevice, using the offset:
[root@linux-1 test]# losetup -o 106928640 /dev/loop0 flat
5. Look for the volumegroup inside the newly created /dev/loop0
[root@linux-1 test]# vgscan
Reading all physical volumes. This may take a while...
WARNING: Duplicate VG name rootvg: Existing
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE (created here) takes precedence over
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36
Found volume group "rootvg" using metadata type lvm2
Found volume group "rootvg" using metadata type lvm2
[root@linux-1 test]# pvdisplay
WARNING: Duplicate VG name rootvg: Existing
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE (created here) takes precedence over
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36
--- Physical volume ---
PV Name /dev/sda2
VG Name rootvg
PV Size 74.43 GB / not usable 22.62 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 2381
Free PE 445
Allocated PE 1936
PV UUID ZHjhkC-No2D-M2jI-erME-ypxC-hw8R-Op8suu
--- Physical volume ---
PV Name /dev/loop0
VG Name rootvg
PV Size 9.90 GB / not usable 26.02 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 316
Free PE 60
Allocated PE 256
PV UUID MMZAx8-EU7Q-z36V-SJ8L-vh7O-n9y2-3rz6mp
I'm using the rootvg as default naming scheme for all my LVM system partitions. This has been detected and I have to rename my LVM of the vmdk to e.g. rootvgtemp instead of rootvg.
[root@linux-1 test]# pvscan
WARNING: Duplicate VG name rootvg: Existing
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE (created here) takes precedence over
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36
PV /dev/sda2 VG rootvg lvm2 [74.41 GB / 13.91 GB free]
PV /dev/loop0 VG rootvg lvm2 [9.88 GB / 1.88 GB free]
Total: 2 [84.28 GB] / in use: 2 [84.28 GB] / in no VG: 0 [0 ]
6. Change, if necessary the rootvg name (check the warnings). Make sure you use the correct UUID and remember that number when changing it back to the correct name (rootvgtemp -> rootvg):
Check that with vgdisplay:
[root@linux-1 test]# vgrename jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE rootvgtemp
[root@linux-1 test]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "rootvg" using metadata type lvm2
Found exported volume group "rootvgtemp" using metadata type lvm2
8.
[root@linux-1 test]# lvscan
ACTIVE '/dev/rootvg/rootlv' [1.00 GB] inherit
ACTIVE '/dev/rootvg/homelv' [18.00 GB] inherit
ACTIVE '/dev/rootvg/optlv' [3.00 GB] inherit
ACTIVE '/dev/rootvg/tmplv' [512.00 MB] inherit
ACTIVE '/dev/rootvg/usrlv' [5.00 GB] inherit
ACTIVE '/dev/rootvg/varlv' [1.00 GB] inherit
ACTIVE '/dev/rootvg/swaplv' [2.00 GB] inherit
ACTIVE '/dev/rootvg/datalv' [30.00 GB] inherit
inactive '/dev/rootvgtemp/rootlv' [512.00 MB] inherit
inactive '/dev/rootvgtemp/homelv' [1.00 GB] inherit
inactive '/dev/rootvgtemp/optlv' [512.00 MB] inherit
inactive '/dev/rootvgtemp/tmplv' [512.00 MB] inherit
inactive '/dev/rootvgtemp/usrlv' [4.00 GB] inherit
inactive '/dev/rootvgtemp/varlv' [1.00 GB] inherit
inactive '/dev/rootvgtemp/swaplv' [512.00 MB] inherit
9. Activate a LV and mount the directory:
[root@linux-1 test]# lvchange -ay /dev/rootvgtemp/rootlv
10. Mount:
[root@linux-1 test]# mkdir /home/user/vmware/RHES4-i386-clean/dir
[root@linux-1 test]# mount /dev/rootvgtemp/rootlv /home/user/vmware/RHES4-i386-clean/dir
11. Now you can change to that directory and do your things.
To disable the directory/filesystems and restart the virtual with this vmdk.file:
Disconnect:
[root@linux-1 test]# cd ..
[root@linux-1 RHES4-i386-clean]# umount /dev/rootvgtemp/rootlv
[root@linux-1 RHES4-i386-clean]# lvchange -an /dev/rootvgtemp/rootlv
[root@linux-1 RHES4-i386-clean]# vgchange -an rootvgtemp
Change the VG-name back to the original. You must do this when you had to change the vgname due to duplicate names. After that, disconnect the disk:
[root@linux-1 RHES4-i386-clean]# vgchange -yn rootvgtemp
copieer de vgcfg van de laatst werkende, b.v.
Look for the latest backup of the LVM definitions with "lvcfgrestore -l" or look inside the /etc/lvm/archive directory. Copy the file and change the rootvgtemp name inside the file to the correct one, in our example it's rootvg :
[root@linux-1 RHES4-i386-clean]# cp /etc/lvm/archive/rootvgtemp_00009.vg .
Change the rootvgtemp to rootvg inside the file:
Restore the LVM definitions:
[root@linux-1 RHES4-i386-clean]# vgcfgrestore -f ./rootvgtemp_00000.vg
rootvg
WARNING: Duplicate VG name rootvg: Existing
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36 (created here) takes precedence over
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE
Restored volume group rootvg
[root@linux-1 RHES4-i386-clean]# vgscan
Reading all physical volumes. This may take a while...
WARNING: Duplicate VG name rootvg: Existing
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE (created here) takes precedence over
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36
Found volume group "rootvg" using metadata type lvm2
Found volume group "rootvg" using metadata type lvm2
[root@linux-1 RHES4-i386-clean]# lvscan
WARNING: Duplicate VG name rootvg: Existing
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE (created here) takes precedence over
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36
Disconnect the loop device:
[root@linux-1 RHES4-i386-clean]# losetup -d /dev/loop0
[root@linux-1 RHES4-i386-clean]# lvscan
WARNING: Duplicate VG name rootvg: Existing
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE (created here) takes precedence over
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36
ACTIVE '/dev/rootvg/rootlv' [512.00 MB] inherit
ACTIVE '/dev/rootvg/homelv' [1.00 GB] inherit
ACTIVE '/dev/rootvg/optlv' [512.00 MB] inherit
ACTIVE '/dev/rootvg/tmplv' [512.00 MB] inherit
ACTIVE '/dev/rootvg/usrlv' [4.00 GB] inherit
ACTIVE '/dev/rootvg/varlv' [1.00 GB] inherit
ACTIVE '/dev/rootvg/swaplv' [512.00 MB] inherit
Remove the loopdevice and the flat file:
[root@linux-1 RHES4-i386-clean]# losetup -d /dev/loop0
[root@linux-1 RHES4-i386-clean]# vmware-mount -X
Cool shit or what???