The big advantage of a dedicated server is the disk space it offers. In the case of cloud/virtual, we rarely need to think about how to distribute the space to SSD, traditional hard disk and NVMe. Commonly, on a dedicated server with multiple hard disks, you’ll get the server configured with various directories mapped to various hard disks with limited space. This is because the web host does not know your purpose for using the server. For a web server or database server, usually we need a faster working larger /var/
directory, whereas our backup directory can be slow. We can configure the directories to different FTP accounts.
Required Commands to Increase Logical Volume
We can check the present sizes and space used by simply running df -h
command:
1 | df -h |
Example output:
---
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Filesystem Size Used Avail Use% Mounted on udev 7.8G 0 7.8G 0% /dev tmpfs 1.6G 1.3M 1.6G 1% /run /dev/md1 3.9G 400M 3.6G 11% / /dev/ssd/usr 15G 3.3G 11G 24% /usr tmpfs 7.8G 0 7.8G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup /dev/mapper/ssd-home 4.8G 40K 4.6G 1% /home /dev/mapper/ssd-var 54G 33G 19G 64% /var /dev/loop0 117M 117M 0 100% /snap/core/14946 /dev/loop1 73M 73M 0 100% /snap/core22/607 /dev/loop2 55M 55M 0 100% /snap/lxd/12631 /dev/loop4 73M 73M 0 100% /snap/core22/583 /dev/loop3 163M 163M 0 100% /snap/lxd/24643 /dev/mapper/hdd-data 3.9G 24K 3.6G 1% /data tmpfs 1.6G 0 1.6G 0% /run/user/0 |
However, the above command does not give a clear-cut idea about logical volumes and logical volumes. Hence, we will run:
1 | vgdisplay -v |
Example output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | --- Volume group --- VG Name hdd System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size 931.51 GiB PE Size 4.00 MiB Total PE 238467 Alloc PE / Size 1024 / 4.00 GiB Free PE / Size 237443 / 927.51 GiB VG UUID LhWox9-igoc-2c7v-DxDH-QUoP-t0PA-STcsoL --- Logical volume --- LV Path /dev/hdd/data LV Name data VG Name hdd LV UUID iN3zRj-HEz7-UcNk-BBvG-WCnM-1xLP-y8XMbK LV Write Access read/write LV Creation host, time , LV Status available # open 1 LV Size 4.00 GiB Current LE 1024 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:3 --- Physical volumes --- ... ## output truncated |
Take that, we want to increase the size of the /var
directory by 10GB. /var
, in this case, is a LOGICALVOLUME
, belonging to ssd
VOLUMEGROUP
. You need the correct path in this format:
1 | /dev/VOLUMEGROUP/LOGICALVOLUME |
In our example, it is:
1 | /dev/ssd/var |
This is the command to increase the partition size by 10GB:
1 | lvextend -L +10G /dev/VOLUMEGROUP/LOGICALVOLUME |
In our case, it will be:
1 | lvextend -L +10G /dev/ssd/var |
After the correct execution of the command, After entering the command, the following message will be displayed:
1 2 | Extending logical volume var to 64.00 GB Logical volume var successfully resized |
Next, we need to know the file system of the volume. In order to use the increased space, we must enlarge the file system. Running a command such as blkid
will give you an idea of whether the partition’s filesystem is ext3, ext4 or something else. Different file systems will need different commands. For ext2, ext3, ext4, we will run:
1 | resize2fs /dev/ssd/var |
Example commands for other file systems:
1 2 3 4 | # ReiserFS resize_reiserfs -f /dev/ssd/var # XFS xfs_growfs /var |
We can check the present size:
1 | df -h /var/ |
This will finish our work.