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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
07-11-2012, 11:41 AM
|
#1
|
Member
Registered: Sep 2011
Location: /dev/null
Distribution: ubuntu 64bits
Posts: 135
Rep:
|
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.
|
|
|
07-11-2012, 12:18 PM
|
#2
|
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187
|
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.)
|
|
|
07-11-2012, 04:11 PM
|
#3
|
Member
Registered: Sep 2011
Location: /dev/null
Distribution: ubuntu 64bits
Posts: 135
Original Poster
Rep:
|
Quote:
Originally Posted by PTrenholme
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.
|
|
|
07-12-2012, 03:53 PM
|
#4
|
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187
|
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.)
|
|
|
07-17-2012, 04:22 PM
|
#5
|
Member
Registered: Sep 2011
Location: /dev/null
Distribution: ubuntu 64bits
Posts: 135
Original Poster
Rep:
|
Quote:
Originally Posted by PTrenholme
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,
|
|
|
07-19-2012, 03:41 PM
|
#6
|
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187
|
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.)
|
|
|
All times are GMT -5. The time now is 08:31 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|