Is there a way to allow the OS to use a USB Flash Drive as RAM?
I’m not sure if thats exactly what you want, but you can make a swapfile on your USB memory stick, or change your USB memorystick to a swap drive.
see
man mkswap
and
man swapon
for more details.
I use this trick to add more memory on a mediastreamer device that runs embedded linux, but has very limmited and non-expandable memory.
Hope it helps.
Note that using a flash based device as swap is a rather poor idea as it will severely shorten the lifespan of that particular device (not to mention flash based devices, despite having good reading and ‘seek’ speeds tend to have poor write speeds)
Full ACK.
You are trying to use the probably slowest type of memory (external USB storage) as a surrogate for the fastest type of memory (RAM) on your machine.
I know of this side-effect, but I read its mainly a theoretical one. Modern portable memory devices have algorithms that spread the usage over the different memory chips to extend the lifetime. But even if this isnt implemented in your memstick, the chance of throwing out your memstick because of the limmited capacity is much bigger then because its broken.
They are so cheap these days, I wouldnt worry.
True, its slow and I would not go for this solution if I would be able to extend the RAM of my device.
IMO, if you have a harddisk in your system, even creating additional swapfiles (not necessarily in a partition by itself) would still run faster that any USB-speed device.
I remember reading in a magazine that Vista could use an external drive as swap, or memory. I couldn’t see any objective reason why someone would want to do so, but it was touted as a big saving feature for the (poor) user.
In a few desktops here, even running a virtual machine:
- with 2GB RAM - very little swap used
- with 4GB RAM - have yet to see any swap.
… but it was touted as a big saving feature for the (poor) user
Microsoft has already made them poor. So, they have to help them
I fully agree with all other responders. Flash should not be used as a swap device.
> I remember reading in a magazine that Vista could use an external drive
> as swap, or memory. I couldn’t see any objective reason why someone
> would want to do so
well, it is ALREADY so slow that no one would notice a difference if
using a USB stick to TRY to meet that hogs memory requirements…
–
heartless_bot
You can extend your RAM with a USB pen drivein a way. What you do here is to change the swap partition of your OS with the pen drive. Caching works much much faster with a pen drive than the hard disk. It works pretty fast compared to hadrddisk swap, but not as fast as pure RAM.
But from a practical working point, you get a really decent performance rather than a seemingly hung computer.
So this is a pretty old message thread, but I do see that your referenced site does show useful instructions for Linux users at the end. You can use the terminal command free to see if you are indeed using any swap space to begin with:
**> free**
total used free shared buffers cached
Mem: 16443980 2339024 14104956 0 352880 900512
-/+ buffers/cache: 1085632 15358348
Swap: 4197372 **0** 4197372
If your total swap used is zero, then this whole thing is not going to do much for you I would think. Using the USB drive as swap can reduce its life span and there is no real good substitute for installing more real RAM memory. But, perhaps some one wants to know how. Thanks for the information boscharun.
Thank You,
On 2012-01-14 19:16, boscharun wrote:
>
> You can 'extend your RAM with a USB pen drive ’
> (http://www.skipser.com/p/2/p/how-to-use-pen-drive-as-ram.html)in a way.
> What you do here is to change the swap partition of your OS with the pen
> drive. Caching works much much faster with a pen drive than the hard
> disk. It works pretty fast compared to hadrddisk swap, but not as fast
> as pure RAM.
I doubt it. Writing on a usb drive is much slower than on a real hard disk.
I have yet to see hardware where this is reversed.
Besides, your interests are in doubt. You have joined today, made 2 posts,
twice the same thing, so probably you are just a commercial poster.
–
Cheers / Saludos,
Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)
Putting swap on USB is really bad idea. It would by painfully slow.
But linux kernel offers much better alternative - it’s called zram.
And it’s ultra fast compressed device in RAM, that can be used to compress memory somewhere between 2:1 - 10:1 ratio.
It achieves about 13GB/s average read with 0.0ms access time on my quad core cpu.
you just need to enable it (as superuser):
modprobe zram num_devices=1 (or “modprobe zram zram_num_devices=1” in kernel>=3.2)
echo 1073741824 > /sys/block/zram0/disksize (set size to 1GB for example)
mkswap /dev/zram0 (put higher priority swap on it)
swapon -p 5 /dev/zram0
and that’s all, enjoy your compressed memory. You can use it as compressed ramdisk too, just format it to ext4 or btrfs.
Putting swap on it will give you quite huge performance boost if you are very low on memory.
You can read more here:
http://www.webupd8.org/2011/10/increased-performance-in-linux-with.html
Note: one device can utilize only one cpu core, to achieve best performance on dual core, make 2512MB devices instead of 11GB.