I try to repair an broken Ubunu 14.04 with chroot. What I did, is to boot Ubuntu from USB mounted the original system that has to be repaired and changed to this system with chroot:
sudo mount /dev/sdXY /mnt
sudo mount -o bind /dev /mnt/dev
sudo mount -o bind /sys /mnt/sys
sudo mount -t proc /proc /mnt/proc
sudo cp /proc/mounts /mnt/etc/mtab
sudo chroot /mnt /bin/bash
That worked fine, but in chroot
environment I don't have access to the internet, so apt
isn't able to resolve hostnames.
What am I supposed to do?
ping www.askubuntu.com
does not work either.
On newer Ubuntu systems, name resolution is handled by the resolvconf service, and /etc/resolv.conf is a symbolic link to /run/resolvconf/resolv.conf. You can either add a bind mount to the /run filesystem along with your other bind mounts before executing the chroot command
so that the chroot system picks up the host system's DNS settings or, once you're in the chrooted system, temporarily create a static /etc/resolv.conf with nameserver(s) of your choice e.g.