LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-09-2004, 04:33 AM   #1
aus9
Guru
 
Registered: Oct 2003
Posts: 5,060

Rep: Reputation: Disabled
Restoring GRUB using a rescue cd


USING A RESCUE CD to restore GRUB to MBR
I am using sysresccd aka system rescue cd from www.sysresccd.org

INTRODUCTION
Rescue cds always tend to mount any partitions they discover as read only but we need them as read writeable.
eg knoppix makes my partitions available on the desktop for reading only.

Know where your /boot partition is....mine is /dev/hda1 change yours to suit.

STEP by STEP
Change bios to boot cdrom b4 hard or floppy drives

With cd in drive, boot the computer and assuming English keep pressing enter at the prompts, until you get a console or terminal prompt. If you have a non-qwerty keyboard the second prompt allows you to change the keyboard.

type su press enter

type mkdir /mnt/newroot press enter

mount your real /boot partition for me its
type mount -t reiserfs /dev/hda1 /mnt/newroot press enter

type chroot /mnt/newroot /bin/bash press enter

type grub press enter
# prompt will change to grub then then the cursor


type root (hd0,0) press enter (change if /boot partition different)

type setup (hd0) press enter

reboot and remove cd.

EXPLAIN

su = setuser to root no password is requied for knoppix or sysrescd

mkdir = make directory to anything you like but I suggest if you are reading this don't change it.
Its only a directory in your virtual = ram drive = ram disk so on reboot IT is not there.

mount means make your /boot partition readable and writeable. Yours may not be reiserfs so change reiserfs to whatever you are using.
/bin/bash is what I use, as do most newbies.

chroot means ignore all rescue cd file system, trick it into thinking your old system is back already.

grub = bootloader

root see my tutorial if you don't know how to use root

setup means let grub do its business

Last edited by aus9; 09-09-2004 at 04:41 AM.
 
Old 09-09-2004, 05:46 AM   #2
masand
Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 58
hi aus9
thanks for ur little tutorial

i got to learn a new way of dealing with the above problem

will try when i gat to face it again

regards
 
Old 02-21-2012, 05:35 PM   #3
Foxbat1155
Member
 
Registered: Oct 2011
Location: Portugal.
Distribution: Debian squeeze - Fluxbox.
Posts: 109

Rep: Reputation: 0
error

this is not working for me.

first of all it cannot mount any reiserfs. I believe that should have been explained in this post.

I have mounted it with ext4

second I am stuck here:

chroot: failed to run command `/bin/zsh': No such file or directory...
 
Old 02-22-2012, 02:05 AM   #4
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,675

Rep: Reputation: Disabled
Hi aus9, thanks for this concise and very nicely short HowTo.

Here are some additions marked in green (aus9's original commands in black) which might help in some instances:

Code:
mkdir /mnt/newroot
mount /dev/sda1 /mnt/newroot

mount -t proc none /mnt/newroot/proc
mount -t sysfs none /mnt/newroot/sys
mount -o bind /dev /mnt/newroot/dev

chroot /mnt/newroot /bin/bash

source /etc/profile
These additions were suggested to me by another member here:
http://www.linuxquestions.org/questi...5/#post4145771

<edit 29th february 2012> I found a further source, they added the "mount -t sysfs none /mnt/newroot/sys" line as well. I thought I'd post it here, too, for completeness. </edit>

Last edited by JZL240I-U; 02-29-2012 at 10:44 AM.
 
Old 05-12-2013, 06:13 AM   #5
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Lubuntu 12.10
Posts: 34
Blog Entries: 2

Rep: Reputation: Disabled
Question "No such file or directory"

"type chroot /mnt/newroot /bin/bash press enter"

I type the above, but I always get the below response from terminal:
lubuntu@lubuntu:~$ sudo chroot /mnt/newroot /bin/bash
chroot: failed to run command ‘/bin/bash’: No such file or directory

I even investigate in the /bin folder, results as follows:
lubuntu@lubuntu:~$ cd /bin
lubuntu@lubuntu:/bin$ ls -l bas*
-rwxr-xr-x 1 root root 5468 Apr 23 12:47 base64
-rwxr-xr-x 1 root root 924892 Mar 30 15:32 bash
lubuntu@lubuntu:/bin$

This proves that there is a bash, but I always still get the "No such file or directory" result.

Why does this happen? Does it happen since my original Lubuntu 13.04 whose grub was recently knocked out by Debian 7.0 LXDE CD ISO was encrypted?

Last edited by andrew.comly; 05-12-2013 at 06:19 AM.
 
Old 05-12-2013, 06:35 AM   #6
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Lubuntu 12.10
Posts: 34
Blog Entries: 2

Rep: Reputation: Disabled
My encrypted Lubuntu 13.04 was recently knocked out by Debian 7 LXDE CD ISO install to a usb stick. I received the following results with your advice:

lubuntu@lubuntu:~$ mkdir /mnt/newroot
mkdir: cannot create directory ‘/mnt/newroot’: File exists
lubuntu@lubuntu:~$ #mount /dev/sda1 /mnt/newroot
lubuntu@lubuntu:~$ sudo mkdir /mnt/newroot
mkdir: cannot create directory ‘/mnt/newroot’: File exists
lubuntu@lubuntu:~$ sudo mount /dev/sda1 /mnt/newroot
mount: /dev/sda1 already mounted or /mnt/newroot busy
mount: according to mtab, /dev/sda1 is already mounted on /mnt/newroot
lubuntu@lubuntu:~$ sudo mount -t proc none /mnt/newroot/proc
mount: mount point /mnt/newroot/proc does not exist
lubuntu@lubuntu:~$ sudo mount -t sysfs none /mnt/newroot/sys
mount: mount point /mnt/newroot/sys does not exist
lubuntu@lubuntu:~$ sudo mkdir /mnt/newroot/sys
lubuntu@lubuntu:~$ sudo mkdir /mnt/newroot/proc
lubuntu@lubuntu:~$ sudo mount -t proc none /mnt/newroot/proc
lubuntu@lubuntu:~$ sudo mount -t sysfs none /mnt/newroot/sys
lubuntu@lubuntu:~$ sudo mkdir /mnt/newroot/dev
mkdir: cannot create directory ‘/mnt/newroot/dev’: File exists
lubuntu@lubuntu:~$ sudo mount -t sysfs none /mnt/newroot/sys
mount: none already mounted or /mnt/newroot/sys busy
mount: according to mtab, none is already mounted on /mnt/newroot/sys
lubuntu@lubuntu:~$ sudo mount -o bind /dev /mnt/newroot/dev
lubuntu@lubuntu:~$ chroot /mnt/newroot /bin/bash
chroot: cannot change root directory to /mnt/newroot: Operation not permitted
lubuntu@lubuntu:~$ sudo chroot /mnt/newroot /bin/bash
chroot: failed to run command ‘/bin/bash’: No such file or directory
lubuntu@lubuntu:~$ sudo source /etc/profile
sudo: source: command not found
lubuntu@lubuntu:~$ sudo source /etc/a
sudo: source: command not found
lubuntu@lubuntu:~$
 
Old 05-12-2013, 06:44 AM   #7
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Lubuntu 12.10
Posts: 34
Blog Entries: 2

Rep: Reputation: Disabled
Question I am impressed with the grub command, but ...

I am impressed with the grub command, when I reboot the computer is stuck in this "grub" interface. Unfortunately, the results (below) are still not successful.

lubuntu@lubuntu:~$ mkdir /mnt/newroot
mkdir: cannot create directory ‘/mnt/newroot’: File exists
lubuntu@lubuntu:~$ #mount /dev/sda1 /mnt/newroot
lubuntu@lubuntu:~$ sudo mkdir /mnt/newroot
mkdir: cannot create directory ‘/mnt/newroot’: File exists
lubuntu@lubuntu:~$ sudo mount /dev/sda1 /mnt/newroot
mount: /dev/sda1 already mounted or /mnt/newroot busy
mount: according to mtab, /dev/sda1 is already mounted on /mnt/newroot
lubuntu@lubuntu:~$ sudo mount -t proc none /mnt/newroot/proc
mount: mount point /mnt/newroot/proc does not exist
lubuntu@lubuntu:~$ sudo mount -t sysfs none /mnt/newroot/sys
mount: mount point /mnt/newroot/sys does not exist
lubuntu@lubuntu:~$ sudo mkdir /mnt/newroot/sys
lubuntu@lubuntu:~$ sudo mkdir /mnt/newroot/proc
lubuntu@lubuntu:~$ sudo mount -t proc none /mnt/newroot/proc
lubuntu@lubuntu:~$ sudo mount -t sysfs none /mnt/newroot/sys
lubuntu@lubuntu:~$ sudo mkdir /mnt/newroot/dev
mkdir: cannot create directory ‘/mnt/newroot/dev’: File exists
lubuntu@lubuntu:~$ sudo mount -t sysfs none /mnt/newroot/sys
mount: none already mounted or /mnt/newroot/sys busy
mount: according to mtab, none is already mounted on /mnt/newroot/sys
lubuntu@lubuntu:~$ sudo mount -o bind /dev /mnt/newroot/dev
lubuntu@lubuntu:~$ chroot /mnt/newroot /bin/bash
chroot: cannot change root directory to /mnt/newroot: Operation not permitted
lubuntu@lubuntu:~$ sudo chroot /mnt/newroot /bin/bash
chroot: failed to run command ‘/bin/bash’: No such file or directory
lubuntu@lubuntu:~$ sudo source /etc/profile
sudo: source: command not found
lubuntu@lubuntu:~$ sudo source /etc/a
sudo: source: command not found
lubuntu@lubuntu:~$ sudo mkdir /mnt/newroot
mkdir: cannot create directory ‘/mnt/newroot’: File exists
lubuntu@lubuntu:~$ sudo mount -t ext2 /dev/sda1 /mnt/newroot
mount: /dev/sda1 already mounted or /mnt/newroot busy
mount: according to mtab, /dev/sda1 is already mounted on /mnt/newroot
lubuntu@lubuntu:~$ sudo chroot /mnt/newroot /bin/bash
chroot: failed to run command ‘/bin/bash’: No such file or directory

[ Minimal BASH-like line editing is supported. For
the first word, TAB lists possible command
completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
lubuntu@lubuntu:~$ grub
grub>
root (hd0,0)
Error 21: Selected disk does not exist
grub>
setup (hd0)
Error 12: Invalid device requested
grub>
grub> root (sda1,0)
root (sda1)
Error 23: Error while parsing number
grub>
root (sda)
Error 23: Error while parsing number

Any things that I did wrong?
 
Old 05-13-2013, 01:31 AM   #8
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,675

Rep: Reputation: Disabled
Hi Andrew,

if I get this right, you are trying this from the GRUB-prompt. As I understand it, e.g. /sys and /proc are not set up yet by the system before booting. "Chrooting" should change the root-directory "/" of a running(!) linux-system to a different device. Please give a more detailed description of your problems and what actions led up to them.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
restoring grub nayankk Linux - Newbie 2 09-10-2005 03:59 PM
Restoring grub after win reinstall praveendasigi Linux - Distributions 1 01-25-2005 11:58 PM
Restoring Grub Sevoma Suse/Novell 6 12-31-2004 10:52 PM
problem restoring grub redhat 8 rock_sg Linux - Hardware 0 07-30-2003 01:15 AM
Restoring GRUB sami Linux - Newbie 11 10-30-2002 05:36 PM


All times are GMT -5. The time now is 10:57 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration