How to increase RAM using a USB as RAM memory?

2

1

I'm using Ubuntu, a Linux distro.

I read some years ago about the possibility to increase the RAM by using a pen-drive USB as additional memory RAM.

I already googled that but I found only articles talking about using pen-drive as additional swap.

There is a way to do this? The pen-drive as swap is the same as additional RAM?

Thanks a lot

user2342558

Posted 2018-03-19T11:37:20.580

Reputation: 134

5The swap file is technically acts like RAM... but the speed on USB will be atrociously slow. Are you sure you wanted to do this? – Darius – 2018-03-19T11:38:20.700

sure, I bought a 16 GB USB only to do that. My need is to speed up my notebook for at least some months – user2342558 – 2018-03-19T11:41:21.443

2Why not use a swapfile on the hard drive? It will be much faster than a USB key. – Ignacio Vazquez-Abrams – 2018-03-19T11:47:35.950

Linux doesn't have a hybrid solution like Windows readyboost AFAIK. Note that it's just storing some pages in an external memory, the RAM amount is not increased in any cases – phuclv – 2018-03-19T11:54:45.057

@IgnacioVazquez-Abrams, I thought that using the hard drive it may be compromised or damaged at the long period. So I thought to use a USB because if it'll be broken, I'll lose few money. – user2342558 – 2018-03-19T11:54:50.923

2Even the worst SSD has a lifetime much longer than most USB keys. – Ignacio Vazquez-Abrams – 2018-03-19T11:55:53.587

@IgnacioVazquez-Abrams the USB drive will have much better access time, that's why Windows stores small items that need to be accessed frequently on flash, the remainings will still be on HDD – phuclv – 2018-03-19T11:56:01.893

1@LưuVĩnhPhúc: Depends on how much you pay for it. If you spend "few money" then there's no way it will keep up with anything from the past 5 years. – Ignacio Vazquez-Abrams – 2018-03-19T11:57:36.083

The USB is 3.0 with 130 Mb/s of read or write speed. So, whit it can I increase the speed of my notebook in case of the RAM is entirely in use? The swap option on that USB may solve my problem? – user2342558 – 2018-03-20T10:07:55.223

The swap file does not "technically act like RAM". There is no memory address the CPU can assert that will directly, without intervention from the OS, read or write the contents of the swap file. Not if it's on a hard drive, nor an SSD, nor a USB key. – Jamie Hanrahan – 2018-03-21T17:23:14.107

Answers

3

First run this command to find the name of your pendrive from root access in terminal.

fdisk -l

For my case my pendrive is /dev/sdb1. Make sure you get the right drive name then run this to unmount the drive. Change /dev/sdb1 to your pendrive name.

sudo umount /dev/sdb1

Then run this to create the swap file on the pendrive.

mkswap /dev/sdb1

Now to turn on the swap file, run this, remember my pendrive is 2GB so I gave swap 2GB (15000). Give yours according to what yours have.

swapon -p 15000 /dev/sdb1

Done! To see whether it worked, type in this command.

cat /proc/swaps

This is how mine looks like:

This is how mine looks like

Jacques Innocent

Posted 2018-03-19T11:37:20.580

Reputation: 31

(1) -p 15000 is priority, but you connect it to the size of the pendrive somehow. Can you clarify what you mean? (2) Is this a permanent solution? I think it's not (an entry in /etc/fstab would be). Either way this should be explicitly stated. (3) Setting the partition type to 0x82 is rather optional, but it helps to keep things tidy, especially if you recommend fdisk -l as a general way to determine what device is what. – Kamil Maciorowski – 2018-06-26T23:09:56.997

I use -p 15000 for me because my drive is 1.9GB and I cannot assign the exact 1.9GB for swap because I need a little space for retention. But if for example you have a 4GB pendrive, you can use -p 37500 so the swap space assigned is dynamic according to what size you have. – Jacques Innocent – 2018-06-28T08:53:02.257

My point is swapon -p ... has nothing to do with size (mkswap -p ... has). – Kamil Maciorowski – 2018-06-28T08:56:47.770