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,595

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

Be excellent to each other!

#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,747

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: #! Fringe Division
Registered: 2011-04-26
Posts: 10,163
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


VSIDO | SolusOS

Words That Build Or Destroy

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.


sed 's/stress/relaxation/g'
Privacy & Security on #!

Offline

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

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

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

^ i already made an edit to my post! check it:

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

in other words: everything went smooth as a baby's butthole.

Offline

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

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

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,747

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

redman wrote:

First message on forum just to say: thank you! You saved my life! big_smile

In general, if you do get into trouble, dr xaos will be the one to bail you out. He's the problem solver here.

Offline

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

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

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)


Some common cbiz abbreviations. This will save me time and yet @ same time tell folks what the babble is supposed to mean.

Vll ! = ( Viva la gnu/Linux !)    Vl#!! = ( Viva la #! !)    Last but not least, UD ... OD ! = ( Use Debian ... or die !) tongue

Offline

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

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

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

CBizgreat! wrote:

This would work w most Debian OS's and deriviatives too ... ?

This will work with any distro using Grub2, so everything based on Debian and Ubuntu. If a distro uses Grub1 (grub legacy), only the last bit needs to be changed, though Grub1 rarely breaks, if ever.

Offline

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

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

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)


Some common cbiz abbreviations. This will save me time and yet @ same time tell folks what the babble is supposed to mean.

Vll ! = ( Viva la gnu/Linux !)    Vl#!! = ( Viva la #! !)    Last but not least, UD ... OD ! = ( Use Debian ... or die !) tongue

Offline

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

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 10,163
Website

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

el_koraco wrote:
redman wrote:

First message on forum just to say: thank you! You saved my life! big_smile

In general, if you do get into trouble, dr xaos will be the one to bail you out. He's the problem solver here.

Along with an incredible amount of information and fellow doctor's on the Quick Reference page.. cool


VSIDO | SolusOS

Words That Build Or Destroy

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

VastOne wrote:
el_koraco wrote:
redman wrote:

First message on forum just to say: thank you! You saved my life! big_smile

In general, if you do get into trouble, dr xaos will be the one to bail you out. He's the problem solver here.

Along with an incredible amount of information and fellow doctor's on the Quick Reference page.. cool

Yes, indeed. This forum and all the info posted by the community it's of great help in everything. It's one of the best characteristics of #!

Offline

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

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

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)


Some common cbiz abbreviations. This will save me time and yet @ same time tell folks what the babble is supposed to mean.

Vll ! = ( Viva la gnu/Linux !)    Vl#!! = ( Viva la #! !)    Last but not least, UD ... OD ! = ( Use Debian ... or die !) tongue

Offline

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

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

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


Some common cbiz abbreviations. This will save me time and yet @ same time tell folks what the babble is supposed to mean.

Vll ! = ( Viva la gnu/Linux !)    Vl#!! = ( Viva la #! !)    Last but not least, UD ... OD ! = ( Use Debian ... or die !) tongue

Offline

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

machinebacon
#! unstable
Registered: 2009-07-02
Posts: 6,586

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

FYI: Wiki page created on http://crunchbanglinux.org/wiki/howto/r … ith_chroot

Thanks xaos52 for the instructions! smile

Offline

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

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

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)


Some common cbiz abbreviations. This will save me time and yet @ same time tell folks what the babble is supposed to mean.

Vll ! = ( Viva la gnu/Linux !)    Vl#!! = ( Viva la #! !)    Last but not least, UD ... OD ! = ( Use Debian ... or die !) tongue

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

This is an awesome guide, but several people have been bitten by the assumption that there is no separate /boot partition.

Remember if you try to use this guide:

If you have a separate /boot partition, you must set TARGET to the partition normally mounted at root (/) (this will most likely not be sda1) and not your /boot partition!

(aka Assumption 2: You do not have a separate /boot partition, and your root partiton is sda1)

(It's called chroot for a reason!)

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

If for any reason you need internet in your chrooted enviroment, you should do, before the chroot command:

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

Source: http://ubuntuforums.org/showthread.php?t=1439061

Offline

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

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

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

Dr. Xaos, thanks for this guide! smile
I am still not in trouble with MBR/GRUB but I will be soon when I'll reinstall M$-Win, so I am practising this.
I have sut up a LVM so the first mount command gives me this error

mount: unknown filesystem type 'LVM2_member'

I have found this, so doing

sudo apt-get install lvm2
vgchange --available y $volgroupname

I am able to mount my root partition as /dev/dm-0; since I have a separate /usr partition I also have to mount it as

sudo mount --bind /usr $TARGET/usr

At this point I am able to chroot but, strangely, the command grub-update is not there even though GRUB is installed. Am I missing something!?
thanks smile


#!#!#! Forum etiquette #!#!#!
Are you a new member!? Have you introduced yourself?!
CLI basics | LVM | smxi | chrooting | multiarch

Offline

Help fund CrunchBang, donate to the project!

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

mariannemarlow
#! Die Hard
From: My flat, London, England
Registered: 2012-06-03
Posts: 2,204
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.

Debian Logo