From time to time a disk partition becomes full and it becomes desirable to grow the partition. Since I often don't remember how to do this, I wrote this short description to keep track of how to do it.
Extending the LVM partition
The first step is to extend the size of the LVM partition. This is done easily by using the lvextend (8) command. You just need to specify the amount and the LVM partition. In my case, the vg02-ext volume was using 60G and the +40G command will grow its size to 100G. Note that you can run this command while your file system is mounted (if you grow the size of your LVM partition).
Preparing the ext4 filesystem for resize
Before resizing the ext4 filesystem, you must make sure it is not mounted:
The file system must be clean and you should run the e2fsck (8) command to check it:
Resizing the ext4 filesystem
The last step is to resize the ext4 file system by using the resize2fs (8) command. The command can enlarge or shrink an unmounted file system of type ext2, ext3 or ext4. The command only needs the block device path to operate.
After the resize, we can re-mount the ext4 partition:
Add a comment
To add a comment, you must be connected. Login2 comments
- Edit
- Publish
- Spam
- Waiting
- Delete
I agree that a graphical tool is easier. You're right that I'm using Ubuntu but none of the 12 virtual machines I'm using have a GUI installed. Command line is also a lot easier to use for me when you have to run them on several machines...- Edit
- Publish
- Spam
- Waiting
- Delete
Much simpler: since you are using sudo at every step I deduce you are using a derivative of Ubuntu. Since you are using supposedly user-friendly distribution just use the Volume manager or whatever is called there (I assume Ubuntu has one, Redhat/Suse/Mandriva have): it will resize both the volume and the filesystem in one _graphical_ operation: it is far easier and you are far less likely to mess up your filesystem and lose data than by doing it by hand. You should only do it by hand when you have no alternative like when you are forced to use putty from Windows since you cann't use graphical commands from it.