Created
March 20, 2024 13:41
-
-
Save jwillmer/5066f7a64f4105e40d589af7cfe5595f to your computer and use it in GitHub Desktop.
Resize partition and add swap to Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# disable swap | |
sudo swapoff -a | |
# check space | |
df -h | |
# check partitions | |
lsblk | |
# recreate partition | |
sudo fdisk /dev/sda | |
p # show table | |
d # delete | |
n # new / confirm existing format | |
a # optional: mark as bootable | |
w # save | |
# check partitions | |
lsblk | |
# recognize newly available space | |
resize2fs /dev/sda1 | |
# check space | |
df -h | |
# create new swap file | |
sudo fallocate -l 8G /swapfile | |
# set permissions | |
sudo chmod 600 /swapfile | |
# make it a swapfile | |
sudo mkswap /swapfile | |
# activate the swap | |
sudo swapon /swapfile | |
# make the swap permanent | |
sudo nano /etc/fstab | |
# add this line | |
/swapfile none swap sw 0 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment