lordaker
Posts: 30
Joined: Wed Sep 20, 2017 8:31 am

How make a swap space on Rapberry Pi by using USB Drive ?

Mon Feb 19, 2018 2:36 pm

Hello,

I use an usb drive of 32gb and I want to use it like my swap partition for my Raspberry Pi 3.

I formated it with the command " fdisk /dev/sda "

And I create a swap file by using this proccess:

http://raspberrypimaker.com/adding-swap ... spberrypi/

But my swap.file can't research the max of usb drive.

So when I make the command " free -h"
My swap have the value " 1.2 G"

How can I change that ?

User avatar
HawaiianPi
Posts: 2660
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: How make a swap space on Rapberry Pi by using USB Drive ?

Mon Feb 19, 2018 9:57 pm

Why do you think you need 32GB of swap? :shock:

If you actually try to use even a fraction of that it will drag your Pi's performance down to unuseable levels. But since you asked, don't use a swap file, use a swap partition. Format the drive as Linux swap and mount it in /etc/fstab.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

fbe
Posts: 329
Joined: Thu Aug 17, 2017 9:08 pm

Re: How make a swap space on Rapberry Pi by using USB Drive ?

Mon Feb 19, 2018 11:03 pm

I could get 4GB swapfile by increasing CONF_SWAPSIZE and CONF_MAXSWAP in /etc/dphys-swapfile (I didn't try bigger values).

Is Raspbian (32bit) really able to use more than 4GB virtual memory?

User avatar
thagrol
Posts: 814
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: How make a swap space on Rapberry Pi by using USB Drive ?

Tue Feb 20, 2018 4:12 pm

Going over 4GB in a file will be restricted by which filesystem the USB stick has been formatted with. FAT32 for example has a hard filesize limit of 4GB.

That said, a 32GB swap partition is likely to be pointless anyway, whether or not raspbian can address it.

Most sources recommend having swap space between 1 and 2 times the size of the installed RAM. For most Pi models that's a minimum of 1GB and a maximum of 2GB.
Note to self: don't feed the trolls
If you believe "L'enfer, c'est les autres" (Hell is other people) have you considered that it may be of your own making?

Return to “Beginners”

Who is online

Users browsing this forum: fujisan123, Google [Bot], unvjustintime and 19 guests