![]() |
|
quickie on LVM - Printable Version +- Linux-Noob Forums (https://www.linux-noob.com/forums) +-- Forum: Linux Noob (https://www.linux-noob.com/forums/forum-3.html) +--- Forum: Tips and Tricks (https://www.linux-noob.com/forums/forum-59.html) +---- Forum: Filesystem Management (https://www.linux-noob.com/forums/forum-26.html) +---- Thread: quickie on LVM (/thread-2096.html) |
quickie on LVM - hijinks - 2006-03-10 So what are the benefits about running a filesystem with LVM.. well for one say you create a normal non-LVM setup with a 20gig home dir. Now over the next few weeks you download so much porn that its filled.. so your option is get a new drive and either move everything to the new drive or do some symlinking. Well if you created your /home partition under a LVM enviroment, you could just grow /home with the new drive and have that extra 400 gigs to download more porn. IMO that is one of the biggest points to using LVM is it allows you to easily change the size of a partition. With that said you should never make / or /boot LVM.. this just creates evilness.. or so i've read.. So in my example I will have a extra partition I made on my sda drive called sda7 which has no filesystem on it or such Code: [root@localhost ~]# fdisk -l
Disk /dev/sda: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3200 25599577+ 83 Linux
/dev/sda3 3201 5112 15358140 83 Linux
/dev/sda4 5113 9726 37061955 5 Extended
/dev/sda5 5113 5214 819283+ 82 Linux swap
/dev/sda6 5215 5278 514048+ 83 Linux
/dev/sda7 5279 9726 35728528+ 8e Linux LVMI gave it a system type of LVM.. that is only needed for LVM v1.. most modern distros should ship with v2 now anyway. Ok now lets init that partition Code: [root@localhost ~]# pvcreate /dev/sda7
Physical volume "/dev/sda7" successfully createdNow you might get a partition not found error. I ran into this when i just created sda7 using fdisk. The only work around I found out was a reboot. You could also use pvcreate on a whole disk. Like if i had a sdb i could do it on the whole disk. There is no need to do it just on a partition. Now we need to create out volume group. You might think of this as the extended partition which holds all the extended partitions. That might not be explaining it good enough but oh well.. Code: [root@localhost ~]# vgcreate volume_group /dev/sda7
Volume group "volume_group" successfully createdFeel free to change volume_group to whatever identifier you want to use. You will notice how its used in a bit.. just hold on! Ok now lets see if it worked Code: [root@localhost ~]# pvdisplay /dev/sda7
--- Physical volume ---
PV Name /dev/sda7
VG Name volume_group
PV Size 34.07 GB / not usable 0
Allocatable yes
PE Size (KByte) 4096
Total PE 8722
Free PE 8722
Allocated PE 0
PV UUID i9r7Pt-o8Jl-bhSW-LfCN-lVlW-FPZX-ZYgvyMNow you can see my pv name is the partition i used.. My volume group is what i used above. and you can see I have around 34gigs of space you allocate. So lets get down to using that all up now So lets create a logical device for our old lady porn Code: [root@localhost ~]# lvcreate -L3000 -nporn_old_lady volume_group
Logical volume "porn_old_lady" createdNow lets create the filesystem. I shall use ext3 here Code: mkfs.ext3 /dev/volume_group/porn_old_ladyNow we can mount it Code: mount /dev/volume_group/porn_old_lady /dump/Now lets see it in all its glory Code: [root@localhost ~]# df -h | grep dump
2.9G 37M 2.8G 2% /dumpSo you can see our size is 2.9gigs and we have used 37megs and we have aroudn 2.8gigs left. So you downloaded a ton of old lady porn and you want to grow your partition.. ok lets do it! Lets say we want to increase it to 7gigs Code: [root@localhost ~]# lvextend -L7G /dev/volume_group/porn_old_lady
Extending logical volume porn_old_lady to 7.00 GB
Logical volume porn_old_lady successfully resizedNow if you use ext3 you have to resize it.. so you have to umount it and do some magic Code: umount /dump
e2fsck -f /dev/volume_group/porn_old_lady
resize2fs /dev/volume_group/porn_old_lady
mount /dev/volume_group/porn_old_lady /dump/Now lets check out the new size Code: [root@localhost ~]# df -h | grep dump
6.9G 39M 6.6G 1% /dumpYaya.. more space for old lady porn.. that would make randall happy. You can just see the benefits of using this if you are a hosting company or such. Now there is a ext2online patch you can apply to your kernel so you can resize it while its still mounted. I have never tried it. quickie on LVM - anyweb - 2006-03-10 nice informative post as always hijinks by the way, for those that don't know, Fedora Core's default filesystem setup is LVM cheers anyweb quickie on LVM - xDamox - 2006-03-11 LOL! Nice one hijinks. :) quickie on LVM - xDamox - 2006-08-25 I have been recently messing with LVM/Partition etc, instead of using fdisk to partition your hard disk you should use parted as this will create the partitions on the fly and not require a reboot quickie on LVM - anyweb - 2006-08-25 i used parted to create partitions on the fly before, and all was great, until i reboted. then i had to reinstall the entire box i must have made some mistake :( cheers anyweb quickie on LVM - xDamox - 2006-08-25 yea anyweb one mistake with parted and your a f*cked, the reason is once you create a partition thats it created. quickie on LVM - Tyrannus - 2007-07-30 This is a great tutorial. I want to add two very useful commands when using LVM. Code: [root@localhost ~]# vgcfgbackup --help
vgcfgbackup: Backup volume group configuration(s)
vgcfgbackup
[-d|--debug]
[-f|--file filename]
[-h|-?|--help]
[--ignorelockingfailure]
[-P|--partial]
[-v|--verbose]
[--version]
[VolumeGroupName...]Code: [root@localhost ~]# vgcfgrestore --help
vgcfgrestore: Restore volume group configuration
vgcfgrestore
[-d|--debug]
[-f|--file filename]
[-l[l]|--list [--list]]
[-M|--metadatatype 1|2]
[-n|--name VolumeGroupName]
[-h|--help]
[-t|--test]
[-v|--verbose]
[--version]
VolumeGroupNamequickie on LVM - Dungeon-Dave - 2010-04-29 To add a few more points here: 1. reiserFS didn't need to be unmounted to resize it - "resize_reiserfs /dev/volume_gp/lv_name" will grow the filesystem to fit the enlarged logical volume 2. Newer version of EXT3 (and EXT4 now) support online resizing - and resiser is discontinued - so there is no need to unmount. 3. LVM can manipulated virtual partitions (logical volumes) much better than parted - such as migrating partitions between physical volumes whilst still in use. Parted is like a command-based version of "partition magic" but has some drawbacks: I have used it in the past to expand an EXT3 filesystem and it lost the journaling, reducing the filesystem to EXT2. 4. If manipulating a disk in use (eg: creating a partition on the root disk) then the kernel needs a reboot to re-read the tables. Parted attempts to keep them in memory, but there are issues with them being written back to the disk properly. If manipulating a disk currently unused (no filesystems mounted on it) then fdisk can change the partition tables without the kernel requiring a reboot. Between the two, LVM is more complex than parted, but much more powerful (and has higher success rates). I would advise against parted on modern systems. Warning: NEVER USE PARTED TO EXTEND A LOGICAL VOLUME! |