Skip to content

Instantly share code, notes, and snippets.

@furushchev
Created September 3, 2019 09:52
Show Gist options
  • Save furushchev/325c9f8edcd19f6c34791a740c01f96a to your computer and use it in GitHub Desktop.
Save furushchev/325c9f8edcd19f6c34791a740c01f96a to your computer and use it in GitHub Desktop.
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/local/bin:/opt/local/sbin
FUSE_OPT="-o default_permissions -o allow_other -o use_ino -o nonempty -o suid"
UNION_OPT="-o cow"
SSD_DEVICE="/dev/nvme0n1p1"
SSD_PATH="/ssd"
UNIONFS="/usr/bin/unionfs-fuse"
ulimit -n 16384
# mount ssd
mount -n -t ext4 -o defaults ${SSD_DEVICE} ${SSD_PATH}
unionmount()
{
DEST=$1
MASTER="${SSD_PATH}/master/${DEST}"
OVERLAY="${SSD_PATH}/overlay/${DEST}"
UNION="${SSD_PATH}/union/${DEST}"
mount -n --bind "/${DEST}" "/${MASTER}"
${UNIONFS} ${FUSE_OPT} ${UNION_OPT} "/${OVERLAY}=RW:/${MASTER}=RO" "/${UNION}"
mount -n --bind "/${UNION}" "/${DEST}"
}
unionmount_ro()
{
DEST=$1
unionmount "${DEST}"
mount -o remount,ro "/${DEST}"
}
# unionmount etc
unionmount home
unionmount opt
unionmount var
exec /lib/systemd/systemd "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment