LVM
From MyWiki
Statement
In a virtual environment, disk drives can be expanded with just a simple line command. These kinds of capabilities renders moot the value that LVM brings to the table. As a result, LVM in virtual servers is a liability, and we can all save ourselves some headaches by purging it from our system.
Use this procedure to get rid of it.
Procedure
- Shut down the VM
- Back up the VM
- Using the VMware Console application, create a new IDE disk at least as large as the current disk. Do not allocate all disk space now. Split into 2GB files. The equivalent command line command is:
vmware-vdiskmanager -c -s 20Gb -a ide -t 1 ideDisk0.vmdk
- Assign the new virtual disk to the VM (and take note of the current assignments for the devices). For example:
The current disk is at IDE 0:0 (corresponding to /dev/sda) The new disk is at IDE 0:1 (corresponding to /dev/sdb)
- Boot the VM from CD using a rescue ISO file
- IMPORTANT!! On the boot menu, add the boot time parameter selinux=0 to disable SELinux
- Mount the file systems read-only
- Your old file systems will be mounted at /mnt/sysimage
- fdisk /dev/sdb (the new disk) and create the following partitions
Device Boot Start End Blocks Id System (primary) /dev/sdb1 * 1 25 (200M) 83 Linux (primary) /dev/sdb2 26 150 (1024M) 82 Linux swap (primary) /dev/sdb3 151 2610 (all) 83 Linux
- Make the ext3 filesystems
mkfs.ext3 -L /boot /dev/sdb1 mkfs.ext3 -L / /dev/sdb3
- Label the swap partition too
mkswap -L swap2 /dev/sdb2
- Verify your labels are correct
e2label /dev/sdb1 e2label /dev/sdb3
- Mount the new file systems
mkdir /tmp/newboot mkdir /tmp/newroot mount -t ext3 /dev/sdb1 /tmp/newboot mount -t ext3 /dev/sdb3 /tmp/newroot
- Copy all files from old disk to new disk
cd /tmp/newboot cp -ax /mnt/sysimage/boot/* . cd /tmp/newroot cp -ax /mnt/sysimage/* .
- Edit your new grub.conf file /tmp/newboot/grub/grub.conf and change the root parameter of the kernel line(s)
kernel /vmlinuz... ro root=LABEL=/
- Edit your new fstab file /tmp/newroot/etc/fstab and update the mount labels
LABEL=/ / ext3 defaults 1 1 LABEL=/boot /boot ext3 defaults 1 2 ... LABEL=swap2 swap swap defaults 0 0
- Shut down the VM
- Reconfigure the disk drives in VMWare Console
- Remove the old disk drive
- Assign the new disk drive to IDE 0:0
- Review the vmx file and cleanup as necessary.
- delete references to ide0:1 (or whatever the old assignment was)
- Boot the VM from CD using a rescue ISO file
- No need to disable selinux this time
- Allow the file systems to be mounted read write
- Your (new & only) file system will be mounted at /mnt/sysimage
- Install the master boot record
grub root (hd0,0) setup (hd0) quit
- Shutdown the VM
- In VMware Console, set the CD-ROM to *not* be connected at startup
- Boot the VM from the hard drive
- Rebuild initrd (to remove the reference to VolGroup00 LogVol00)
sudo su - cd /boot mkdir backup cp initrd-2.6.20-1.2320.fc5.img backup mkinitrd -f initrd-2.6.20-1.2320.fc5.img 2.6.20-1.2320.fc5
- Reboot the VM again, just to watch it come up cleanly so you know everything works
