IPv4 Address:-
IPv6 Address:-
Service Provider:-
SSL Information:-
HTTP Protocol:-
Database:-
Web:-
Blog Menu


Search articles:
 

Recent articles (showing 61-69 out of 69):

 
Using a swap file instead of swap partition in FreeBSD 8.x/9.x [22/Jan/2012]   Booting from ZFS RAID0/1/5/6 in FreeBSD 9.0-RELEASE     Upgrading software (ports/packages) in FreeBSD  

Sometimes, it's preferrably to use a swap file instead of a swap partition in FreeBSD.  It can be useful if you boot from a ZFS raidz1/2/mirror root, or if you just need to add additional swap space to an existing server.

Whatever your reasons for wanting to do it, here's how to do it using FreeBSD 8.x and 9.x

I will create a 4GB swap file, but you can create any size you want by adjusting the figure in the dd command.

First, we need to create a swapfile of the desired size:

dd if=/dev/zero of=/swapfile.dat bs=1m count=4096 Copy

This will create /swapfile.dat with 4096 x 1MB blocks (4GB) – next change the permissions on it as follows:

chmod 0600 /swapfile.dat Copy

And finally, add the following line to your /etc/rc.conf file:

swapfile="/swapfile.dat" Copy

Upon next reboot, your server will create a virtual node (using mdconfig) to the swapfile and add it as swapspace.

To activate it without rebooting, you can run:

/etc/rc.d/addswap start Copy

It should be noted that swapfiles wont be used for kernel crashdumps.  These need to be partitions in order to work.

  Booting from ZFS RAID0/1/5/6 in FreeBSD 9.0-RELEASE     Upgrading software (ports/packages) in FreeBSD  
Copyright © 2024 Daniel Austin MBCS.
Proudly hosted using the FreeBSD operating system.
 
E-mail me
PGP Key
E-mail me
LOGGED IN
Login
padlock icon
LOGIN ERROR#123: random error here