Receptionless
Posts: 1
Joined: Sun Sep 07, 2014 1:15 pm

Using Flash Drive To Expand RAM

Sun Sep 07, 2014 1:26 pm

I know that you can use USB Drives to add extra vRAM to your PC using windows. Usually this is avoided because it is insanely slow, but I was wondering if it would work on my raspberry pi? I want to run a server on it, but the RAM available for use ( I have the 512MB ) is simply not enough. Are the speeds provided by the USB enough for it to have a noticeable impact on the pi?

Thanks for reading!

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13101
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Using Flash Drive To Expand RAM

Sun Sep 07, 2014 2:38 pm

a standard swap file mechanism is already built int Rasbian.

User avatar
Lob0426
Posts: 2198
Joined: Fri Aug 05, 2011 4:30 pm
Location: Susanville CA.
Contact: Website

Re: Using Flash Drive To Expand RAM

Sun Sep 07, 2014 5:00 pm

I used GParted to create a swap partition on a 512MB USB stick. Then disabled the swap on the SD card. Raspbian automatically mounts the swap drive if it is plugged into the a RasPi.

The default Raspbian swap file is 100MB. But the default settings discourage swap file use.

I use this on my WordPress server. I wanted to remove as many writing operations as I could from my servers SD Card. For this to work better you need to change the "swappiness" setting.

vm.swappiness=40 in /etc/sysctl.conf.

I think 60 is the max. It is set at 10 default.
512MB version 2.0 as WordPress Server
Motorola Lapdock with Pi2B
Modded Rev 1.0 with pin headers at USB

http://rich1.dyndns.tv/
(RS)Allied ships old stock to reward its Customers for long wait!

W. H. Heydt
Posts: 12656
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Using Flash Drive To Expand RAM

Sun Sep 07, 2014 9:25 pm

Receptionless wrote:I know that you can use USB Drives to add extra vRAM to your PC using windows. Usually this is avoided because it is insanely slow, but I was wondering if it would work on my raspberry pi? I want to run a server on it, but the RAM available for use ( I have the 512MB ) is simply not enough. Are the speeds provided by the USB enough for it to have a noticeable impact on the pi?

Thanks for reading!
What are you doing that uses more memory than the Pi has?

Do you understand that *all* modes of virtual memory are painfully slow compared to physical memory?

Do you know how to keep a system thrashing if you are using more than a trivial amount of virtual memory?

User avatar
socialdefect
Posts: 110
Joined: Mon Jun 25, 2012 9:02 pm
Location: Tilburg, the Netherlands
Contact: Website

Re: Using Flash Drive To Expand RAM

Sun Sep 07, 2014 10:56 pm

If you want to use your Pi as a server you might want to tweak your settings and OS a little. The default Raspbian image is build to display all the Pi has to offer and that's a load more than you want on your server. There are several mini Raspbian images like Minibian which has only a minimal selection of software, it doesn't even include a graphical desktop environment. You won't need that on a server anyways since it's easy to run commands and access files using SSH.
On this forum you can find tutorials for setting up any type of server you like using mostly terminal commands so there's no need for a desktop anyway.
If you don't use a desktop you can also dedicate more GPU to the system itself which makes it way faster. This can be configured using:

Code: Select all

sudo raspi-config
And if you've got a fast USB key why not use it as a swap drive??... Just set the swappiness as explained in previous posts and keep the swap partition's size below 512MB for more won't be used.

Advanced Users and Daredevils:

Another good tip is to check what packages will be installed every time you apt-get something. If you see a lot of packages you don't need apply --no-install-recommends to your apt-get command and check again. Be sure to check the previous selections to make sure you're not missing anything before you commit the changes. Specialy on webservers you can save tons of disk space and unneeded daemons starting automatically at boot. (disabling daemons you don't use is also a good mem saver)
== If it's not broke... I'm not done fixing it! ==

superman
Posts: 14
Joined: Sun Aug 24, 2014 4:10 pm

Re: Using Flash Drive To Expand RAM

Sun Sep 07, 2014 11:50 pm

@Receptionless: just a bit off-topic, running the OS on a flash drive or USB HDD can boost the performance for sure. Keeping a backup of the whole system will come in handy in case the flash drive or USB HDD suddenly gives up the host.

@WHHeydt: How many MB will be considered as "more than a trivial amount of virtual memory"? More than 1.5 times the size of system RAM, maybe?

drgeoff
Posts: 10765
Joined: Wed Jan 25, 2012 6:39 pm

Re: Using Flash Drive To Expand RAM

Sun Sep 07, 2014 11:59 pm

Receptionless wrote:I know that you can use USB Drives to add extra vRAM to your PC using windows. Usually this is avoided because it is insanely slow, but I was wondering if it would work on my raspberry pi? I want to run a server on it, but the RAM available for use ( I have the 512MB ) is simply not enough. Are the speeds provided by the USB enough for it to have a noticeable impact on the pi?

Thanks for reading!
Have you overridden the default memory split setting to give the minimum to the GPU?

Return to “Beginners”