# Encrypt swap



## sk8harddiefast (Jul 16, 2010)

I want to encrypt my swap
I follow this http://www.freebsd.org/doc/en/books/handbook/swap-encrypting.html
but

```
sudo dd if=/dev/random of=/dev/ad0s1b bs=1m
dd: /dev/ad0s1b: Operation not supported
```
Any idea?


----------



## teckk (Jul 16, 2010)

Is /dev/ad0s1b your swap partition

```
swapctl -l
```
I don't know if you have to umount swap to write random to it. Look at

```
man swapoff
man swapon
```


----------



## sk8harddiefast (Jul 16, 2010)

> Is /dev/ad0s1b your swap partition


yeap.
How to use swapon/swapoff?


----------



## DutchDaemon (Jul 17, 2010)

swapon(8) should contain all the information anyone could give ..


----------



## sk8harddiefast (Jul 25, 2010)

I did it 
This is the steps to encrypt swap with bde.
Boot to single user mode
Run:

```
fsck -y
mount -u /
mount -a -t ufs
dd if=/dev/random of=/dev/ad0s1b bs=1m
```
Where /dev/ad0s1b is your swap partition.* Maybe is different in every system.*

```
ee /etc/fstab
```
Change from this

```
/dev/ad10s1b	        none			swap			sw		0	0
```
To this

```
/dev/ad10s1b[B].bde[/B]	        none			swap			sw		0	0
```


```
ee /etc/rc.conf
```
and add this line

```
gbde_swap_enable="YES"
```
Reboot and thats it


----------

