Category Archives: 未分类文章

Virtualbox reduce swap size and increase size of root

Given I have installed ubuntu inside virtualbox.

I used default installation, ubuntu give 10GB swap size, which is quite a waste.

// turn off swap
sudo swapoff -a


//reduce size to 4G
sudo lvreduce /dev/mapper/ubuntu--vg-swap_1 -L 4G

//recreate swap filesystem
sudo mkswap /dev/ubuntu-vg/swap_1

//bring it online
sudo swapon

// extend root logic volume with free size
sudo lvextend /dev/mapper/ubuntu--vg-root /dev/sda5


// extend without reboot
sudo resize2fs /dev/ubuntu-vg/root