Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
you want to use pen-drive as swap ?? – Sushantp606 Dec 2 '13 at 4:32
up vote 2 down vote accepted

Smaller USB drive seek times are much faster as compared to the HDD. 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 the files under pen 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 , use the following and make sure which one is your pen drive with the consideration of size, and sdb1 is just used here for exampling and explaining -

sudo fdisk -l

Now create swap on you pen drive by-

sudo mkswap /dev/sdb1

turn it on by -

sudo swapon -p 32767 /dev/sdx1

to check its working use -

cat /proc/swaps

it will show both your swap means hdd and pendrive as well.

share|improve this answer

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

share|improve this answer
"set swappiness to 0" was in my original question. My intent is to reduce writes on the SSD for drive longevity; if the external flashdrive fails, I throw it away and get another. – K7AAY Jul 8 '15 at 16:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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