After searching here, I found no direct answer to:

Is it practical to put swap on a USB Flash drive? I do not yet know if the teeny-tiny flash drive (Fit CZ33 ) I wish to use runs at high-speed (480 Mbps), full-speed (12 Mbps), or low-speed (1.5 Mbps), but am checking w/ SanDisk.

My intent is to reduce writes on the SSD for drive longevity; if the external flashdrive fails, I throw it away and get another.

Why? Because I just changed my ThinkPad R60 9459AT8 over to a Samsung SSD after maxing out the RAM at 3GB, set up trim after repartitioning with 20% free, removed swap, set swappiness to 0 and otherwise tuned up Xubuntu 13.10 for SSD. However, since it's not practical for me to add a mechanical HDD, I'd like to move the swap over to a Flashdrive which will always stay in the left side USB2 socket, for I'dather wear out a $12 flashdrive instead of a $180 SSD.

Why? Sometimes, I lose my WiFi connection until I reboot, plus rarely see slowdown, and I'd like to see if having swap again would help. I do watch a system monitor always in a panel and never exceed 30% free memory use, but would like to have swap without putting in on the SSD.

Yea, or nay?

And, does the size of the flashdrive make any difference: 8GB, 16GB or 32GB?

  • 4
    you want to use pen-drive as swap ?? – Sukupa91 Dec 2 '13 at 4:32

Flash drives are slower. My SSD is older and half the speed of newer systems and my system is all SATA2 and USB2.

sudo hdparm -t /dev/sdd4

older SSD drive: Timing buffered disk reads: 626 MB in 3.01 seconds = 208.20 MB/sec

Older 160GB rotating drive: Timing buffered disk reads: 212 MB in 3.01 seconds = 70.46 MB/sec

USB2 flash drive Timing buffered disk reads: 50 MB in 3.07 seconds = 16.26 MB/sec

Or my flash drive is only 10% as fast for reading as my slow SSD. And writes are notoriously slow on flash drives.

You can set swappiness to use RAM first.

cat /proc/sys/vm/swappiness
gksudo gedit /etc/sysctl.conf

Add this:



There is the swapspace or dynamic swap manager. Looks like not maintained, but still in repository of 12.04.

sudo apt-get install swapspace


| improve this answer | |

Smaller USB drive seek times are much faster as compared to an HDD, if you had one. The downside is that regular and sequential read/writes to the USB drive decrease the life of the drive itself. It is not as good as having proper RAM but at least it is far better than having Swap on the HDD.

To do so, delete all files uon the USB flash drive, so plug it in and unmount it by-

sudo umount /media/sdb1

to watch the disk label as we have used here sdb1 (yours might be different). Yse the following and make sure which one is your USB flash drive with the consideration of size, and sdb1 is just used here for exampling and explaining -

sudo fdisk -l

Now create swap on your USB flash drive by-

sudo mkswap /dev/sdb1

turn it on with

sudo swapon -p 32767 /dev/sdx1

to check it works

cat /proc/swaps

which will show both your swap on your booting drive and the USB Flash Drive as well.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.