1

I followed this post to extend my (LVM) Ubuntu partition. It doesn't work and my disk is still 50GB (while it should be 200GB).

$ sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from 24,50 GiB (6272 extents) to <49,00 GiB (12543 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.

Then

$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv 
resize2fs 1.45.5 (07-Jan-2020) Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on
/; on-line resizing required old_desc_blocks = 4, new_desc_blocks = 7 The filesystem on 
/dev/mapper/ubuntu--vg-ubuntu--lv is now 12844032 (4k) blocks long.

Oddly enough, I don't get the expected output (my disk should be 200GB):

    $ lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0                         2:0    1    4K  0 disk 
loop0                       7:0    0 55,7M  1 loop /snap/core18/2823
loop1                       7:1    0 91,9M  1 loop /snap/lxd/24061
loop2                       7:2    0 91,9M  1 loop /snap/lxd/29619
loop3                       7:3    0 63,7M  1 loop /snap/core20/2434
loop4                       7:4    0 55,4M  1 loop /snap/core18/2846
loop5                       7:5    0   64M  1 loop /snap/core20/2379
loop6                       7:6    0 38,8M  1 loop /snap/snapd/21759
loop7                       7:7    0 44,4M  1 loop /snap/snapd/23545
sda                         8:0    0  200G  0 disk 
├─sda1                      8:1    0    1M  0 part 
├─sda2                      8:2    0    1G  0 part /boot
└─sda3                      8:3    0  199G  0 part 
  └─ubuntu--vg-ubuntu--lv 253:0    0   49G  0 lvm  /
sr0                        11:0    1 1024M  0 rom 

What have I missed? How can I expand my partition properly to have 200GB instead of 50GB total space?

sudo fdisk -l /dev/mapper/ubuntu--vg-ubuntu--lv
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 48,102 GiB, 52609155072 bytes, 102752256 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

1 Answers1

0

If you can hook up a monitor to it:

  1. Optional: Make a backup of your disk
  2. Download an Ubuntu installer ISO, put it on a USB/CD, and boot off of it
  3. Close the installer
  4. Run GParted
  5. Select the disk
  6. Right click on the partition to resize
  7. Select resize
  8. Change the numbers or drag the slider
  9. Click Partition > Apply all changes
  10. Confirm changes were performed correctly
  11. Boot back in and check again

If you only have a CLI, I found a post that might help: Resize Disk Partition on Remote VM Server (I don't have the time to test it right now):

First, turn off swap (swapoff /dev/sda5), because we'll temporarily remove the swap partition.

Use GParted or cfdisk or fdisk to:

Remove the logical partition /dev/sda5 and the extended partition /dev/sda2. Enlarge /dev/sda1 to span the whole disk minus what you want to allocate for the swap partition. Re-create a partition (make it a primary partition for simplicity) for the swap. Do not turn swap back on. Comment out the swap line in /etc/fstab, and reboot. (If you don't reboot, the kernel keeps using obsolete data about the partitioning, which can have disastrous consequences.)

After the reboot, edit /etc/fstab to change the name of the swap device and uncomment it. Format the swap area with mkswap and activate it with swapon -a.

Finally enlarge the existing filesystem to occupy all of /dev/sda1 with resize2fs /dev/sda1.