Commit 89c4313b authored by Benjamin Slade's avatar Benjamin Slade

new options for limiting cache; fixes for dracut delay on boot

- added in an option to set target/limit for ZFS ARC
- fixed issue with kernels installed post-chroot taking 2-3 minutes to boot
  due to dracut searching for the swap partition to initiate resume
  - this is fixed by disabling the resume option from dracut
  (future versions may contain other options pending investigation)
parent 1281631b
......@@ -63,8 +63,7 @@ xbps-install -Su # update
read -p "The following will take some time - you may want to go and put the kettle on or the like. Please press <return> (twice) to continue." teatime
# install crucial packages, including zfs, which will trigger DKMS ZFS module creation for each kernel
# Nb. despite `python(3)` not being a current (2019-06-15) dependency of `zfs`, DKMS module build fails without it
xbps-install -S linux cryptsetup grub python3 zfs
xbps-install -S linux cryptsetup grub zfs
# dracut
sed -i 's/--force/--force --hostonly --include \/boot\/rootkey.bin \/rootkey.bin/' /etc/kernel.d/post-install/20-dracut
......@@ -96,6 +95,12 @@ mkswap -f /dev/zvol/${ZPOOLNAME}/swap
echo "# zol swap vol" >> /etc/fstab
echo "/dev/zvol/${ZPOOLNAME}/swap none swap sw 0 0" >> /etc/fstab
# disable resume functionality from dracut
echo "omit_dracutmodules+=\" resume \"" > /etc/dracut.conf.d/omit-resume-for-zvol-swap.conf
# inform user about resume
echo "[Resume functionality has been disabled from dracut. Otherwise future kernels which are installed will take 2-3 minutes to boot while dracut searches for the swap partition to initialise resume. This issue will be investigated, but disabling resume from dracut prevents the delayed boot.]"
# Setting zfs cache
echo "Setting zpool cachefile for ${ZPOOLNAME}."
zpool set cachefile=/etc/zfs/zpool.cache ${ZPOOLNAME} # IMPORTANT
......@@ -105,6 +110,33 @@ useradd -m -s /bin/bash -U -G wheel,users,audio,video,cdrom,input ${USERNAME}
echo "Set password for user ${USERNAME}: "
until passwd ${USERNAME}; do echo "Confirmation didn't match. Please try again. " ; done
# setting ARC
read -p "Would you like to set limit ARC size? (By default it will default to half available memory; if you're running a desktop/laptop, you may want to set it lower; if you're running a file-server, you may want to set it higher.) [Y/n]: " ARCSET
if [ ${ARCSET} == "Y" ]
echo "Installing bc for calculations..."
xbps-install -S bc
RAWMEM=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`
MEMAVAIL=`echo "${RAWMEM}*1.025/1024/1024" | bc`
echo "You have ${MEMAVAIL}Gb available. How much memory would you like to reserve for ARC? "
until [[ "${ARCREZ}" =~ ^[0-9.]+$ ]] && [[ `echo "${ARCREZ} > 0" | bc` == 1 ]] && [[ `echo "${ARCREZ} < ${RAWMEM}" | bc` == 1 ]]
do read -p "Enter a number in Gb (e.g. \"4\", \"1.7125\" &c.): " ARCREZ
MEMINBYTES=`echo "${ARCREZ}*1024*1024*1024" | bc | awk '{printf("%d\n",$1 + 0.5)}'`
echo "
# Limit ZFS ARC to ${ARCREZ}Gb
echo ${MEMINBYTES} >> /sys/module/zfs/parameters/zfs_arc_max" >> /etc/rc.local
echo "ARC size specified in /etc/rc.local"
echo "Removing bc package"
xbps-remove -R bc
# additional configuration
read -p "Do you want to install NetworkManager? [Y/n]: " NETWORKMAN
......@@ -15,7 +15,7 @@ done
/sbin/zpool export -a -f
# final message to user
echo "When you reboot, sign in as *root* and execute in root's ome directory:"
echo "When you reboot, sign in as *root* and execute in root's home directory:"
echo "."
echo ""
read -p "Press <return> to reboot." rebootnow
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment