Herewith my little post about lvm. It is very long time ago, and it is not easily to remembered. So i’ll try to keep it safe 😉
First, i’ll try to describe a little concept about lvm like these:
1. Physical Volume, It’s like you have a plot of land (sebuah kaveling tanah), /dev/sda is an example if you’re using SCSI or /dev/hda for IDE. So if we have two sda drive, we have two PV.
2. Volume Group, It’s consist of many ‘house‘ or physical volume that can be increase or decrease.
3. Logical Volume, It’s called by ‘house‘ that you have build on physical volume.
I choose my centos 6 with all partitions here: I have been always remembered myself to create /boot as a primary, / as a logical, swap is twice of your ram, then do not use ext4 format if your distro not applicable with it.
1. Merge two partitions
In this case, i’m using six partitions: then, we make a physical volume for both partitions. Scan or reading all physical volume for LVM configuration, then we create Volume Group with names ‘data’ for both partitions. Let we check that Volume Group was properly configure. Then we create and we check the Logical Volume with total allocation for ‘Total PE’. It will be produced an output in path /dev/data/lvdata Now we format them with ext4 format. Finished, it can be used by mounting into specific folder.
2. Extends the partition
So, now we will be able to extend the /data with another partition into physical volume from volume group by using /data3 also known as /dev/sda9. We unmount, create physical volume then check it.
[root@centos ~]# umount /dev/sda9
[root@centos ~]# pvcreate /dev/sda9 After all, we must register that PV into VG with names ‘data’ with these params. As we can see, VG size has been increased by total from 1.95 to 2.92 GiB so we have to increased LV capacity by unmount that first, re-mount it, than extend with proper ‘Total PE’ that you want. But, as we can see.. size didn’t increased yet. So we have to resize that partition (/dev/data/lvdata). Voila !!, we use all of capacity of our disks. Honestly, we can use optional number allocation at params resize2fs /dev/data/lvdata <how_much_size>
[root@centos ~]# resize2fs /dev/data/lvdata 300M
PS : Sometimes, we have a trouble since the UUID or BlockID on our devices has been changed during the LVM activity. It makes our system CRASHED!! 😦 . So what do we do ??. Read here.
1. Login into safe mode on your system.
2. Just type ‘blkid’ (without quote).
3. Check and see the conditions /etc/fstab with ls params or cat
4. Mount and remount slash root /
5. Change permission for /etc/fstab
6. Then edit (In future, you can mount it manually by registered the mount params in /etc/rc.local) Thanks