# Encrypting a zfs zvol with geli



## Alain De Vos (Dec 13, 2022)

Load the kernel module

```
kldload geom_eli.ko
```

Create the zvol & set the volmode

```
zfs create -V 5G ZT/private
zfs set volmod=full ZT/private
```

Initialise the key

```
dd if=/dev/random of=mykey bs=64 count=1
```

Create the eli device with this key and enter passphrase

```
geli init -s 4096 -K ./mykey /dev/zvol/ZT/private
```

Attach the eli device

```
geli attach -k ./mykey /dev/zvol/ZT/private
```

Create the zpool

```
zpool create gelipool /dev/zvol/ZT/private.eli
```

Write your data ....

Export the zpool

```
zpool export gelipool
```

Detach the eli device

```
geli detach /dev/zvol/ZT/private.eli
```

When all data no longer needed:

```
zfs destroy ZT/private
```


----------

