# parallel swap (in several disks)



## alvaro (May 6, 2011)

Does FreeBSD take advantage of several swap partitions in different HDs? (I mean in terms of transfer rate, seek times, etc etc). If that is the case, how can it be optimized?


----------



## SirDice (May 6, 2011)

Yes, and no need to optimize.


```
dice@molly:~>swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/gpt/swap4    2097152    16568  2080584     1%
/dev/gpt/swap5    2097152    15964  2081188     1%
/dev/gpt/swap6    2097152    16848  2080304     1%
/dev/gpt/swap7    2097152    16008  2081144     1%
Total             8388608    65388  8323220     1%
```


----------



## phoenix (May 6, 2011)

From swapon(8):

```
DESCRIPTION
     The swapon, swapoff and swapctl utilities are used to control swap
     devices in the system.  At boot time all swap entries in /etc/fstab are
     added automatically when the system goes multi-user.  [b]Swap devices use a
     fixed interleave[/b]; the maximum number of devices is specified by the ker-
     nel configuration option NSWAPDEV, which is typically set to 4.  There is
     no priority mechanism.
```
Note the mention of the "fixed interleave".  Basically, the kernel (internally) creates a RAID0-like stripeset across all the swap devices.  There's nothing to "optimise" or configure.  Just create 1 swap device per harddrive, and the kernel does the rest.


----------



## SirDice (May 6, 2011)

Don't be tempted to put swap on a 'real' RAID0 volume though. If one of the drives fails the entire RAID volume fails and you lose _all_ swap in one go.


----------

