Online Resizing LVM Partitions Plesk CentOS RedHat – Lee Claxton Sarasota

KVM VPS Hosting AdvertisementKVM VPS Unlimited Bandwidth

KVM VPS Hosting with KVM VPS Unlimited Bandwidth, KVM virtual private server hosting starting at only $30 a month. Cheap KVM Hosting up to 6 Cores @ 2.83Ghz, 12GB Memory, 1TB RAID-10 with Unlimited Bandwidth.

Online Resizing LVM Partitions Plesk CentOS

Online Resizing LVM Partitions Plesk CentOS RedHat while online and not needing to restart your web server. By Lee Claxton Sarasota

Online Resizing LVM Partitions Plesk CentOS

How to do online resizing of LVM partitions in CentOS, CloudLinux and Redhat based linux systems. This machine runs CentOS for Parallels Plesk Panel which runs everything in /root instead of /home so we will have to resize the partitions.

Might have to reboot your web server and make sure you can umount the partition you want to shrink. If you blocked root access and you connect to your web server with a created username using ssh, this will lock the /home directory, as the current user you’re logged in as is locking the partition. so make sure no files or users are currently writing to it. If you disabled root access from SSH edit /etc/ssh/sshd_config and re-enable root ssh login. Just follow these instructions and your machine won’t be down for a minute. but I highly suggest you make full backups, or a clone before attempting. Also restart your server once the resize is complete to verify you can still bootup your server, Do this at none peek hours. Lets begin. 🙂

df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

50G 6.5G 41G 14% /

tmpfs 1.9G 0 1.9G 0% /dev/shm

/dev/sda1 485M 40M 420M 9% /boot

/dev/mapper/VolGroup-lv_home

358G 207M 340G 1% /home

You can see here that I have 358G in VolGroup-lv_home and only 50G in VolGroup-lv_root. since this web server is running Plesk, and Plesk runs everything in /var we will need to increase the size of VolGroup-lv_root.

2. vgdisplay

Notice where you see “Free PE / Size” you will need to freeup the disk size in here, before you provision it to the other partition, make sure you have enough space in /home to remount it, or else you’ll reboot into maintenance mode. Delete any files in your /home partition you don’t need to freeup space to use for /root partition. If you get an error after lvm resizing and cannot boot up your webserver because it’s booting into a read-only filesystem maintenance mode look at bottom of this tutorial for fix.

LVM Resizing /home

3. umount /dev/mapper/VolGroup-lv_home

If you cannot unmount home you might need to restart because something is writing to /home. Probably the user you’re currently logged in as. You can nano /etc/ssh/sshd_config and re-enable root ssh login and login as root to avoid having a user writing to /home.

4. e2fsck -f /dev/mapper/VolGroup-lv_hom

5. resize2fs -p /dev/mapper/VolGroup-lv_home 20G

This took me a while to understand. But you will set the resize2fs limit to what you want to change the partition of VolGroup-lv_home to and use the remainder of the space to fillup root. This honestly took me like 5 tuts to figure out since no one really explained it and the tutorials really didn’t have a deviation in their ranges.

6. lvreduce -L 20G /dev/mapper/VolGroup-lv_home

Now we will write the new size for the home partition, which will be 20G so we can use the other +300 gig in /root.

7. e2fsck -f /dev/mapper/VolGroup-lv_home

Check to make sure everything’s fine.

8. mount /dev/mapper/VolGroup-lv_home /home

9. Now type “vgdisplay

You should now see free space under Free PE / Size. Shows I have 343GB available.

10. lvextend -L +340G /dev/mapper/VolGroup-lv_root

I’ll go ahead and add 340G to root partition

11. resize2fs -p /dev/mapper/VolGroup-lv_root

Confirm writing and now you have your new partition size without even having to restart or to use a bootable CD like GPARTED. Only the newest versions of GPARTED allow LVM resizing, but you will need to restart your server and boot to CD which is a no no in the server world.

Have a great day! 🙂

If everything went smooth you should have successfully resized your partitions.

 

Fix if you cannot boot up your web server after lvm resize

If you get an error saying:

File-based locking initialisation failed.

Fix file based locking initialisation failed by unmounting the /root partition and remounting it using RW read and write. Usually this means you wen’t past the partitions space while resizing, usually from /home partition.

mount -o rw,remount /

For a quick fix you can umount and remount the root partition when your web server boots up in maintenance mode and comment out your home partition in /etc/fstab, but you will need to regrow the partition you were taking the disk space from for a complete fix, usually back to /home until you give /home enough disk space to be able to mount once again, or just leave /home unmounted at all times since its really not needed in Parallels Plesk Panel.

 

nano /etc/fstab

comment out your /home partition, this way it will not be mounted during your web servers bootup process. Don’t have nano? Maybe you’re one of them VI pretty boys, just do a yum install nano 🙂

Once you comment out your /home partition in /etc/fstab you can restart to bypass having to mount the /home partition on every boot, which is not needed in Parallels Plesk Panel.

For a perm fix you’ll need to add some disk space back to your /home partition, not all of it, just enough to be able to mount it.

 lvextend the logical volume and resize2fs the filesystem

Buy Sarasota FL Computer Repair

 Managed Linux Hosting

By Lee Claxton

Lee Claxton Sarasota

Lee Claxton Sarasota is a Sarasota computer repair tech and Sarasota website design to web hosting services Sarasota FL area. Lee Claxton Sarasota has over 15 years of computer repair and web services experience. Sarasota computer repairs mostly take 1 to 2 hours to complete starting at $35 an hour and web hosting services starting at $3.95 a month. HIre Lee Claxton Sarasota today! 941-539-9680

Alpha Computer and Web Services

Computer Services Sarasota

5439 Sawgrass RD, Sarasota FL 34232

941-539-9680

Sarasota PC Services | Shared Web Hosting Plans | Shared Reseller Hosting | Sarasota Website Designs| Computer Repair Sarasota FL

 

Lee Claxton Sarasota

Lee Claxton Sarasota

Lee Claxton Sarasota