Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Activating swap file
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
pmatos
Veteran
Veteran


Joined: 06 Jun 2003
Posts: 1246
Location: Eckental, Germany

PostPosted: Tue May 20, 2008 12:57 pm    Post subject: Activating swap file Reply with quote

Hello all,

I have installed for the first time Gentoo on a macbook and it worked flawlessly but I followed the [wiki] suggestion of creating a swap file instead of a swap partition, however, I don't know how to activate the swap file on boot. I have been doing swapon manually but it is not convenient. Usually you would do it in fstab [in case of it being a partition] but what if it is a file?

Cheers,

Paulo Matos
Back to top
View user's profile Send private message
dnadesign
Apprentice
Apprentice


Joined: 23 Dec 2006
Posts: 172
Location: Poland

PostPosted: Tue May 20, 2008 1:22 pm    Post subject: Reply with quote

Hi, try adding this to your fstab:
Code:
/path/to/swap/file none swap sw,loop 0 0


It mounts a file through a loopback device, so it acts as a partition. Should work as a swap partition, but I didn't test it yet.
_________________
MacBook Pro 5.1
Intel C2D 2.53 GHz, 4GB RAM DDR3, GF 9400M and 9600M GT 512MB
Back to top
View user's profile Send private message
pmatos
Veteran
Veteran


Joined: 06 Jun 2003
Posts: 1246
Location: Eckental, Germany

PostPosted: Tue May 20, 2008 1:30 pm    Post subject: Reply with quote

dnadesign wrote:
Hi, try adding this to your fstab:
Code:
/path/to/swap/file none swap sw,loop 0 0


It mounts a file through a loopback device, so it acts as a partition. Should work as a swap partition, but I didn't test it yet.


Thanks, I will try that.
Back to top
View user's profile Send private message
dnadesign
Apprentice
Apprentice


Joined: 23 Dec 2006
Posts: 172
Location: Poland

PostPosted: Wed May 21, 2008 1:26 am    Post subject: Reply with quote

pmatos wrote:
Thanks, I will try that.


Ok, so I tested it and there's a few things missing. Follow those simple steps, to get a swap file.
1. Create a file called, for example, /swapfile of a needed size (if this example 1M means 1 million blocks, which will give you a 512MB file):
Code:
dd if=/dev/zero of=/swapfile count=1M

2. Use mkswap to get your file ready for swaping:
Code:
mkswap /swapfile

3. Make a fstab entry:
Code:
/swapfile none swap sw,loop 0 0

4. Run as root to activate your file swap space:
Code:
swapon -a


The fstab entry will make sure that it is correctly mounted on startup (one of the rc scripts has a call to "swapon -a"). If you have trouble using "swapon" then try chown'ing the file to root (I did it before activating the swapfile, but it shouldn't be necessary).

Enjoy your additional swap space. :)
_________________
MacBook Pro 5.1
Intel C2D 2.53 GHz, 4GB RAM DDR3, GF 9400M and 9600M GT 512MB
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum