How to setup swap on a sd card

ubuntu
hardware

#1

I had installed ubuntu with an sd card plugged in and it got formatted as swap device. unfortunately my daughter pulled and formatted to use for carrying files. Now the box is running visibly slower. I want to restore the old setup, where the sd card is designated as swap.
Please, advise how to do?
Thanks everybody


#2

Is this Raspberry PI based setup? Please provide a little bit info about your setup like what kind of computer you got and how did you install it first time?


#3

typically, you’ll need to set up the partiton (your card in this case) you want to swap on using mkswap /dev/sdX and then enable it with swapon /dev/sdX.


#4

it’s a 7 yr old laptop with Lubuntu. the sd card is like ssd while the hd is pretty slow, so it helps a lot.


#5

I got this warning:
mkswap: /dev/sdb: warning: don’t erase bootbits sectors
(dos partition table detected). Use -f to force.
Setting up swapspace version 1, size = 14.9 GiB (16005459968 bytes)

Is it better to reformat??


#6

I did that and the sd is not recognized as swap in Disks. is there a way to verify that swap is on the card? previously Disks was recognizing this as Linux swap format.


#7

Use any one of the following command to see swap info
cat /proc/swaps
OR
swapon -s
See “HowTo: Check Swap Usage and Utilization in Linux” for more info