Skip to content

Instantly share code, notes, and snippets.

@antranigv
Created July 24, 2023 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antranigv/5acb4fffb1c8d52c8b8d8013ddecd4f7 to your computer and use it in GitHub Desktop.
Save antranigv/5acb4fffb1c8d52c8b8d8013ddecd4f7 to your computer and use it in GitHub Desktop.
Devuan Linux Jail on FreeBSD 13.2
root@srv0:/etc/jail.conf.d # cat linux0.conf
# vim: set syntax=sh:
exec.clean;
allow.raw_sockets;
mount.devfs;
linux0 {
$id = "2";
devfs_ruleset = 10;
$bridge = "bridge10";
$domain = "srv0.abi.am";
vnet;
vnet.interface = "epair${id}b";
mount.fstab = "/etc/jail.conf.d/${name}.fstab";
exec.prestart = "ifconfig epair${id} create up";
exec.prestart += "ifconfig epair${id}a up descr vnet-${name}";
exec.prestart += "ifconfig ${bridge} addm epair${id}a up";
exec.start = "/sbin/openrc default";
exec.stop = "/sbin/openrc shutdown";
exec.poststop = "ifconfig ${bridge} deletem epair${id}a";
host.hostname = "${name}.${domain}";
path = "/usr/local/jails/linux0";
exec.consolelog = "/var/log/jail/${name}.log";
persist;
exec.jail_user = "root";
exec.system_jail_user = false;
allow.socket_af;
}
root@srv0:/etc/jail.conf.d # cat linux0.fstab
devfs /usr/local/jails/linux0/dev devfs rw 0 0
tmpfs /usr/local/jails/linux0/dev/shm tmpfs rw,size=1g,mode=1777 0 0
fdescfs /usr/local/jails/linux0/dev/fd fdescfs rw,linrdlnk 0 0
linprocfs /usr/local/jails/linux0/proc linprocfs rw 0 0
linsysfs /usr/local/jails/linux0/sys linsysfs rw 0 0
/tmp /usr/local/jails/linux0/tmp nullfs rw 0 0
root@srv0:/etc/jail.conf.d # jls -N
JID IP Address Hostname Path
siras0 siras0.srv0.abi.am /usr/local/jails/siras0
linux0 linux0.srv0.abi.am /usr/local/jails/linux0
root@srv0:/etc/jail.conf.d # jexec -l linux0 /bin/bash
root@linux0:~# ps auxf
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 93675 0.0 0.0 6036 3692 pts/1 S 21:22 0:00 /bin/bash
root 94152 0.0 0.0 5152 2180 pts/1 R+ 21:22 0:00 \_ ps auxf
root 30930 0.0 0.0 10788 7568 ? Ss 21:15 0:00 /usr/sbin/sshd
root 99509 0.0 0.0 3900 2460 ? Ss 21:15 0:00 /usr/sbin/cron
root 90875 0.0 0.0 4552 2968 ? Ss 21:15 0:00 /usr/sbin/rsyslogd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment