Thursday, September 5, 2019

Another pacman recovery

Pacman carries several types of problems. Some take so much time to solve that it's easier to do a fresh Arch install, if one has recently backed-up all their data. This one is a coin toss for a fresh install, and it's one of the more insidious pacman fails. It happens when one does a pacman -Syu, leaves for some other task, then returns to find the system off and unable to completely boot, noting it's unable to find the HDD or possibly
ERROR: specified kernel image does not exist: `/boot/vmlinuz-linux`
The boot process dumps out into a maintenance prompt, and power may even cycle off. Not that it matters to what comes next, but the likely explanation is the internet connection was interrupted during the pacman update, possibly in addition to a power interruption.

1 hour with install disk, 2-3 hours if create disk

In short:
  1. boot with recovery disk
  2. delete /var/lib/pacman/db.lck
  3. fsuck the drive
  4. rerun pacman -Syu, mkinitcpio, and grub
As always, the devil is in numerous details neglected in most web posts and so forth about this problem: one large challenge is likely moving one's system to a wired connection, since the Arch install ISO has rudimentary wifi tools that will add significant time, or entirely thwart, the pacman update while chrooted. Move your system to an ethernet connection. Additionally,
  • mkinitcpio -p linux will likely be unable to locate vmlinuz unless one reinstalls the "linux" package, eg pacman -S linux.
  • one's printer will likely have to be reinstalled due to a "corrupted filter" b/c it won't match the new modules.

burn the CD

$ cdrecord -scanbus
$ cdrecord -v -dao -eject dev=1,0,0 file.iso

boot it and turn on the swap

# lsblock -l
# swapon /dev/sdb [or whichever]
# free -m

chroot

Typically we chroot and do a base install from the disk. But this is not an install. We want to complete a pacman -Syu inside our already existing installation. The mounting is similar, and is the key for proper paths. The key is not to mkdir /mnt, but simply to mount to it as if it already exists. Most people mount to "mnt", however, one could use a different directory name.
# mount -rw -t ext4 /dev/sda1 /mnt
now the entire drive is mounted in a virtual folder called "/mnt". It doesn't exist, but we can chroot into it and see the drive.
# arch-chroot /mnt

clear pacman cache

Users can always run pacman -Sc, but if a person is willing to install the pacman-contrib package (100Kb), there's a script called paccache that will clear all but the most recent 3 updates (in case a person needs to downgrade some package).

$ du -sh /var/cache/pacman/pkg/
14G /var/cache/pacman/pkg/
# paccache -r
==> finished: 870 packages removed (disk space saved: 8.92 GiB)
$ du -sh /var/cache/pacman/pkg/
4.5G /var/cache/pacman/pkg/

No comments: