LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 07-11-2012, 11:41 AM   #1
masuch
Member
 
Registered: Sep 2011
Location: /dev/null
Distribution: ubuntu 64bits
Posts: 135

Rep: Reputation: 1
Question grub 2 - when / why I need both in grub.cfg ; set root= and search ... --set=root ...


Hi,

Could please somebody explain me what is the difference between commands ?
Quote:
set root=(hdX,gptY)
and
search ... --set=root someuuid
when and why I need to present both commands in the grub.cfg ?

thank you,
kind regards,
M.
 
Old 07-11-2012, 12:18 PM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
The first one (set root=...) tells GRUB where to look for grub.cfg, the second one tells GRUB where (and how) to look for the root file system for the specific OS you're loading.

See info grub2 for more details. (If you've installed the info files - IIRC, Ubuntu and some other distributions do not install them by default.)
 
Old 07-11-2012, 04:11 PM   #3
masuch
Member
 
Registered: Sep 2011
Location: /dev/null
Distribution: ubuntu 64bits
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by PTrenholme View Post
The first one (set root=...) tells GRUB where to look for grub.cfg, the second one tells GRUB where (and how) to look for the root file system for the specific OS you're loading.

See info grub2 for more details. (If you've installed the info files - IIRC, Ubuntu and some other distributions do not install them by default.)
Precisely - set prefix (depends on set root=) tells to grub where to look for grub.cfg.
But WHY in grub.cfg each menuentry contains (I know that does not have to) set root= (in ubuntu generated) if grub.cfg is already loaded (when I am in grub shell prompt in edit mode I mean) ?

(I went through https://wiki.archlinux.org/index.php/GRUB2 manual.) I am looking for more information.
 
Old 07-12-2012, 03:53 PM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
The "root file system for the OS" is not the GRUB2 "root." It is the location, usually "/", that the kernel needs to know in order to start the OS running. On a system with a single OS, those locations are often the same, but not always.

Here's an excerpt from my grub.cfg where you can see that (for that OS) it's on a different drive from the grub.cfg file. (Added comments in red.)
Code:
menuentry 'Fedora 17 (/dev/md127)' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-207d8262-a705-4237-8cc6-f527fb3e34cc' {
        savedefault
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod btrfs
        set root='hd1,msdos6' #This is where the MBR installed by GRUB2 was told to look for load.cfg
        # And the next block is, essentially, a double-check that the root specified has the correct UUID, but it's
        # possible you might want to have load.cfg and grub.cfg on different partitions. 
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos6 --hint-efi=hd1,msdos6 --hint-baremetal=ahci1,msdos6  f52a4cdd-befe-4197-82dc-18a34eacf783
        else
          search --no-floppy --fs-uuid --set=root f52a4cdd-befe-4197-82dc-18a34eacf783
        fi
        echo    'Loading Linux 3.4.4-3.fc17.x86_64 ...'
        # But note here that this OS is booted using a boot image from a different boot directory and UUID
        linux   /bootM/vmlinuz-3.4.4-3.fc17.x86_64 root=UUID=207d8262-a705-4237-8cc6-f527fb3e34cc ro quiet
        echo    'Loading initial ramdisk ...'
        initrd  /bootM/initramfs-3.4.4-3.fc17.x86_64.img
}
(If you're interested, /dev/md127 is a software RAID-1 drive, and /dev/sdb6 is a btrfs partition from which I usually boot. Since btrfs is still somewhat experimental, I can also boot from a USB stick, but that's a different issue.)

The point of all the above is that the GRUB designers wanted to support as many different booting scenarios as possible, so they tried to make as few assumptions as they could. (The "U" in "GRUB" stands for "unified," not "universal," but they wanted to be as "universal" as the technology available would let them be.)
 
Old 07-17-2012, 04:22 PM   #5
masuch
Member
 
Registered: Sep 2011
Location: /dev/null
Distribution: ubuntu 64bits
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by PTrenholme View Post
The "root file system for the OS" is not the GRUB2 "root." It is the location, usually "/", that the kernel needs to know in order to start the OS running. On a system with a single OS, those locations are often the same, but not always.

Here's an excerpt from my grub.cfg where you can see that (for that OS) it's on a different drive from the grub.cfg file. (Added comments in red.)
Code:
menuentry 'Fedora 17 (/dev/md127)' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-207d8262-a705-4237-8cc6-f527fb3e34cc' {
        savedefault
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod btrfs
        set root='hd1,msdos6' #This is where the MBR installed by GRUB2 was told to look for load.cfg
        # And the next block is, essentially, a double-check that the root specified has the correct UUID, but it's
        # possible you might want to have load.cfg and grub.cfg on different partitions. 
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos6 --hint-efi=hd1,msdos6 --hint-baremetal=ahci1,msdos6  f52a4cdd-befe-4197-82dc-18a34eacf783
        else
          search --no-floppy --fs-uuid --set=root f52a4cdd-befe-4197-82dc-18a34eacf783
        fi
        echo    'Loading Linux 3.4.4-3.fc17.x86_64 ...'
        # But note here that this OS is booted using a boot image from a different boot directory and UUID
        linux   /bootM/vmlinuz-3.4.4-3.fc17.x86_64 root=UUID=207d8262-a705-4237-8cc6-f527fb3e34cc ro quiet
        echo    'Loading initial ramdisk ...'
        initrd  /bootM/initramfs-3.4.4-3.fc17.x86_64.img
}
(If you're interested, /dev/md127 is a software RAID-1 drive, and /dev/sdb6 is a btrfs partition from which I usually boot. Since btrfs is still somewhat experimental, I can also boot from a USB stick, but that's a different issue.)

The point of all the above is that the GRUB designers wanted to support as many different booting scenarios as possible, so they tried to make as few assumptions as they could. (The "U" in "GRUB" stands for "unified," not "universal," but they wanted to be as "universal" as the technology available would let them be.)

Hi,

Thanks a lot for explanation and patience - but I am not clear about it :-( and I did not find any load.cfg (or similar to it) file on my ubuntu instance.

In my case I am using similar menuentry for ocz hard drive because proprietary company does not support linux at all - so kernel module does not exist - disk is not recognized in grub - and for that reason I cannot boot my raid0 from grub (not generating by update-grub at all) by "usual way" , but like following:

menuentry " ... exp ... Ubuntu 3.2.0-27 rlraid0ocz[PCEUBU1:raid0ocz] apparmor" --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
gfxmode $linux_gfx_mode
insmod part_gpt
insmod gzio
insmod part_msdos
insmod ext2
insmod raid # fixes software raid boot problem
insmod mdraid
insmod mdraid1x
insmod mdraid09
set root='(hd2,msdos5)'
#set root='(hd1,gpt6)'
#set root='(/dev/md/PCEUBU1:raid0ocz)'
search --no-floppy --fs-uuid --set=root ff504cbf-0446-4de6-a61b-65cc066dd9b7
#search --no-floppy --fs-uuid --set=root /dev/md/PCEUBU1:raid0ocz
linux /boot/vmlinuz-3.2.0-27-generic root=UUID=20b7653b-199d-4565-821e-dda9ac0383e2 ro vga=799 $vt_handoff apparmor=1 security=apparmor crashkernel=384M-2G:64M,2G-:128M initcall_debug printk.time=y bootchart=disable verbose elevator=noop
#init=/sbin/bootchartd rdinitrd=/sbin/bootchartd
initrd /boot/initrd.img-3.2.0-27-generic
}

so ,grub is taken from different disk - MBR than OS instance - GPT is running from.
(But in some cases I do not need to have set root=() - which I prefer - reason:it is more independent when reordering /dev/sdXY - which happened to me very often. - especially boot from external usb hard disk / usb pendrive, mc card , ...)
(I have never seen --hint-bios and --hint-efi - something new :-) - is it for fedora grub specific ?

Regards,
 
Old 07-19-2012, 03:41 PM   #6
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Not exactly. Fedora 17 uses GRUB 2.0.0.37.beta6; Ubuntu uses GRUB 1.99.21ubuntu3.1 (in my Ubuntu 12.04 virtual system, updated today). I suspect that the beta version of the 2.0 release is at least slightly different from the older 1.99 version that Ubuntu modified for their last release. (And I have no idea what the Ubuntu developers might have modified in the pre-release version 1.99 of GRUB 2 for their system. I suppose I could look at the source code, but I don't feel like doing that.)
 
  


Reply

Tags
difference, grub 2, root, set



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] Grub can't find grub.cfg when booting - error: no such device Breagha Linux - Software 8 03-14-2010 12:40 PM
grub not seeing grub-set-default change bic Linux - Software 4 02-15-2008 01:44 PM
How to set Grub not to auto boot any OS without Grub Boot menu shown ussr_1991 Linux - Software 2 09-01-2007 08:36 AM
change Root Password even if the password in the grub is also set sheelnidhi Linux - General 6 08-30-2006 07:27 AM

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

All times are GMT -5. The time now is 10:44 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
Open Source Consulting | Domain Registration