# lvresize

Know what's annoying?  I'll tell you: default Ubuntu server installs from I-don't-know-when don't actually use 100% of the disk space you allocate to them.  Neat right?  NOPE!  Anyway, if that happens to you, [this article](https://neurotechnics.com/blog/resize-the-default-lvm-partition-in-ubuntu/) will get you squared away, and here's the TLDR version:

## Reclaim 100% of disk space in Ubuntu server (unencrypted drive)

### Check if you can actually do the resize
```
sudo lvresize -tvl +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
```

### Resize it for realsiez
```
sudo lvresize -vl +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
```

### Resize the file system to match
```
sudo resize2fs -p /dev/mapper/ubuntu--vg-ubuntu--lv
```

## Reclaim 100% of disk space in Ubuntu server (ENCRYPTED drive)

### Confirm disk size
```
sudo fdisk -l /dev/sda
```

### Grow root partition to fill new space
```
sudo apt install -y cloud-guest-utils   # if not already installed
sudo growpart /dev/sda 3
```

### Resize LUKS container
```
sudo cryptsetup resize dm_crypt-0
```

### Resize LVM
```
sudo pvresize /dev/mapper/dm_crypt-0
```

### Extend logical volume
```
sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
```

### Resize file system
```
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
```

### Verify results
```
df -h /
```
