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

Leave a Reply

Your email address will not be published. Required fields are marked *

注意: 评论者允许使用'@user空格'的方式将自己的评论通知另外评论者。例如, ABC是本文的评论者之一,则使用'@ABC '(不包括单引号)将会自动将您的评论发送给ABC。使用'@all ',将会将评论发送给之前所有其它评论者。请务必注意user必须和评论者名相匹配(大小写一致)。