SEARCH

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

You are not logged in.

#26 2012-09-09 21:59:48

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

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

^ chroot already gives you root shell.. wink
my problem is that I have a number of update-* commands available, but update-grub is not one of those...:/


#!#!#! 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!

#27 2012-09-09 22:01:20

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

Ok


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

Offline

#28 2012-09-10 07:10:02

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

Sorry I thought you were trying grub-update when it should be update-grub - wasn't meaning to highlight the root thing.


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

Offline

#29 2012-09-10 08:41:24

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

With a separate /usr partition, you have to mount that partition first, like so:

sudo mkdir $TARGET/usr
sudo mount /dev/sdxy $TARGET/usr

Last edited by xaos52 (2013-04-28 08:45:58)

Offline

#30 2012-09-10 18:10:04

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

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

thanks Dr. Xaos, with your prescription I was able to fully chroot into the system! smile
however the binding option did not work for /usr, I got this

sudo mount -o bind /dev/dm-2 $TARGET/usr
mount: Not a directory

but this sequence of commands did the trick

sudo apt-get update && sudo apt-get install lvm2
TARGET=/media/sda5
sudo mkdir -p $TARGET
sudo mkdir -p $TARGET/usr
sudo mount /dev/dm-0 $TARGET 
sudo mount /dev/dm-2 $TARGET/usr

and so forth...


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

Offline

#31 2012-09-10 18:16:07

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

OK.
Thanks for the feedback. smile

Offline

#32 2012-10-24 10:32:50

beadmaze
#! Junkie
Registered: 2009-10-10
Posts: 330

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

to avoid massive crossposting i'd just like to ask, if this is the procedure i should choose to the solve this problem:
http://crunchbanglinux.org/forums/post/266450/#p266450

@tunafish: how did you manage this: http://crunchbanglinux.org/forums/post/211245/#p211245 ?


We are a nice, friendly community here and I hope we stay that way.

Offline

#33 2012-10-24 10:51:14

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

@beadmaze... i don't know exactly what I did. In such a situation I usually just search the internet till I've found the right commands...
Something like this maybe:
http://www.ubuntugeek.com/rescue-an-enc … olume.html
?
I know, not very helpful...
Tuna.


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

Offline

#34 2012-11-16 19:18:30

stratoka
Member
From: Csíkszereda
Registered: 2012-11-16
Posts: 17

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

I like to say thank you myself to.


Linux poses a real challenge for those with a taste for late-night
hacking (and/or conversations with God).   -Matt Welsh-

Offline

#35 2013-02-19 18:17:06

saneks
#! Die Hard
Registered: 2009-10-01
Posts: 1,020

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

great, this thread just saved my day. another distro changed the #! grub and when I removed it I could not boot anymore. thanks!


eee701 user & other lap/desktops

Offline

#36 2013-04-27 22:00:31

elpato
New Member
Registered: 2013-04-27
Posts: 1

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

Multi-part first post here...

First of all, big thanks for the info!!! I had to use the following commands (as root) to get it running with encryption, but finally got grub back ... and now I know to run update-grub after fdisking around big_smile

cryptsetup luksOpen /dev/sda1 sda1_crypt
mount /dev/dm-0 $TARGET

Stupidly, I installed lvm2 because I thought I was using LVM... turned out it wasn't necessary in my case, but...

I don't know if there is a thread to suggest adding packages to the live iso; but I think the lvm2 package would be useful in case anybody using LVM needs the live cd to fix grub. It's quite small, but on my whopping 2.5G connection it took me 20+ minutes to apt-get update/install.

xaos52 wrote:

With a separate /usr partition, you have to mount that partition first, like so:

sudo mkdir $TARGET/usr
sudo mount -o bind /dev/sdxy $TARGET/usr

Isn't bind used only with an already mounted directory? Also, I can't find it listed under the options section of my man page (so you may be referring to something I was not aware of tongue ).

sudo mount --bind /usr $TARGET/usr  #Mounts an already mounted /usr to the chrooted environment.
sudo mount /dev/sdxy $TARGET/usr  #The device isn't mounted yet, so no need to bind.

Lastly... I have been using #! for a few months, and it looks like a great distro with a pretty cool community... I don't expect to be a "regular" on here... but will hopefully I will drop by sometimes...

Offline

#37 2013-04-28 08:43:53

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

You are right.
Thanks for spotting this. smile
Corrected now.

Offline

#38 2013-09-07 18:15:30

grizmoblust
New Member
Registered: 2013-08-04
Posts: 8

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

VDP76 wrote:

thanks Dr. Xaos, with your prescription I was able to fully chroot into the system! smile
however the binding option did not work for /usr, I got this

sudo mount -o bind /dev/dm-2 $TARGET/usr
mount: Not a directory

but this sequence of commands did the trick

sudo apt-get update && sudo apt-get install lvm2
TARGET=/media/sda5
sudo mkdir -p $TARGET
sudo mkdir -p $TARGET/usr
sudo mount /dev/dm-0 $TARGET 
sudo mount /dev/dm-2 $TARGET/usr

and so forth...



I followed this and I still get /bin/bash:  command does not exist.

chroot $TARGET
chroot: fail to run command ` /bin/bash:  No such file or directory

Last edited by grizmoblust (2013-09-07 19:42:53)

Offline

#39 2013-09-07 20:46:44

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

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

^ sorry for the trivial question, have you mounted the correct partition as / (root) !?
I ask because I had to figure out which partition was which with the /dev/dm-* naming...

Last edited by VDP76 (2013-09-07 20:47:07)


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

Offline

#40 2013-09-07 22:46:24

grizmoblust
New Member
Registered: 2013-08-04
Posts: 8

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

sudo apt-get install lvm2
lsblk /dev/sda
 
/dev/sda1 (grub)
/dev/sda2 (system boot) 
/dev/sda3 (1k unknown empty space)
/dev/sda5 (LVM) 
   /dev/dm-0     root
   /dev/dm-1     home
   /dev/dm-2     var
   /dev/dm-3     usr
   /dev/dm-4     tmp
   /dev/dm-5     opt

vgchange -ay
sudo su

TARGET=/media/sda5
mkdir -p $TARGET
mkdir -p $TARGET/home
mkdir -p $TARGET/var
mkdir -p $TARGET/usr

mount /dev/dm-0 $TARGET
mount /dev/dm-1 $TARGET/home
mount /dev/dm-2 $TARGET/var
mount /dev/dm-3 $TARGET/usr

chroot $TARGET
chroot: fail to run command ' /bin/bash ' : No such file or directory

chroot /media/dm-0
chroot: cannot change root directory to /media/dm-0 : No such file or directory

chroot /dev/dm-0
chroot: cannot change root directory to /dev/dm-0 : No such file or directory

lsblk /dev/sda5
...(dm-0) ... /media/sda5
...(dm-1) ... /media/home
...(dm-2) ... /media/var
...(dm-3) ... /media/usr
...(dm-4) ... /media/tmp
...(dm-5) ... /media/opt

Offline

#41 2013-09-07 22:51:04

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

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

shouldn't the command be

chroot $TARGET /bin/bash

instead of chroot $TARGET!?


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

Offline

#42 2013-09-07 23:08:45

grizmoblust
New Member
Registered: 2013-08-04
Posts: 8

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

VDP76 wrote:

shouldn't the command be

chroot $TARGET /bin/bash

instead of chroot $TARGET!?

Already tried that. It doesn't work.

Offline

#43 2013-09-07 23:37:14

porkpiehat
#! Die Hard
Registered: 2012-10-02
Posts: 1,007

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

VDP76 wrote:

shouldn't the command be

chroot $TARGET /bin/bash

instead of chroot $TARGET!?

man bash wrote:

If no command is given, run '${SHELL} -i' (default: '/bin/sh -i')

chroot starts the default shell if no command is specified.

Offline

#44 2014-02-11 04:43:55

PDA1
#! Member
Registered: 2014-01-30
Posts: 66

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

xaos52 wrote:

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

Thank you a 1000 times over!!!

I've just spent the past 4 hours working with Clonezilla.
For whatever reason Clonezilla wouldn't restore an image properly. Clonezilla said something like- "you restored an image from sdb to sda and the image was made from sdb...as a result you won't be able to boot up and will have to configure the boot loader"....or some such nonsense.

So, I tried your method and in a matter of a few minutes the problem was fixed.

Thanks again!

Offline

#45 2014-03-01 18:36:40

torulfr
New Member
From: England
Registered: 2014-03-01
Posts: 1

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

crunchbang@crunchbang:~$ TARGET=/media/sda1
crunchbang@crunchbang:~$ sudo mkdir -p $TARGET
crunchbang@crunchbang:~$ sudo mount /dev/sda1 $TARGET
crunchbang@crunchbang:~$ sudo mount --bind /dev     $TARGET/dev
crunchbang@crunchbang:~$ sudo mount --bind /dev/pts $TARGET/dev/pts
crunchbang@crunchbang:~$ sudo mount --bind /proc    $TARGET/proc
crunchbang@crunchbang:~$ sudo mount --bind /sys     $TARGET/sys
crunchbang@crunchbang:~$ sudo chroot $TARGET /bin/bash
root@crunchbang:/# grub-install /dev/sda
bash: grub-install: command not found

Offline

#46 2014-03-02 02:14:03

PDA1
#! Member
Registered: 2014-01-30
Posts: 66

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

torulfr wrote:

crunchbang@crunchbang:~$ TARGET=/media/sda1
crunchbang@crunchbang:~$ sudo mkdir -p $TARGET
crunchbang@crunchbang:~$ sudo mount /dev/sda1 $TARGET
crunchbang@crunchbang:~$ sudo mount --bind /dev     $TARGET/dev
crunchbang@crunchbang:~$ sudo mount --bind /dev/pts $TARGET/dev/pts
crunchbang@crunchbang:~$ sudo mount --bind /proc    $TARGET/proc
crunchbang@crunchbang:~$ sudo mount --bind /sys     $TARGET/sys
crunchbang@crunchbang:~$ sudo chroot $TARGET /bin/bash
root@crunchbang:/# grub-install /dev/sda
bash: grub-install: command not found

I've had the same problems but solved it this way-

Assumptions- the target drive sda1 (sda) is the exact drive you're trying to install grub to. The above won't work without the exact drive name you want to install grub to.

Execute the commands this way while in Terminal

Step 1- sudo su

Step 2- TARGET=/media/sda1

Step 3- mkdir -p $TARGET

Step 4; (copy and paste the next 5 lines into Terminal all at once)

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

Step 5- cp /etc/resolv.conf    $TARGET/etc/

Step 6- chroot $TARGET /bin/bash

Step 7- grub-install /dev/sda

Step 8- update-grub

Step 9- control-D

Step 10-  (copy and paste the next 4 lines into Terminal all at once)

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

Step 11- Reboot your computer

Offline

#47 2014-11-23 13:52:04

psykonerd
New Member
Registered: 2011-01-29
Posts: 2

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

Gentoo-2012 mnt # TARGET=/media/sda1
Gentoo-2012 mnt # mkdir -p $TARGET
Gentoo-2012 mnt # mount /dev/sda1 $TARGET
mount: you must specify the filesystem type
???? !!! ;-)

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: acrobat

Debian Logo