Better mounting.
This commit is contained in:
parent
722d9cf2fc
commit
2c05f23998
11
archbox.conf
11
archbox.conf
@ -2,8 +2,19 @@ USER="lemniskett"
|
|||||||
PRIV="sudo"
|
PRIV="sudo"
|
||||||
INSTALL_PATH="/var/archlinux"
|
INSTALL_PATH="/var/archlinux"
|
||||||
CHROOT="$INSTALL_PATH/root.x86_64"
|
CHROOT="$INSTALL_PATH/root.x86_64"
|
||||||
|
|
||||||
|
# Nix OS will breaks when you mount /run, change MOUNT_RUN to "no"
|
||||||
|
# if you use Nix OS, don't forget to use `archbox --mount-runtime-only`
|
||||||
|
# after user login
|
||||||
MOUNT_RUN="yes"
|
MOUNT_RUN="yes"
|
||||||
|
|
||||||
|
# Mount modules and boot directory, useful if you want to use kernels
|
||||||
|
# from Arch Linux repo, otherwise it's best to remain disabled
|
||||||
|
MOUNT_MOD="no"
|
||||||
|
|
||||||
|
# Lazy unmounting, make sure you know what you're doing if enabling this!
|
||||||
|
LAZY_UMOUNT="no"
|
||||||
|
|
||||||
# Put your desired enviroment variable here, for example
|
# Put your desired enviroment variable here, for example
|
||||||
# ENV_VAR="HOME=/var/home/lemniskett"
|
# ENV_VAR="HOME=/var/home/lemniskett"
|
||||||
ENV_VAR=""
|
ENV_VAR=""
|
||||||
|
@ -2,34 +2,51 @@
|
|||||||
|
|
||||||
source /etc/archbox.conf
|
source /etc/archbox.conf
|
||||||
|
|
||||||
|
msg(){
|
||||||
|
echo "$(tput bold)$(tput setaf 2)==> $@ $(tput sgr0)"
|
||||||
|
}
|
||||||
|
|
||||||
|
rbind() {
|
||||||
|
[[ $(mount | grep $CHROOT$1) ]] && msg "$CHROOT$1 already mounted." \
|
||||||
|
|| (mount -R $1 $CHROOT$1 && msg "$CHROOT$1 mounted!")
|
||||||
|
[[ $2 = "make-rslave" ]] && mount --make-rslave $CHROOT$1
|
||||||
|
}
|
||||||
|
|
||||||
|
bindproc() {
|
||||||
|
[[ $(mount | grep $CHROOT/proc) ]] && msg "$CHROOT already mounted." \
|
||||||
|
|| (mount -t proc /proc $CHROOT/proc && msg "$CHROOT/proc mounted!")
|
||||||
|
}
|
||||||
|
|
||||||
|
rmbind() {
|
||||||
|
umount_args=-R
|
||||||
|
[[ $LAZY_UMOUNT = "yes" ]] && umount_args=-Rl
|
||||||
|
[[ $(mount | grep $CHROOT$1) ]] && umount $umount_args $CHROOT$1 \
|
||||||
|
&& msg "$CHROOT$1 unmounted!"
|
||||||
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
start)
|
start)
|
||||||
mount -R /home $CHROOT/home
|
rbind /home
|
||||||
mount -t proc /proc $CHROOT/proc
|
bindproc
|
||||||
mount -R /tmp $CHROOT/tmp
|
rbind /tmp
|
||||||
mount -R /sys $CHROOT/sys
|
rbind /sys make-rslave
|
||||||
mount --make-rslave $CHROOT/sys
|
rbind /dev make-rslave
|
||||||
mount -R /dev $CHROOT/dev
|
[[ $MOUNT_RUN = "yes" ]] && rbind /run
|
||||||
mount --make-rslave $CHROOT/dev
|
[[ $MOUNT_MOD = "yes" ]] && rbind /lib/modules && rbind /boot
|
||||||
[[ $MOUNT_RUN = "yes" ]] && mount -R /run $CHROOT/run
|
[[ -d /var/lib/dbus ]] && rbind /var/lib/dbus
|
||||||
mount -R /lib/modules $CHROOT/lib/modules
|
|
||||||
mount -R /boot $CHROOT/boot
|
|
||||||
mount -R /var/lib/dbus $CHROOT/var/lib/dbus
|
|
||||||
mount -R / $CHROOT/var/host
|
|
||||||
chroot $CHROOT /usr/local/bin/serviced >/dev/null 2>&1
|
chroot $CHROOT /usr/local/bin/serviced >/dev/null 2>&1
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
umount -R $CHROOT/home
|
rmbind /home
|
||||||
umount -R $CHROOT/proc
|
rmbind /proc
|
||||||
umount -R $CHROOT/tmp
|
rmbind /tmp
|
||||||
umount -R $CHROOT/sys
|
rmbind /sys
|
||||||
umount -R $CHROOT/dev
|
rmbind /dev
|
||||||
[[ $MOUNT_RUN = "yes" ]] && umount -R $CHROOT/run
|
[[ $MOUNT_RUN = "yes" ]] && rmbind /run
|
||||||
umount -R $CHROOT/lib/modules
|
[[ $MOUNT_MOD = "yes" ]] && rmbind /lib/modules && rmbind /boot
|
||||||
umount -R $CHROOT/boot
|
rmbind /var/lib/dbus
|
||||||
umount -R $CHROOT/var/lib/dbus
|
kill $(pidof serviced) 2>/dev/null
|
||||||
umount -R $CHROOT/var/host
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user