Last active
September 12, 2018 03:50
-
-
Save Trucido/17481dfecd01a8befa5a2308f4b45569 to your computer and use it in GitHub Desktop.
ugly hacky script to rebuild all dkms modules plus manually force zfs if it's intree for debian/ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# rebuild/reinstall all dkms modules. | |
# double check there's no others missing too afterwards. | |
#template(){ | |
#KVER=x.x.x-arch | |
#ZVER=x.x.x.x-x | |
#dkms status | sed s/,//g | awk '{print "--force -m",$1,"-v",$2}' | while read line; do ls /var/lib/initramfs-tools | xargs -n 1 dkms build --force $line -k; done | |
#dkms status | sed s/,//g | awk '{print "--force -m",$1,"-v",$2}' | while read line; do ls /var/lib/initramfs-tools | xargs -n 1 dkms install --force $line -k; done | |
#dkms build --force -m spl -v $ZVER -k $KVER | |
#dkms build --force -m zfs -v $ZVER -k $KVER | |
#dkms install --force -m spl -v $ZVER -k $KVER | |
#dkms install --force -m zfs -v $ZVER -k $KVER | |
#} | |
if [[ "$(id -u)" -ne 0 ]]; then | |
echo "Must run this script as root, or with sudo." | |
exit 1 | |
fi | |
echo "Listing all dkms modules currently registered" | |
echo "Save this list to compare to the results afterwards" | |
echo "$(dkms status)" | |
sleep "5" | |
echo "Uninstalling all DKMS modules" | |
sleep "1" | |
dkms status | sed s/,//g | awk '{print "--force -m",$1,"-v",$2}' | \ | |
while read line; do ls /var/lib/initramfs-tools | \ | |
xargs -n 1 dkms uninstall $line -k; done | |
echo "Rebuilding all DKS modules" | |
sleep "1" | |
dkms status | sed s/,//g | awk '{print "--force -m",$1,"-v",$2}' | \ | |
while read line; do ls /var/lib/initramfs-tools | \ | |
xargs -n 1 dkms build $line -k; done | |
echo "DKMS Modules built, now installing" | |
sleep "1" | |
dkms status | sed s/,//g | awk '{print "--force -m",$1,"-v",$2}' | \ | |
while read line; do ls /var/lib/initramfs-tools | \ | |
xargs -n 1 dkms install --force $line -k; done | |
# sometimes dkms is stubborn and unregisters zfs completely from dkms | |
# so, i just quickly whipped this up since I got tired of reinstalling it manually | |
# It's ugly and not well tested but seems to work. | |
# could be shorter and more efficient though. | |
# get ARCH | |
if [ ! -z "$(getconf LONG_BIT)" ]; then | |
ARCH="amd64" | |
elif [ ! -z "$(uname -r | grep pae)" ]; then | |
ARCH="686-pae" | |
elif [ -z "$ARCH" ]; then | |
ARCH="686" | |
else | |
echo "[ERROR] Can't find your ARCH" | |
exit 1 | |
fi | |
# get the list of kernels we need to install zfs/spl. Yeah there's better ways of doing this, I know. | |
# this was scripted quickly to support more use cases where multiple source trees exist. | |
KVER="$(ls /usr/src/ | grep "linux-headers" | sed s/-common//g | sed s/linux-headers-//g | grep "$ARCH")" | |
# get the zfs version, the head -n1 is in case for some strange reason there is more than one else you're SOL | |
ZVER="$(ls /usr/src/ | grep zfs | sed s/zfs-//g | head -n1)" | |
# force build spl and zfs | |
for splb in $KVER; do | |
dkms build --force -m spl -v "${ZVER}" -k $splb; | |
done | |
for zfsb in $KVER; do | |
dkms build --force -m spl -v "${ZVER}" -k $zfsb; | |
done | |
# force install spl and zfs | |
for spli in $KVER; do | |
dkms install --force -m spl -v "${ZVER}" -k $spli; | |
done | |
for zfsi in $KVER; do | |
dkms install --force -m zfs -v "${ZVER}" -k $zfsi; | |
done | |
echo "Listing all dkms modules currently registered after rebuild" | |
echo "Compare them with the first list and If any are missing, they probably need manual re-installation." | |
echo "Read the commented template section of this script to get a rough idea of how it works" | |
echo "$(dkms status)" | |
exit 0 |
Thanks for the script
any idea how to solve this missing config issue?
not too worried I just need to-reload zfs on reboots because dkms will not install it ...
Error! Could not locate dkms.conf file.
File: /usr/src/spl-0.7.0/dkms.conf does not exist.
don't you need to rebuild initramfs too?
$ sudo scripts/filesystem/zfs_initramfs_inspect.sh
/boot/initramfs-0-rescue-72b97c7344964f3d9c98cacf0caca2f8.img: zfs.ko MISSING
/boot/initramfs-4.17.19-100.fc27.x86_64.img: zfs.ko MISSING
/boot/initramfs-4.17.2-100.fc27.x86_64.img: zfs.ko MISSING
/boot/initramfs-4.3.4-200.fc22.x86_64.img: OK
then
$ sudo dracut -f -v /boot/initramfs-4.17.19-100.fc27.x86_64.img 4.17.19-100.fc27.x86_64
and now
$ sudo scripts/filesystem/zfs_initramfs_inspect.sh
/boot/initramfs-0-rescue-72b97c7344964f3d9c98cacf0caca2f8.img: zfs.ko MISSING
/boot/initramfs-4.17.19-100.fc27.x86_64.img: OK
/boot/initramfs-4.17.2-100.fc27.x86_64.img: zfs.ko MISSING
/boot/initramfs-4.3.4-200.fc22.x86_64.img: OK
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not well tested and there's better/easier ways of doing this but I didn't want to spend all day debugging complicated functions and tests.
Use at your own risk, no guarantees it won't like glue your cat to the carpet or anything.