LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-08-2013, 02:45 PM   #1
mgen72
LQ Newbie
 
Registered: Dec 2013
Distribution: centos 6
Posts: 4

Rep: Reputation: Disabled
grub.conf missing


Hi.

My system is a Centos 6.4.

I'm learning Linux.

I am doing some tests and I have moved /boot/grub/grub.conf to /tmp. Afterwards I have restarted the system.

So, now, system doesn't boot and the system shows the grub shell to type commands.

I type this commands:

grub > root
grub > kernel /vmlinuz-2.6.32-220.el6.i686
grub > initrd /initramfs-2.6.32-220.el6.i686.img
grub > boot

But it doesn't work because it can't find the root partition. It would work if I typed:

grub > kernel /vmlinuz-2.6.32-220.el6.i686 ro root=/dev/mapper/VolGroup-lv_root

instead of "grub > kernel /vmlinuz-2.6.32-220.el6.i686".

But if I wouldn't know the path of root partition, how could I boot the system?

I have tried booting with the Centos DVD and choosing "Rescue installed system" but the system halts when trying to boot.

So, in the real world, if I wouldn't know the path of root partiion, how could I boot the system?

Thank you very much,

M. G.
 
Old 12-08-2013, 03:00 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,218

Rep: Reputation: 2517Reputation: 2517Reputation: 2517Reputation: 2517Reputation: 2517Reputation: 2517Reputation: 2517Reputation: 2517Reputation: 2517Reputation: 2517Reputation: 2517
see the wiki
http://wiki.centos.org/TipsAndTricks/ReinstallGRUB

and
http://wiki.centos.org/TipsAndTricks/TroubleshootGRUB
 
1 members found this post helpful.
Old 12-08-2013, 04:01 PM   #3
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 525

Rep: Reputation: 141Reputation: 141
In order to boot from the Redhat/CentOS box with grub problems, you need to know 2 things:
  1. The /boot partition, where you can find kernel and initramfs, and
  2. The root (/) partition.

You can find /boot partition, by searching for file grub.conf or menu.lst or stage1 file. Then finding '/' is easy.

Code:
grub> find /grub/stage1
 (hd0,0)

grub> find (hd0,0)/grub/stage1
 (hd0,0)
 (hd0,1)
 (hd0,4)

grub> cat (hd0,0)/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/vda2
#          initrd /initrd-[generic-]version.img
#boot=/dev/vda
.
.

grub> cat (hd0,1)/etc/fstab
# Created by anaconda on Wed Dec  4 15:25:43 2013
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=74cc8471-e9dc-4b29-8c0a-3baa2d5176a5 /                       ext4    defaults        1 1
UUID=590fd42d-6454-4ce5-99c3-52f9f3e1c5e8 /boot                   ext4    defaults        1 2
.
.
Once you find /boot and root (/), booting is easy.
Code:
grub> root (hd0,0)

grub> kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/vda2
OR
grub> kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=UUID=74cc8471-e9dc-4b29-8c0a-3baa2d5176a5

grub> initrd /initramfs-2.6.32-358.el6.x86_64.img

grub> boot
Note: After entering kernel / or initrd /, you can press <TAB> to autofill.

Last edited by mddnix; 12-08-2013 at 04:03 PM.
 
Old 12-08-2013, 09:38 PM   #4
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,344

Rep: Reputation: 226Reputation: 226Reputation: 226
check out this link:
http://www.linuxforums.org/forum/lin...lems-grub.html

text below is from this link--->>> http://answers.oreilly.com/topic/44-...command-shell/

Quote:
You need to know the locations of Linux kernels and root devices on your system in order to boot it.

Use GRUB's tab completion to find root devices and kernel images. First, boot to the GRUB command shell by hitting c when GRUB starts up.

To find the root device (partition containing /boot), type root (hd0 and hit the Tab key until you see some partitions displayed:

grub> root (hd0,<tab>
Possible partitions are:
Partition num: 0, Filesystem type is ext2fs, partition type 0x83
Partition num: 1, Filesystem type is ext2fs, partition type 0x83
When there are several partitions displayed, and you are not sure which one you want, it does not hurt to try them all. First, try (hd0,0):

grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83

Then search for the kernel image. Type kernel /boot/vmlinuz, and hit Tab. If there is no /boot/vmlinuz, GRUB will tell you:

grub> kernel /boot/vmlinuz<tab>
Error 15: File not found

If this happens, reset the root device to the other partition, and look for a kernel image there:

grub> root (hd0,1)
Filesystem type is ext2fs, partition type 0x83

grub> kernel /boot/vmlinuz<tab>
possible files are: vmlinuz vmlinuz-2.4.21

Okay, you've found a kernel. Type the path to the kernel and the root filesystem:

grub> kernel /boot/vmlinuz-2.4.21 ro root=/dev/hda2

Remember, GRUB's partition numbering starts from zero, so hd0,1 = /dev/hda2.

These next two steps apply only to systems that require a ramdisk to boot. Find initrd:

grub> find /boot/init<tab>
grub> find /boot/initrd-2.4.22-1.img

Load the initrd image:

grub> initrd /boot/initrd-2.4.22-1.img

Now you can boot up:

grub> boot

And the system should start normally.




If you are not sure that the usual kernel naming conventions were followed, have GRUB display the entire contents of /boot. Type kernel /boot/, and hit tab:


grub> kernel /boot/<tab>
System.map System.map-2.4.21 System.map-2.6.3 boot grub config-2.4.21 config-2.6.3
splash.xpm.gz vmlinuz vmlinuz-2.4.21 kernel-of-truth-2.6.3

Well, it looks like we have a wackily-named 2.6 kernel, "kernel-of-truth-2.6.3." Regardless of the silly name, it should work just like its more soberly named cousins.

With tab completion, you can easily search entire filesystems. This is useful for exploring unfamiliar systems, as you can start from the root:

grub> root (hd0,6)
grub> find /<tab>

Possible files are bin dev etc lib mnt opt tmp sys var usr boot home proc sbin root
cdrom floppy initrd

However, this is a big security hole, as anyone with access to the GRUB command shell can read any file on the system with cat: grub> cat /root/secretpersonalstuff.txt
grub> cat /etc/shadow To close this hole, see Recipe Recipe 12.14 to learn how to password-protect GRUB.

<a name="they may">GRUB will find root devices and kernels anywhere they may be. Suppose, for example, you have two IDE hard drives. The second drive has a Linux root filesystem installed on /dev/hdb5. Boot it this way:

grub> root (hd1,4)
grub> kernel /boot/vmlinuz-2.4.21 ro root=/dev/hdb5
grub> boot
On an unfamiliar system, you can have GRUB detect all installed hard drives: grub> root (hd <tab>
Possible disks are: hd0 hd1
 
Old 12-10-2013, 01:25 PM   #5
mgen72
LQ Newbie
 
Registered: Dec 2013
Distribution: centos 6
Posts: 4

Original Poster
Rep: Reputation: Disabled

Thank you John, but If I try to boot from the CentOS installation DVD and I chose the "Rescue ..." option, then when booting, the system halts.

And, in the grub shell the find command doesn't work, it says:

grub > find /grub/grub.conf

Error 15: File not found

This happens because I moved grub.conf from /boot/grub. I did it on purpose (just because I want to learn).
What I want is to fix a problem like this in the real world. Imagine that the grub.conf is missing and you don't know where is the root partition (for this example, root=/dev/mapper/VolGroup-lv_root), so you can't type the command:

grub > kernel /vmlinuz-2.6.32-220.el6.i686 ro root=/dev/mapper/VolGroup-lv_root

Hopefully this hasn't happened to me in a real server, just in a virtual machine I'm using to learn.

Last edited by mgen72; 12-10-2013 at 01:34 PM.
 
Old 12-10-2013, 01:53 PM   #6
mgen72
LQ Newbie
 
Registered: Dec 2013
Distribution: centos 6
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thnnks mddesai, but I think it's required the file /boot/grub/grub.conf exists. If missing, I don't see how to guess that my root partition is root=/dev/mapper/VolGroup-lv_root.


Quote:
Originally Posted by mddesai View Post
In order to boot from the Redhat/CentOS box with grub problems, you need to know 2 things:
  1. The /boot partition, where you can find kernel and initramfs, and
  2. The root (/) partition.

You can find /boot partition, by searching for file grub.conf or menu.lst or stage1 file. Then finding '/' is easy.

Code:
grub> find /grub/stage1
 (hd0,0)

grub> find (hd0,0)/grub/stage1
 (hd0,0)
 (hd0,1)
 (hd0,4)

grub> cat (hd0,0)/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/vda2
#          initrd /initrd-[generic-]version.img
#boot=/dev/vda
.
.

grub> cat (hd0,1)/etc/fstab
# Created by anaconda on Wed Dec  4 15:25:43 2013
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=74cc8471-e9dc-4b29-8c0a-3baa2d5176a5 /                       ext4    defaults        1 1
UUID=590fd42d-6454-4ce5-99c3-52f9f3e1c5e8 /boot                   ext4    defaults        1 2
.
.
Once you find /boot and root (/), booting is easy.
Code:
grub> root (hd0,0)

grub> kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/vda2
OR
grub> kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=UUID=74cc8471-e9dc-4b29-8c0a-3baa2d5176a5

grub> initrd /initramfs-2.6.32-358.el6.x86_64.img

grub> boot
Note: After entering kernel / or initrd /, you can press <TAB> to autofill.
 
Old 12-10-2013, 02:17 PM   #7
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 525

Rep: Reputation: 141Reputation: 141
Quote:
Originally Posted by mgen72 View Post
But I think it's required the file /boot/grub/grub.conf exists. If missing, I don't see how to guess that my root partition is root=/dev/mapper/VolGroup-lv_root.
I also mentioned in the example where you can find root (/), ie., /etc/fstab.

However, the example was for regular partition. So if you have root (/) in LVM, it is not visible/accessible. In that case, what you can do is boot in dracut shell and find where root (/) is.

You can do this in grub> prompt
Code:
grub> find /grub/stage1
 (hd0,0)

grub> root (hd0,0)

grub> kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/abc rdshell

grub> initrd /initramfs-2.6.32-358.el6.x86_64.img

grub> boot
You'll land in rdshell. There do following. This is in my machine.
Code:
# lvm lvscan
  ACTIVE            '/dev/vg/root' [30.00 GiB] inherit
Notedown the root(/) path, reboot the machine, and put the value in root= variable
Code:
grub> find /grub/stage1
 (hd0,0)
grub> root (hd0,0)
grub> kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/vg/root
grub> initrd /initramfs-2.6.32-358.el6.x86_64.img
grub> boot
And then copy grub.conf back from /tmp, if its there, or create new grub.conf file

Last edited by mddnix; 12-10-2013 at 02:20 PM.
 
1 members found this post helpful.
Old 12-10-2013, 02:28 PM   #8
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 525

Rep: Reputation: 141Reputation: 141
If there is no grub.conf file in /boot/grub/, then search for stage1 file, or any file in /boot/grub/ directory.
 
Old 12-15-2013, 11:29 AM   #9
mgen72
LQ Newbie
 
Registered: Dec 2013
Distribution: centos 6
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thank you very much, I thought it was not possible to boot the machine if you didn't know the root partition.

I had wasted some time searching on internet how to fix it before posting the message at Linux Questions.

Again, mddesai, thank you very much.


Quote:
Originally Posted by mddesai View Post
I also mentioned in the example where you can find root (/), ie., /etc/fstab.

However, the example was for regular partition. So if you have root (/) in LVM, it is not visible/accessible. In that case, what you can do is boot in dracut shell and find where root (/) is.

You can do this in grub> prompt
Code:
grub> find /grub/stage1
 (hd0,0)

grub> root (hd0,0)

grub> kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/abc rdshell

grub> initrd /initramfs-2.6.32-358.el6.x86_64.img

grub> boot
You'll land in rdshell. There do following. This is in my machine.
Code:
# lvm lvscan
  ACTIVE            '/dev/vg/root' [30.00 GiB] inherit
Notedown the root(/) path, reboot the machine, and put the value in root= variable
Code:
grub> find /grub/stage1
 (hd0,0)
grub> root (hd0,0)
grub> kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/vg/root
grub> initrd /initramfs-2.6.32-358.el6.x86_64.img
grub> boot
And then copy grub.conf back from /tmp, if its there, or create new grub.conf file
 
Old 12-15-2013, 12:31 PM   #10
TroN-0074
Senior Member
 
Registered: Dec 2011
Location: Michigan USA
Distribution: OpenSUSE 13.2 64bit-Gnome on ASUS U52F
Posts: 1,444

Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
If you enjoy reading here is the GRUB manual http://www.gnu.org/software/grub/manual/

You can download to your computer in PDF format or just read it on a web browser

Last edited by TroN-0074; 12-15-2013 at 12:32 PM.
 
Old 12-15-2013, 12:42 PM   #11
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Debian, Arch
Posts: 1,163
Blog Entries: 7

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
CentOS comes on a live CD/DVD right? Run the live environment, mount the partition(s) with /boot and /tmp. Copy the grub.conf file you copied to /tmp from /tmp back to /boot/grub. Try booting again.
 
Old 12-15-2013, 01:13 PM   #12
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 525

Rep: Reputation: 141Reputation: 141
@mgen72

You're Welcome.
 
  


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
[SOLVED] cant fix missing grub.conf aceone Red Hat 7 12-10-2010 11:32 AM
Missing grub.conf r00tNinj4 Debian 5 06-08-2006 06:02 PM
Missing Grub.conf carlosinfl Debian 4 03-21-2006 05:58 PM
Missing grub.conf & other oddnesses JMCraig Fedora 10 02-25-2005 04:43 PM
grub.conf missing flipboi Fedora 2 02-16-2004 09:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:49 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration