Use rest of free space on LVM partition with new Logical Volume
I recently had to fix a few servers using 2TB hard drives. The client wanted 100GB used for the OS/Software while the rest was to be used for data storage. This was on an LVM for /dev/sda and the LVM was "already using the entire drive" (could not use fdisk to create additional partitions as the entire 2TB drive was on LVM).
For things like this, I hate LVM. to use the rest of the space on the LVM to fill the void and mount the "new partition". In the examples, $VGNAME should be replaced with the name of the Volume group that your LVM is using. The following commands were used to get the job done:
To create a new "logical volume" on top of the LVM that took the rest of the free space:
# lvcreate -l 100%FREE -n data1 $VGNAME
To create an EXT3 file system for the new LVM "data1" partition:
# mkfs.ext3 /dev/$VGNAME/data1
Create mount point and have this partition mounted to it:
# mkdir /data1 # mount /dev/$VGNAME/data1 /data1
Line to add to /etc/fstab to add this mount point to re-mount once the server boots/reboots:
/dev/$VGNAME/data1 /data1 ext3 defaults 0 0
Just a note to say thanks for the posting. I just used this since I was trying to make a logical volume using ALL the available space on the volume group I just created. Made it easy, and it worked..
Thanks! Glad it helped! I've run into some issues like this before, figure it out, then put up an article so I can refer back to it.
Works like a charm!
Thanks for this - a quick solution for my problem