Because root volume ( / ) on my Linux is getting full, I decided to add more disk space to it. As my root volume is configured to be LVM volume, it can be easily expanded by adding a new disk into its volume group.
I added a new physical disk to VMware virtual machine on which my Linux is running. To avoid system reboot in order to add SCSI device I had to force SCSI bus rescan using the command:
$ echo "- - -" > /sys/class/scsi_host/host0/scan
After rescanning SCSI devices I was able to see my new disk as /dev/sdb in output of fdisk command.
$ fdisk -l
Newly added disk looks fine, however, its not partitioned yet. That's why we'll have to use fdisk to create a new partition on this disk.
$ fdisk /dev/sdb
This command will run an interactive console program, that will allow you to create the partition.
Once you've created a new partition, it should be visible in the output of fdisk -l command.
$ fdisk -l /dev/sdb
As you can see, your new partition is visible in the system as /dev/sdb1.
Once you have created a partition on your newly added disk, you are ready to step into LVM setup. First of all, you will need to initialize partition for use with LVM using following command:
$ pvcreate /dev/sdb1
After the volume is initialized for use with LVM, you can add the volume into the volume group. To do so, you will need to know the volume group name. It can be found in output of this command:
$ vgdisplay
In my case, volume group name is pc54-vg. You will use this volume group name as part of next command, that will add your new disk to this volume group:
$ vgextend pc54-vg /dev/sdb1
Now you can see volume group details using command:
$ vgs
My volume group now consists of 2 physical volumes and its total size is 30GB.
Now you can move forward and extend the logical volume. You will need to know the name of the logical volumes in your system. You can find logical volume names using command:
$ lvs
For logical volume extension, you will have to know both, volume group and logical volume name. You will also need to specify a new desired size of your logical volume in lvextend command.
$ lvextend -L 25g /dev/pc54-vg/root
You have just extended your logical volume size. However, it's not enough. You will have to resize the filesystem as well. It can be done using the following command:
$ resize2fs /dev/pc54-vg/root
You are done with volume extension. Current disk space usage and file systems configuration can be displayed using the df command:
$ df
great post, it can be better with some screenshots!,
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit