All Unkept
Posted in: Linux  —  14 August 2007

Sharing internet connection to chroot

UPDATE: Solved! I had forgotten about resolve.conf. Script below updated


I have my computer's hard disk in an external USB hard drive enclosure, and I'm running it off someone else's hardware. I've done this before, and usually I just boot the entire system off the USB device, and it works great.

On this PC, however, it won't boot from my hard drive, but it will boot from other USB keys. So, the closest I've got so far is to use KNOPPIX on a USB key, and then, once KNOPPIX is running, create a chroot for my main system. It looks like this:

# boot knoppix down to single user mode:
telinit 2
# Mount main partition from my computer's hard drive
mkdir /media/mycomputer
mount -t auto -o acl /dev/disk/by-uuid/blahblah...  /media/mycomputer
# Share some things from running system, to keep various applications
# and the kernel happy.
mount --bind /dev /media/mycomputer/dev
mount --bind /tmp /media/mycomputer/tmp
mount --bind /proc /media/mycomputer/proc
mount --bind /etc/resolv.conf /media/mycomputer/etc/resolv.conf
chroot /media/mycomputer

# Now everything works:
/etc/init.d/kdm start
# (use gdm if you don't have kdm)

My system is Feisty, which is very close to Knoppix, and this is probably a big factor in this just working (especially the /dev filesystem). For a while I forgot to do the /etc/resolv.conf bind mount, so the internet did not appear to work.

Comments §

§ On 19 October 2007, tJaisen wrote: 278
Bookmarked. I needed this after my computer crashed during xubuntu's upgrade to gutsy and left me with a kernel panic.

Thanks!

§ On 7 March 2009, Fred wrote: 414
Thanks alot. I accidently uninstalled the gdm package off an ubuntu system that used wireless internet. This allowed me to chroot from the livecd and fix it.

§ On 18 May 2009, aaron wrote: 431
Thanks for this. I needed this because I forgot to install a kernel update when upgrading my filesystems to ext4, and couldn't get past the init prompt. I chrooted in from a live cd and fixed everything.

§ On 22 October 2009, oroberos wrote: 497
Damn, wonderful! All I needed actually...

§ On 24 November 2009, gux wrote: 816
Awesome! the last apt-get dist-upgrade broke my system, so I needed this to chroot from the Live CD and fix it. Cheers!

§ On 23 September 2010, Yeah wrote: 939
One or two weeks that i was looking for a solution like that ! Thanks a lot

§ On 6 May 2011, wa7ed wrote: 1037
Oh yes! i'm in 2011 and it really helped me fix a broken ubuntu 11.04 after an upgrade. Thanks.

Add comment

Format:

  • Javascript has to be on to get past my spam protection, and cookies, and there is a delay, sorry for any inconvenience!
  • I reserve the right to moderate comments.