Server gets larger system drive, and the root LVM extended.

Well, as you all saw in my post on 28 Jan, the root partition only had 29G free, so I felt that an expansion was in order.  The original IDE drive was 200 GB, so only 50 GB was allocated to the root partition.  I ‘cloned’ the existing drive to a new 250GB IDE drive using clonezilla, whichScreenshot-1 was exceedingly easy.  Now, to expand the root partition.  This is blivet-gui, which is supposed to be the new partition management tool, not quite out of beta yet.  However, it refuses to do anything to a mounted partition, so it looked like command line tools were going to have to do.  The commands needed will be:  fdisk, lvs, pvcreate, vgs, vgextend, lvextend, mkfs.ext4, and resize2fs.  You can see by the screen shot, that the new drive has been installed with 46.5 GB of free ‘unallocated’ space.  It is this space that I want to use.  😉  The first step is to use the df -h and lvs commands to collect some information that you will need.  Next, break out our old friend fdisk in order to partition and prepare the free space.  #fdisk  /dev/sda in my case.  Then, create another primary partition (3 of 4 allowable).  Screenshot-4After, that is done, change the partition type from Linux to LVM (8e).   Then, we have to create an ext4 filesystem by doing: #mkfs.ext4 /dev/sda3.  Now, all we need to do is to extend the volume group and capture the free space into the logical volume for root.  😉  First, initialize the partition as a physical volume by:  #pvcreate /dev/sda3.  Now, check the volume groups using the command #vgs.  Now, we can extend it.  The command I used was  #vgextend vg_cap /dev/sda3.  Just a couple more commands…. We are almost there!  Next, we extend the logical volume (lv_root) with all the free space of the volume group (vg_cap).  #lvextend -l +100%FREE /dev/vg_cap/lv_root.  Now, to resize the filesystem:  #resize2fs /dev/vg_cap/lv_root.  Finally, verify everything is fine using df-h, lvs, and vgs.  As you can see, lv_root is now 95GB, with 73GB free.  Screenshot-5 Everything is fine, with the only casualty being that blivet-gui doesn’t seem to run any longer, but that’s no big problem since it didn’t really give me any advantage on a mounted filesystem.  Moral of the story:  The TRUE strength of Linux resides in the CLI (Command Line Interface), shell, terminal, or whatever you choose to call it.  Always has and always will.  As a matter of fact, I accomplished all this over SSH, using VNC just for screenshots.  😉

 

Leave a Reply