Wednesday, June 1, 2016

16.04 - How can I extend a hard disk in Ubuntu logical volume


When I installed Ubuntu 16.04 I selected logical volume management.
I created a virtual machine with 40GB Hard disk.


The I cloned that to a new machine with Hard disk 100. but when I check df -h it still shows 40GB.


Is there any way to increase it?



Suppose there is one LVM partition (except from /boot and maybe EFI), depending on the configuration of your virtual disk. As you choose LVM, you may proceed as follows:


Start gparted in the virtual machine, select the system disk, and create a new partition in the free space with type 'LVM'. You could also do this from the commandline with fdiskor gdisk, ifyou are used to. Remember the name of the newly created partition. For now say it's /dev/sda4.


Next, from commandline execute:


sudo pvcreate /dev/sda4  # to make the partition available for LVM

Now find out the name of your LVM volume group:


sudo vgdisplay

Remember the name of the volume group (say it is vg0). Then execute


sudo vgextend vg0 /dev/sda4

Again, find out the name of your logical volume


sudo lvdisplay

Say the volume's name is vg0-root. Then


sudo lvresize -r -l 100%VG vg0-root

should increase the logical volume vg0-rootto the possible maximum (option -l 100%VG) and resize the filesystem as well (option -r). The online resize of the (mounted) filesystem depends on your kernel; current kernels with ext2/3/4 filesystem support expansion of mounted filesystems.


An other solution would be to extend the partition itself with gparted, then use pvresize (see here, but for that you would have to boot Live Ubuntu from a CD or ISO, as you cannot increase a mounted partition through gparted.


If you could post some more information to your question (output of df, fdisk -l, pvdisplay, vgdisplay and lvdisplay), I could give you additional hints and correct my answer to fit your configuration.


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...