View previous topic :: View next topic |
Author |
Message |
pmatos Veteran

Joined: 06 Jun 2003 Posts: 1246 Location: Eckental, Germany
|
Posted: Tue May 20, 2008 12:57 pm Post subject: Activating swap file |
|
|
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 |
|
 |
dnadesign Apprentice


Joined: 23 Dec 2006 Posts: 172 Location: Poland
|
Posted: Tue May 20, 2008 1:22 pm Post subject: |
|
|
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 |
|
 |
pmatos Veteran

Joined: 06 Jun 2003 Posts: 1246 Location: Eckental, Germany
|
Posted: Tue May 20, 2008 1:30 pm Post subject: |
|
|
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 |
|
 |
dnadesign Apprentice


Joined: 23 Dec 2006 Posts: 172 Location: Poland
|
Posted: Wed May 21, 2008 1:26 am Post subject: |
|
|
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:
3. Make a fstab entry:
Code: | /swapfile none swap sw,loop 0 0 |
4. Run as root to activate your file swap space:
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 |
|
 |
|
|
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
|
|