
In this article, we will delve into a common issue faced by many Ubuntu Server 18.04 users – running out of space on the default Logical Volume Manager (LVM) partition. We will guide you through the process of extending your LVM partition to make full use of your server’s available space.
To fix the issue of running out of space on the default LVM partition in Ubuntu Server 18.04, you can extend the logical volume using the lvextend
command and then resize the file system using the resize2fs
command. This will allow you to make full use of your server’s available space.
Introduction to LVM
The Logical Volume Manager (LVM) is a device mapper target that provides logical volume management for the Linux kernel. It is a highly flexible and advanced option for disk management which provides a method of allocating space on mass-storage devices that is more flexible than conventional partitioning schemes.
The Problem
By default, the Ubuntu Server 18.04 installer creates a small LVM partition. This is intentional to minimize space waste on physical partition creation, assuming that users will customize and expand the LVM as per their requirements. However, this can lead to an issue where the server runs out of space.
Checking the Current Disk Usage
Before we proceed with the solution, let’s first check the current disk usage. You can do this by running the df -h
command in your terminal. This command will display the amount of disk space used and available on your Linux file systems.
Extending the Logical Volume
To extend the logical volume, we will use the lvextend
command. This command is used to add space to a logical volume. Here’s the command you need to run:
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
In this command, -l +100%FREE
tells lvextend
to extend the logical volume by the amount of free space available in the volume group. /dev/ubuntu-vg/ubuntu-lv
is the path to the logical volume that you want to extend.
Please note, if you didn’t customize the LVM settings during installation, the names for the volume group and logical volume should be ubuntu-vg
and ubuntu-lv
respectively.
Resizing the File System
After extending the logical volume, we need to resize the file system to utilize the new space. We can do this using the resize2fs
command. Here’s how you can do it:
resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs
is a command-line utility that allows you to resize ext2, ext3, or ext4 file systems. It can be used to enlarge or shrink an unmounted file system located on device /dev/ubuntu-vg/ubuntu-lv
.
Verifying the Changes
After the resizing is complete, you can check the available space by running df -h
again. You should now see that the available space has increased.
Conclusion
Running out of space on your Ubuntu Server 18.04 with LVM can be a frustrating issue. However, by following the steps outlined in this article, you can easily extend your logical volume and resize your file system to make full use of your server’s available space.
Remember, it is always a good practice to monitor your server’s disk usage regularly to avoid running out of space. Tools like df
and du
can be very helpful for this purpose.
For more information on extending and reducing LVs in Linux, you can refer to this detailed guide on Tecmint.
We hope this article has been helpful. If you have any questions or run into any issues, feel free to leave a comment below.
LVM stands for Logical Volume Manager. It is a device mapper target that provides logical volume management for the Linux kernel. It allows for more flexible allocation of disk space on mass-storage devices compared to conventional partitioning schemes.
The default LVM partition in Ubuntu Server 18.04 is intentionally created small to minimize space waste on physical partition creation. It is expected that users will customize and expand the LVM as per their requirements. However, if not expanded, it can lead to running out of space on the server.
You can check the current disk usage by running the df -h
command in the terminal. This command will display the amount of disk space used and available on your Linux file systems.
To extend the logical volume, you can use the lvextend
command. The command you need to run is:
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
This command extends the logical volume by the amount of free space available in the volume group.
After extending the logical volume, you can resize the file system using the resize2fs
command. Run the following command:
resize2fs /dev/ubuntu-vg/ubuntu-lv
This command resizes the ext2, ext3, or ext4 file system located on the specified device.
To verify the changes, you can run the df -h
command again. It will display the available space on your server. You should see that the available space has increased.
To monitor your server’s disk usage regularly, you can use tools like df
and du
. The df
command shows the amount of disk space used and available on file systems, while the du
command displays the disk usage of files and directories.
For more detailed information on extending and reducing Logical Volumes (LVs) in Linux, you can refer to the guide on Tecmint. It provides comprehensive explanations and examples for managing LVs.