Not sure if this is still something of interest but for the sake of future googlers like myself:
There are two separate root
directories in play when booting/installing from grub. There is the grub root and the linux root (I'm not sure if this is the technical term).
The grub root can be set within the grub.cfg
, and determines which files are readily visible within grub. The default grub root should be the root directory of the drive booting grub, so if the contents of your bootable drive are:
/boot/
/boot/grub2/
/boot/grub2/grub.cfg
...
Then the location of the grub.cfg from the grub root is /boot/grub2/grub.cfg
The grub root can be changed in the grub.cfg using set root=
.
You can use this to set the root to a directory within the current root (set root=/boot/
would cause the grub.cfg
to be located at /grub2/grub.cfg
) which behaves similar to a chroot
in Linux.
You can also change the current root to another drive (set root=(hd0,1)
would set your root to hd0, partition 1. For a full listing of what devices you can use, see the grub page about it http://www.gnu.org/software/grub/manual/grub.html#Device-syntax).
While changing the grub root can be useful, you can also prefix any path with whatever you were going to use (e.x. linux (hd0,1):/boot/OS/RHEL/isolinux/vmlinuz
instead of set root=(hd0,1)
first). Also, once the kernel starts the grub root is irrelevant
As for the Linux root, that is a parameter you can pass the kernel (vmlinuz) when you load it. For this you can pass the kernel a parameter root=
(this value will appear in /proc/cmdline)
However it's important to note that this new root is expected to contain a Linux root filesystem (looking for /etc/ /var/ and so on). When installing you provide the initrd (INITial Ram Disk) which contains these elements, so you probably don't want/need to change the Linux root during installation.
If you do change the Linux root be wary that Linux installation media is not a Linux root filesystem, though the initrd.img contained within is.
If what you're trying to do is use files within your iso as arguments to your kernel then there is a solution. If you create a loopback device in grub the device will persist when the kernel starts (so you should see a device called /dev/loop0
in the Linux root during installation)
I'll give a little snippet of a grub.cfg that relates to ISOs and RHEL specifically:
menuentry "RHEL" {
set isofile='/boot/iso/RHEL.iso' #this is just a grub variable
loopback loop $isofile #mount the $isofile with label=loop as a loopback device
set root=(loop) #set the grub root to the mounted iso (so / is the top level directory in the iso)
#this starts the kernel and passes the paramter inst.stage2 using the ISO and kickstart as a location on the loopback device created by grub (the syntax for this line is liable to change between distros)
linux /isolinux/vmlinuz noeject inst.ks=hd:/dev/loop0:/ks/ks.cfg inst.stage2=hd:LABEL=USBDRIVELABEL:/$isofile
initrd /isolinux/initrd.img #provide an initial ramdisk (which will become the **Linux root**
}
Be aware that the syntax for the kernel line in grub.cfg is:
linux [path to kernel] [kernel argument 1] [kernel argument 2] ...
The kernel arguments will all appear in /proc/cmdline
. It's important to note that because they are processed by the kernel grub syntax is not valid.
You can find more about this in the grub documentation (http://www.gnu.org/software/grub/manual/grub.html#Introduction)
and kernel parameters archwiki page (https://wiki.archlinux.org/index.php/kernel_parameters#GRUB)
as well as boot options for your relevant distro (RHEL https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/chap-anaconda-boot-options.html#list-boot-options-sources)