swap file

LuCKy lucky at e-neyret.com
Sun Sep 19 13:59:05 PDT 2004


> I want to use a swap file instead of swap partition, I found some
> documentation on how to do that, but mostly out-dated.
>
> Is the following procedure correct?
>
> 1. Create a file of 256 MB
>
> # dd if=/dev/zero of=/swap bs=4096 count=65536
>
> 2. Make it a swap file
>
> # mkswap /swap
>
> 3. Add the following line to /etc/fstab
>
> /swap           swap            swap    pri=1           0       0
>
> 4. First mount the filesystem read-write, then activate the swap
>
> # mv /etc/rc.d/rcsysinit.d/S20swap /etc/rc.d/rcsysinit.d/S45swap
>
> Should this work? The file in on a journeling filesystem (ext3), could
> this cause problems?
>
> Sincerly,
>
> Laurens

This works.
Don't forget to chmod 600 /swap in order to prevent regular users from dumping 
the swap space.

LuCKy



More information about the lfs-support mailing list