# Can't mount md(4) in jail?



## mko_io (Sep 27, 2019)

Hi,
I'm trying to mount an memory disk inside a jail, Here's my configure
/etc/jail.conf


```
j1 {
    exec.start="/bin/sh /etc/rc";
    exec.stop="/bin/sh /etc/rc.shutdown";
    exe.clean;
    mount.devfs;
    ip.address="192.168.64.6";
    enforce_statfs = 0;
    allow.mount;
    allow.mount.tmpfs;
    allow.mount.zfs;
   devfs_ruleset = 5;
}
```

and the /etc/devfs.conf

```
[devfsrules_j1=5]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add path 'bpf*' unhide
```


and in jail $ sysctl security.jail gives me:

```
security.jail.mount_tmpfs_allowed: 1
security.jail.mount_procfs_allowed: 0
security.jail.mount_zfs_allowed: 1
security.jail.mount_devfs_allowed: 1
security.jail.devfs_ruleset: 7
security.jail.enforce_statfs: 0
security.jail.mount_allowed: 1
security.jail.jailed: 1
```

which seems correct to me then I'm trying to make a md based ufs

```
# mdconfig -s 10m -u md0
# mdconfig -l
md0
#newfs /dev/md0
/dev/md0: 10.0MB (20480 sectors) block size 32768, fragment size 4096
    using 4 cylinder groups of 2.53MB, 81 blks, 384 inodes.
super-block backups (for fsck_ffs -b #) at:
192, 5376, 10560, 15744
#mount /dev/md0 /mnt/disk1
```

then I got an error:

```
mount: /dev/md0: Operation not permitted
```

any suggestions?


----------



## bjs (Sep 27, 2019)

Not saying it will solve your problem but one thing I notice right off the bat is in your /etc/jail.conf you have 
	
	



```
devfs_ruleset=7;
```

But in
/etc/devfs.conf you have
	
	



```
[devfsrules_j1=5]
```


----------



## mko_io (Sep 28, 2019)

bjs that's a typo, I've corrected it, the problem is still there. thanks for pointing it out.


----------



## D-FENS (Sep 28, 2019)

You need to unhide also the md device in your ruleset.
It should look like this:
`add path 'md*' unhide`
This topic already discusses this: https://forums.freebsd.org/threads/memory-disk-in-a-jail.66363/

And after doing this, I think you need to restart the devfs daemon on the host.


----------

