# Running poudriere on truenas



## dfr (Apr 15, 2022)

Has anyone succeeded in building packages inside a truenas jail? When I try it, all the zfs filesystems are mounted inside the jail in unexpected directories, prepending the pool's altroot which truenas sets to /mnt:


```
zfs list                                                            
NAME                                                          USED  AVAIL  REFER  MOUNTPOINT
pool                                                         4.82T  5.38T   239K  /mnt/pool
pool/iocage                                                  60.2G  5.38T  14.8M  /mnt/pool/iocage
pool/iocage/jails                                            54.3G  5.38T   256K  /mnt/pool/iocage/jails
pool/iocage/jails/pkg                                        6.72G  5.38T   247K  /mnt/pool/iocage/jails/pkg
pool/iocage/jails/pkg/data                                   1.77G  5.38T   205K  none
pool/iocage/jails/pkg/data/data                              1.48M  5.38T   273K  /mnt/usr/local/poudriere/data
pool/iocage/jails/pkg/data/data/.m                            222K  5.38T   222K  /mnt/usr/local/poudriere/data/.m
...
```


----------



## SirDice (Apr 15, 2022)

GhostBSD, pfSense, TrueNAS, and all other FreeBSD Derivatives


----------



## dfr (Apr 16, 2022)

This isn't a truenas problem - its easy to reproduce on a vanilla FreeBSD system:


```
sudo zpool import -R /altmnt scratch
sudo iocage activate scratch
sudo iocage create -n testjail -r 12.3-RELEASE bpf=1 vnet=1
...
sudo iocage set ip4_addr="vnet0|DHCP" interfaces="vnet0:vm-public" testjail
sudo iocage set jail_zfs=1 jail_zfs_dataset=iocage/jails/testjail/data allow_mount_devfs=1 allow_mount_nullfs=1 allow_mount_tmpfs=1 testjail
sudo zfs create scratch/iocage/jails/testjail/data
sudo iocage start testjail
...
sudo iocage console testjail
...
root@testjail:~ # df
Filesystem                         1K-blocks    Used     Avail Capacity  Mounted on
scratch/iocage/jails/testjail/root 187457084 1262686 186194398     1%    /
devfs                                      1       1         0   100%    /dev
fdescfs                                    1       1         0   100%    /dev/fd
scratch/iocage/jails/testjail/data 186194422      24 186194398     0%    /altmnt/scratch/iocage/jails/testjail/data
root@testjail:~ # zfs create -o mountpoint=/mnt scratch/iocage/jails/testjail/data/test
root@testjail:~ # df
Filesystem                              1K-blocks    Used     Avail Capacity  Mounted on
scratch/iocage/jails/testjail/root      187457049 1262686 186194363     1%    /
devfs                                           1       1         0   100%    /dev
fdescfs                                         1       1         0   100%    /dev/fd
scratch/iocage/jails/testjail/data      186194387      24 186194363     0%    /altmnt/scratch/iocage/jails/testjail/data
scratch/iocage/jails/testjail/data/test 186194387      24 186194363     0%    /altmnt/mnt
```

Note the addition of the /altmnt prefix inside the jail. This leaks information from the host and makes the jail behave differently depending on how the pool was imported which seems wrong. Any namespace protection from the altroot in the host is irrelevant in the jail since it has its own private namespace.


----------



## indgy (May 27, 2022)

I have been looking at running Poudriere in a jail and found these resources, while not truenas or iocage specific they may help:

https://dan.langille.org/2019/10/23/moving-poudriere-from-the-host-into-a-jail/

https://hackacad.net/post/2021-01-13-build-a-freebsd-pkg-mirror-with-bastille-poudriere/


----------

