SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2011-10-03 19:21:34

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

How to chroot into #! on disk when you can not boot via grub

How to chroot from live session to #! on disk

Assumption: #! is installed on /dev/sda1 but is not accessible via grub
Goal: reinstall grub in mbr of /dev/sda:
Here goes:
boot from livecd or usb
in terminal window:

sudo su
TARGET=/media/sda1
mkdir -p $TARGET
mount /dev/sda1 $TARGET
mount --bind /dev     $TARGET/dev
mount --bind /dev/pts $TARGET/dev/pts
mount --bind /proc    $TARGET/proc
mount --bind /sys     $TARGET/sys
cp /etc/resolv.conf    $TARGET/etc/
chroot $TARGET /bin/bash

This places you in a root terminal on the #! system
Do whatever you want to do there, e.g. re-install grub

grub-install /dev/sda
update-grub

To exit from chroot:

control-D

This brings you back to where you were in the live session and you can unmount

umount -l $TARGET/dev/pts
umount -l $TARGET/dev
umount -l $TARGET/proc
umount -l $TARGET/sys

Thats it...
Reboot into the #! system on disk.

Edit1: Replaced '/usr/bin/bash' by '/bin/bash'
Edit2: Start with defining TARGET, and reference it in all subsequent lines.
Edit3: Use sudo su in stead of sudo
Edit4: cp /etc/resolv.conf into the chroot to make apt-get possible

Last edited by xaos52 (2013-02-28 12:42:45)

Offline

Help fund CrunchBang, donate to the project!

#2 2011-10-03 19:44:03

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: How to chroot into #! on disk when you can not boot via grub

i hope it doesn't, but when it does, i bet it this will prove useful one day. thanks!

Offline

#3 2011-10-03 20:03:24

el_koraco
#!/loony/bun
From: inside Ed
Registered: 2011-07-25
Posts: 4,749

Re: How to chroot into #! on disk when you can not boot via grub

Nice! This should go up on the wiki ASAP.

Offline

#4 2012-03-18 18:58:22

retired
Member
Registered: 2012-02-25
Posts: 19

Re: How to chroot into #! on disk when you can not boot via grub

This just saved my A## - thanks - should be a sticky ?

Offline

#5 2012-03-18 19:01:17

VastOne
#! Ranger
From: V-Ger
Registered: 2011-04-26
Posts: 10,165
Website

Re: How to chroot into #! on disk when you can not boot via grub

^ It is in Quick References and will be added to the Wiki

Offline

#6 2012-04-22 19:28:53

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: How to chroot into #! on disk when you can not boot via grub

today is the day i'll be making use of this. just installed Win7 on another partition because i need to test some audio-issues i'm having (try and determine whether it is a Linux problem or not..). of course it has messed up my MBR, so i'll be using chroot for the first time ever! this calls for celebration! smile

edit: whew, that was easy! thanks for the great explanation xaos, really useful, made my day!

Offline

#7 2012-04-23 07:51:33

Tunafish
#! Die Hard
From: the Netherlands
Registered: 2010-03-07
Posts: 1,204

Re: How to chroot into #! on disk when you can not boot via grub

Some days ago I made a typo in /etc/default/grub
Had to chroot into #! and used something similar...
As I have an encrypted root partition I first had to open and mount that one as well. When this is done the steps are the same as described above.

Offline

#8 2012-04-23 08:18:41

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: How to chroot into #! on disk when you can not boot via grub

Do not keep us in suspense any longer, rhowaldt.
How did it go? smile

Offline

#9 2012-04-23 09:42:37

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: How to chroot into #! on disk when you can not boot via grub

Offline

#10 2012-04-23 09:58:25

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,602

Re: How to chroot into #! on disk when you can not boot via grub

Oops - missed that.

Offline

#11 2012-05-06 22:34:25

redman
New Member
Registered: 2012-05-02
Posts: 2

Re: How to chroot into #! on disk when you can not boot via grub

First message on forum just to say: thank you! You saved my life! big_smile
By the way, I am loving #!

Offline

#12 2012-05-06 23:13:42

el_koraco
#!/loony/bun
From: inside Ed
Registered: 2011-07-25
Posts: 4,749

Re: How to chroot into #! on disk when you can not boot via grub

Offline

#13 2012-05-06 23:22:58

CBizgreat!
#! Die Hard
Registered: 2011-07-27
Posts: 1,865

Re: How to chroot into #! on disk when you can not boot via grub

Another thank you Xaos ...

Nothing borked here. But was really wanting to know how to do something like this and hadn't been able to trackdown any good how to's for it. So definitely bookmarked and appreciated. Know where to come, if needing this done. This would work w most Debian OS's and deriviatives too ... ?


(CB) smile

Last edited by CBizgreat! (2012-05-06 23:23:23)

Offline

#14 2012-05-06 23:47:43

el_koraco
#!/loony/bun
From: inside Ed
Registered: 2011-07-25
Posts: 4,749

Re: How to chroot into #! on disk when you can not boot via grub

Offline

#15 2012-05-07 00:22:46

CBizgreat!
#! Die Hard
Registered: 2011-07-27
Posts: 1,865

Re: How to chroot into #! on disk when you can not boot via grub

^Thanks El_ it's always appreciated when more experienced nixers clarify. More interested in possibly having to change files on harddisk from live session, so a better idea of how to do this could really help out sometime.


Vll ! smile

Last edited by CBizgreat! (2012-05-07 00:23:19)

Offline

#16 2012-05-07 00:28:06

VastOne
#! Ranger
From: V-Ger
Registered: 2011-04-26
Posts: 10,165
Website

Re: How to chroot into #! on disk when you can not boot via grub

Offline

#17 2012-05-07 10:44:04

redman
New Member
Registered: 2012-05-02
Posts: 2

Re: How to chroot into #! on disk when you can not boot via grub

Offline

#18 2012-05-07 12:24:35

CBizgreat!
#! Die Hard
Registered: 2011-07-27
Posts: 1,865

Re: How to chroot into #! on disk when you can not boot via grub

Ok it's official ... add me to the list of folks whose arse Xaos saved w this how to ...

At the risk of getting added to El_'s and BlackIvans PLONK list. Funny story ... a dork ( who shall remain nameless) decides why da heel not. Time to give it a try ... installs Arch. Spends HOURS 1/2 learning way around, get's brilliant idea. Ha ! It'll save me some time if I just copy over some fluxbox config files to this new install ... Yeah !

And everything was going great, dork was very pleased w himself. Until he borked up the .fluxbox keys file and the wm went to shat ! Arghhhh ... being still nix newbish, didn't know how to fixy, though sure there are plenty of ways and gdm was set up for autologin. To a fluxbox that wasn't there ! Arghhhh again ! In a nix newb frenzy x dork tried to just reinstall fluxbox, then in an ever desperate dorkish frenzy ... uninstalled fluxbox altogether, the only wm installed at the time and gdm didn't like it at all. Reboot ... gdm login screen ... nothing to log into ... And so was up chit creek.

So ... what ends up happening. Dork follows Xaos handy how to for chroot ( w a friggin LM10 livecd of all things), makes it into Arch root terminal and whamo ... reinstalls fluxbox w it. To @ least enable dork to get back in and in grand newb style fix the borkage w/o having to spend FRIGGIN HRS reinstalling and config'in.

So THANK YOU Xaos ... You're da man ! wink


(CB)

Last edited by CBizgreat! (2012-05-07 12:35:06)

Offline

#19 2012-05-29 18:17:44

CBizgreat!
#! Die Hard
Registered: 2011-07-27
Posts: 1,865

Re: How to chroot into #! on disk when you can not boot via grub

Me again ... Xaos ya saved my arse again ... You're da man ... again !


This time dorking around with display managers. Things went a tad wrong, Xaos handy chroot how to and a "dpkg-reconfigure gdm" and was back in bizness ! Anyway ... yet again, thanks for taking the time to write/post this.


cb. smile

Offline

#20 2012-05-29 18:31:25

machinebacon
#! unstable
From: China
Registered: 2009-07-02
Posts: 6,826
Website

Re: How to chroot into #! on disk when you can not boot via grub

Offline

#21 2012-05-30 07:11:49

CBizgreat!
#! Die Hard
Registered: 2011-07-27
Posts: 1,865

Re: How to chroot into #! on disk when you can not boot via grub

^ x12 for good add ...


This info has already saved me a ton of time, headache and/or buttache. Thanks to one of the nix wizards here in Crunch-academy. Professor Xaos. smile

Last edited by CBizgreat! (2012-05-30 07:41:35)

Offline

#22 2012-07-02 16:44:44

pidsley
Window Mangler
Registered: 2012-05-23
Posts: 1,752

Re: How to chroot into #! on disk when you can not boot via grub

Last edited by pidsley (2012-07-02 16:47:49)

Offline

#23 2012-07-12 01:22:42

sanbor
New Member
Registered: 2012-05-19
Posts: 1

Re: How to chroot into #! on disk when you can not boot via grub

sudo cp /etc/resolv.conf $TARGET/etc/resolv.conf 

Offline

#24 2012-09-09 21:47:03

VDP76
#! Bean Roaster
Registered: 2012-04-12
Posts: 840

Re: How to chroot into #! on disk when you can not boot via grub

mount: unknown filesystem type 'LVM2_member'

Offline

Be excellent to each other!

#25 2012-09-09 21:53:07

mariannemarlow
#! Die Hard
From: My flat, London, England
Registered: 2012-06-03
Posts: 2,246
Website

Re: How to chroot into #! on disk when you can not boot via grub

Perhaps it should be:

sudo update-grub

smile

hmm

Last edited by mariannemarlow (2012-09-09 22:01:09)


Between two evils, I always pick the one I never tried before ~ Mae West

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: bleh

Debian Logo