Here is a short summary of LVM configuration and setup.
Check to make sure you have LVM2:
vgscan --version
If vgscan complains about missing driver:
modprobe dm_mod
Create physical volumes:
pvcreate /dev/sda1
pvcreate /dev/sda2
Add the physical volumes to a volume group:
vgcreate VolGroup01 /dev/sda1 /dev/sdb1
To create logical volumes out of the volume group:
lvcreate -L <length> -n LogVol01 VolGroup01
ex: lvcreate -L 500M VolGroup01 -n LogVol01
ex: lvcreate -L 20G VolGroup01 -n LogVol01
Create a filesystem
mkfs -t ext3 /dev/VolGroup01/LogVol01
Mount the logical volume
mount /dev/VolGroup01/LogVol01 /mnt/debian
Extending Logical Volume
Unmount the Logical Volume
umount /dev/VolGroup01/LogVol01
If there is free space in the volume group:
lvextend -L +1G /dev/VolGroup01/LogVol01
If the volume group is full then add a disk/partition to it:
vgextend VolGroup01 /dev/sdc1
and then extend the logical volume:
lvextend -L +1G /dev/VolGroup01/LogVol01
Finally, extend the filesystem (any of the below 3 methods)
extendfs -F ext3 /dev/VolGroup01/LogVol01
resize2fs /dev/VolGroup01/LogVol01
resize2fs /dev/VolGroup01/LogVol01 500M
Mount the logical volume
mount /dev/VolGroup01/LogVol01 /mnt/debian
Showing posts with label lvm. Show all posts
Showing posts with label lvm. Show all posts
Sunday, January 2, 2011
Monday, December 20, 2010
Adventures with Logical Volume Manager
While trying to create a separate partition for virtual machines, I realized that I did not change the default CentOS partition layout so it was using LVM. I was a little confused whether to simply just mount the /dev/sdb or work with LVM, so I logged on Freenode and someone told me I need to make it part of the volume group. (I later realized I could've [obviously] just mounted it.) Took me couple hours to read about and understand how LVM works.
I followed these guides, they're very similar:
TLDP LVM HOWTO
CentOS LVM Administration Guide
The guides are a little vague for a newcomer to LVM to I had a hard time, and I got stuck towards the end with how to mount the new space that I had made part of the volume group. I did not want to merge this space into / (root file system) where everything else is, and keep the /vm in a separate partition.
The virtual HDD I had added was now part of the volume group, and I could see it as /dev/VolGroup00/virtmacs (that's the name I gave it). Therefore, for simplicity's sake, I just did mkfs -t ext3 /dev/VolGroup00/virtmacs, and then added it to /etc/fstab and mounted it and took a sigh of relief.
For people who're adding a new hard drive and get confused by Logical Volume Manager, and don't want to deal with it for whatever reason (maybe you're just testing something and don't want to expand storage etc.), just mount as usual. You don't have to go through any special guides.
I followed these guides, they're very similar:
TLDP LVM HOWTO
CentOS LVM Administration Guide
The guides are a little vague for a newcomer to LVM to I had a hard time, and I got stuck towards the end with how to mount the new space that I had made part of the volume group. I did not want to merge this space into / (root file system) where everything else is, and keep the /vm in a separate partition.
The virtual HDD I had added was now part of the volume group, and I could see it as /dev/VolGroup00/virtmacs (that's the name I gave it). Therefore, for simplicity's sake, I just did mkfs -t ext3 /dev/VolGroup00/virtmacs, and then added it to /etc/fstab and mounted it and took a sigh of relief.
For people who're adding a new hard drive and get confused by Logical Volume Manager, and don't want to deal with it for whatever reason (maybe you're just testing something and don't want to expand storage etc.), just mount as usual. You don't have to go through any special guides.
Subscribe to:
Posts (Atom)