run container use unshare

level@ThinkStation:~$ cat run-unshare.sh

ROOTFS=/home/level/.local/share/lxc/noble/rootfs

sudo mount -o private,X-mount.group=1,X-mount.owner=1 -t devtmpfs devtmpfs $ROOTFS/dev

sudo mount -o private,mode=666,X-mount.group=1,X-mount.owner=1 -t devpts devpts $ROOTFS/dev/pts

sudo mount -o private,X-mount.group=1,X-mount.owner=1 -t tmpfs tmpfs $ROOTFS/dev/shm

sudo chown -R 1:1 $ROOTFS/dev/pts

sudo chmod 0755 $ROOTFS/dev/pts/ptmx

sudo chown 1:1 $ROOTFS/dev/ptmx

sudo chmod 0755 $ROOTFS/dev/ptmx

# unshare -p --fork -U -m --keep-caps --map-users=0:1:1 --map-groups=0:1:1 --map-users=1:1:65536 --map-groups=1

:1:65536 -R /ubuntu_bionic_1804/lxc_rootfs -w /home/level --mount-proc -r

unshare -p --fork -U -m --keep-caps -R $ROOTFS -w /root --mount-proc --map-users=0:1:65536 --map-groups=0:1:655

36 -S 0 -G 0

sudo umount $ROOTFS/dev/pts

sudo umount $ROOTFS/dev/shm

sudo umount $ROOTFS/dev


ROOTFS=${HOME}/wifi/codebot

sudo mount -o private,X-mount.group=1000,X-mount.owner=1000 -t devtmpfs devtmpfs $ROOTFS/dev

sudo mount -o private,X-mount.group=1000,X-mount.owner=1000 -t devpts devpts $ROOTFS/dev/pts

sudo mount -o private,X-mount.group=1000,X-mount.owner=1000 -t tmpfs tmpfs $ROOTFS/dev/shm

sudo mount -o private,X-mount.group=1000,X-mount.owner=1000 -t sysfs sysfs $ROOTFS/sys

sudo mount --make-shared -o remount ${HOME}/wifi


sudo chown -R 1000:1005 $ROOTFS/dev/pts

sudo chmod 0666 $ROOTFS/dev/pts/ptmx


sudo chown 1000:1005 $ROOTFS/dev/ptmx

sudo chmod 0666 $ROOTFS/dev/ptmx


export -n TMUX

export HOME=/home/ubuntu USER=ubuntu

unshare -U -m --keep-caps -R $ROOTFS -w /home/ubuntu --map-users=0:1000:65536 --map-groups=0:1000:65536 -S 1000

 -G 1000 --propagation unchanged --setgroups allow

# unshare -p --fork -U -m --keep-caps -R $ROOTFS -w /root --mount-proc --map-users=0:1000:65536 --map-groups=0:

1000:65536 -S 0 -G 0

# unshare -p --fork -U -m --keep-caps -R $ROOTFS -w /home/ubuntu --mount-proc --map-users=0:1000:65536 --map-gr

oups=0:1000:65536 -S 0 -G 0

# unshare -p --fork -U -m --keep-caps -R $ROOTFS -w /home/ubuntu --mount-proc --map-users=0:1000:65536 --map-gr

oups=0:1000:65536 -S 1000 -G 1000

# unshare -p --fork -U -m --keep-caps -w $ROOTFS --mount-proc --map-users=0:1000:65536 --map-groups=0:1000:6553

6 -S 0 -G 0

sudo umount $ROOTFS/dev/pts

sudo umount $ROOTFS/dev/shm

sudo umount $ROOTFS/dev

sudo umount $ROOTFS/sys


bconsole() {

        unshare -U --map-users=0:1000:65536 --map-groups=0:1000:65536 -S 1000 -G 1000 tmux -S wifi/codebot/tmp/

tmux-1000/default a

}


Comments

Popular Posts