Skip to content

Instantly share code, notes, and snippets.

@p3x-robot
Last active April 19, 2018 18:17
Show Gist options
  • Save p3x-robot/9146dca0b9f52a03d9278c299b9a9b29 to your computer and use it in GitHub Desktop.
Save p3x-robot/9146dca0b9f52a03d9278c299b9a9b29 to your computer and use it in GitHub Desktop.
💺 Re-install util-linux

How to re-install util-linux packages when it is broken

Based on

util-linux/util-linux#52
http://www.linuxfromscratch.org/lfs/view/development/chapter06/util-linux.html

  • Boot into a live cd (eg Linux Mint 18-19)
    • I you have a new Nvidia video card so in the GRUB settings add in nomodeset (I think it is the command e or c to change the GRUB boot settings
  • Once you are booted into the GUI or terminal
  • Go to the terminal an execute as below
sudo -i
# /dev/sdb1 can be your linux installation
mount /dev/sdb1 /mnt 

for dir in /dev /dev/pts /proc /sys /run; do sudo mount --bind $dir /mnt/$dir; done

chroot /mnt

whoami
# if you are not root, execute this, otherwise, don't need it
sudo -i

# go to a place where you have your projects for example
cd /home/user/projects
git clone https://github.com/karelzak/util-linux
cd util-linux
make uninstall

# check out your stable version or which is need for you apt
# if you have no network you can open a new terminal, 
# which is not in chroot-ed and you got internet
apt list | grep util-linux 
# it says 2.73, but I use the latest stable at the moment
# you can find out the stable versions, like
git branch

# i use the latest
git checkout stable/v2.30

# now the building
./autogen.sh
mkdir -pv /var/lib/hwclock

# make sure the --docdir matches with the stable version as below shows
./configure ADJTIME_PATH=/var/lib/hwclock/adjtime --docdir=/usr/share/doc/util-linux-2.30 --disable-chfn-chsh --disable-login --disable-nologin --disable-su --disable-setpriv --disable-runuser --disable-pylibmount --disable-static --without-python --without-systemd --without-systemdsystemunitdir
make
chown -Rv nobody .
su nobody -s /bin/bash -c "PATH=$PATH make -k check"

# if now problem (hopefully all test pass)
make install

# now you can have wrong libraries, let's fix them
cd /lib/x86_64-linux-gnu/
for lib in libblkid.so* libfdisk.so* libmount.so* libsmartcols.so* libuuid.so*; do mv $lib $lib.bak; done

# check it everything is working
mount --version
# shows now error, something like:
# mount from util-linux 2.30.2 (libmount 2.30.2: btrfs, assert, debug)

# so we can remove the backups
rm *.bak

We are done!*

reboot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment