You are not logged in.
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)
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
i hope it doesn't, but when it does, i bet it this will prove useful one day. thanks!
Offline
Nice! This should go up on the wiki ASAP.
Offline
This just saved my A## - thanks - should be a sticky ?
Offline
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!
edit: whew, that was easy! thanks for the great explanation xaos, really useful, made my day!
Offline
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
Do not keep us in suspense any longer, rhowaldt.
How did it go?
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
^ 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
Oops - missed that.
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
First message on forum just to say: thank you! You saved my life!
By the way, I am loving #!
Offline
First message on forum just to say: thank you! You saved my life!
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
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)
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 !)
Offline
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
^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 !
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 !)
Offline
redman wrote:First message on forum just to say: thank you! You saved my life!
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..
Offline
el_koraco wrote:redman wrote:First message on forum just to say: thank you! You saved my life!
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..
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
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 !
(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 !)
Offline
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.
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 !)
Offline
FYI: Wiki page created on http://crunchbanglinux.org/wiki/howto/r … ith_chroot
Thanks xaos52 for the instructions!
Sweaty lads picking up the soap | I love the new "Ignore user" button
Offline
^ 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.
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 !)
Offline
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
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
Offline
Dr. Xaos, thanks for this guide!
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
#!#!#! Forum etiquette #!#!#!
Are you a new member!? Have you introduced yourself?!
CLI basics | LVM | smxi | chrooting | multiarch
Offline
Perhaps it should be:
sudo update-grub
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
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat