You are here

LVM

Technical Notes

These notes are my personal online notebook of useful commands and "how-to's". You are welcome to make use of them if you find them helpful. They obviously don't come with any warranty! Click on one of the category tags above for the notes in any category.

Backup LVM-based VM to another computer

#first stop VM
#
lvname=vm_www
lvcreate -L5G -s -n $lvname-snap /dev/VolGroup00/$lvname
#the VM can be re-started now
#turn the snapshop into a file image (optionally gzip it)
#dd if=/dev/VolGroup00/$lvname-snap | bzip2 -9 >/backup/$lvname.dd.bz2
dd if=/dev/VolGroup00/$lvname-snap >/backups/$lvname.img
#remove the snapshot
lvremove -f /dev/VolGroup00/$lvname-snap
#copy to another machine
scp $lvname.img root@jordan:/amf300;
rm -f $lvname.img
#on the other machine, run bzip2 -9 vm_xxxx.img

Topic: 

How to move a virtual machine from one computer to another

#create a snapshot of the LV drive
/usr/sbin/lvcreate -L5G -s -n vm_test_snap /dev/VolGroup00/vm_test
#turn the snapshop into a file image
dd if=/dev/VolGroup00/vm_test_snap | gzip -9 >/backup/vm_test.dd.gz
#remove the snapshot

Topic: 

Zimbra backup using LVM and rsync

Creating a new Xen VM in CentOS 5.1

I would recommend not using LVM within a VM because it makes it harder to back up the files within the VM


/usr/sbin/lvcreate -L 5G -n vm_testvm VolGroup00 #first create a logical volume for the machine
/usr/sbin/lvcreate -L 512M -n vm_testvm_swp VolGroup00 #create the LV swap file
/sbin/mkswap /dev/VolGroup00/vm_testvm_swp

Topic: 

LVM commands

It is confusing that a logical volume can contain either a partitioned drive or a single file-system with no partition table. Doing an fdisk -lu will determine which.

A partition can contain several file-systems, such as boot and a “nested” LVM partition. The link at the bottom gives examples of how to access this.

Create and mount a LV

/usr/sbin/lvcreate -L 20G -n jessica VolGroup00
/sbin/mkfs -j /dev/VolGroup00/jessica -L jessica #format jessica as ext3
mkfs.ext4 -L ext4volname /dev/vg/newvol # or ext4
mount /dev/VolGroup00/jessica /home/jessica/backup
Topic: 

Zimbra VM and LVM re-organization

My default Zimbra VM install uses LVM within its own virtual machine. This makes it harder to get at the data from outside the VM, and so complicates backup. The following steps need to be taken

Topic: 
Subscribe to RSS - LVM