You are not logged in.
^ chroot already gives you root shell..
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
Ok
Between two evils, I always pick the one I never tried before ~ Mae West
Offline
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
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)
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
thanks Dr. Xaos, with your prescription I was able to fully chroot into the system!
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
OK.
Thanks for the feedback.
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
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
@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
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
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
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
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.
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 ).
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
You are right.
Thanks for spotting this.
Corrected now.
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
thanks Dr. Xaos, with your prescription I was able to fully chroot into the system!
however the binding option did not work for /usr, I got thissudo 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
^ 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
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
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
shouldn't the command be
chroot $TARGET /bin/bash
instead of chroot $TARGET!?
Already tried that. It doesn't work.
Offline
shouldn't the command be
chroot $TARGET /bin/bash
instead of chroot $TARGET!?
If no command is given, run '${SHELL} -i' (default: '/bin/sh -i')
chroot starts the default shell if no command is specified.
Offline
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 grubgrub-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
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
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
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
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