Slackware – Add Swap After Installation

I just got a Slackware Linux VM and everything was setup and works well until I realize that I don’t have enough swap space. Swap partition should be ideally twice the size of RAM. I just re-created the partition and re-added the new and bigger swap partition.

Here is what I do. First, since this is a VM (although it should work the same on real box), I need to remove the old swap partition. In VirtualBox, you just need to remove the virtual disk and create a new one. I have problem re-using the same name/label so I just name it like SlackSwap2. To save disk space from the host, you need to delete the physical virtual disk file on VirtualBox’s directory.

Next, create a bigger virtual disk that suits your need. In my case, it is 3GB. Then boot the VM into runlevel 3 and create a swap partition. I used cfdisk to manage the partition and my device is at /dev/sdb. Once the swap partition is created, my partition is now at /dev/sdb1. Maybe we need a reboot this time, but it may work without a reboot, just not sure because I rebooted anyway.

Next, boot again in runlevel 3 and login as root of course. Do the following to configure the swap partition.

mkswap /dev/sdb1
swapon /dev/sdb1

Then reboot again for it to take effect. Once done rebooting, you should now have a bigger swap partition. Verify it by using top or other utilities like ksysguard.

Enjoy and share.

This entry was posted in Linux, Slackware. Bookmark the permalink.

Leave a Reply

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