I need to repair a network related package (Samba) that is preventing my system from booting. (mint 17).
I have a bootable USB stick with the same OS. How would I fix the broken package on my hard disk through the USB operating system?
Download the package(s) that you need and use dkpg
with the --instdir
option:
dpkg --instdir=/path/to/mounted/HDD --install yourpackage.deb
you might want to use --purge
(also with the appropriate --instdir
!!) first if dpkg
doesn't want to overwrite a half installed package.
The easiest way to do this is to create a chroot, and then perform the repair operations inside the chroot. You do this by:
sudo ifconfig
.sudo mkdir -pv /mnt/mymint
sudo mount -v -t ext4 /dev/sdX
where X is the letter for your root partition. You may need to change the -t
option depending on your filesystem.sudo swapon /dev/sdY
where Y is your swap partition.mount -t proc proc /mnt/mymint/proc
mount --rbind /sys /mnt/mymint/sys
mount --rbind /dev /mnt/mymint/dev
chroot /mnt/mymint /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"
sudo apt-get remove --purge brokenpackagename && sudo apt-get-install packagename
exit
umount -l /mnt/mymint/dev{/shm,/pts,}
umount /mnt/mymint{/boot,/sys,/proc,}
reboot
My personal opinion is that using a changeroot is the safest approach because, in this way nothing from the LiveCD/USB interferes with your system. I'll admit this approach probably scares off some newer users, but I can assure you that this work as it is the method that the Gentoo Distribution uses for new installs. If interested, see Chapter 6 of the Gentoo Install Handbook.
chroot