LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Passing root path from dhcp to grub2 in a pxe boot (https://www.linuxquestions.org/questions/linux-server-73/passing-root-path-from-dhcp-to-grub2-in-a-pxe-boot-925834/)

hokie92grad 01-26-2012 01:13 PM

Passing root path from dhcp to grub2 in a pxe boot
 
I am trying to setup a RHEL6 x86_64 server to host iscsi root drives for an array of RHEL6 x86_64 diskless clients. I would like to set this up in a way that does not require user intervention to get the clients to boot and each client needs to have its own root device.

The setup:
Each client is using pxe to start the process, which obtains the boot loader image name from dhcp. (grub.pxe from grub version 1.99)
grub is then loading its configuration file and a default item is selected in the menu list to boot a vmlinuz and initramfs that knows how to switch to an iscsi root drive. Currently the grub.cfg file specifies the iscsi root device to load, but this will not work when I have multiple clients trying to use the same grub.cfg file.

I have a few of options 1) setup dhcp to pass the root device information to grub, 2) setup dhcp to pass the config file for grub to load, 3) change the initramfs scripts to load an appropriate iscsi root device based on ip address or some other metric.

Right now I am trying option 1. According to the manual, there are some environment variables available : net_pxe_rootpath and net_pxe_extensionpath, which I believe correspond to the dhcp option root-path and extensions-path. I don't know how to use these environment variables. I tried in what I thought was an obvious way, but it did not work.

Here is the setup:
dhcpd.conf:
host client1
{
next-server 192.168.1.2;
option host-name client1;
hardware ethernet 00:a0:ae:02:b8:8b;
fixed-address 192.168.1.128;
filename "grub.pxe";
option root-path "/dev/mapper/vg_client1-lv_root";
option extensions-path "iscsi:@192.168.1.2::3260::iqn.2011-11.net.foonet:server1.target2.sys2";
}

grub.cfg:
menuentry 'GNU/Linux, 2.6.32-131.0.15.el6.x86_64 pxe client1 env' --class gnu-linux --class gnu --class os {
echo 'Loading Linux 2.6.32-131.0.15.el6.x86_64 ...'
echo "net_pxe_rootpath=${net_pxe_rootpath}"
echo "net_pxe_extensionspath=${net_pxe_extensionspath}"
linux (pxe)/vmlinuz-2.6.32-131.0.15.el6.x86_64 ro root=${net_pxe_rootpath} netroot=${net_pxe_extensionspath} iscsi_initiator=iqn.2011-11.net.foonet:server1.target2.sys2 ip=eth0:dhcp rd_LVM_LV=vg_cleint1/lv_root rd_LVM_LV=vg_client1/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto
echo 'Loading initial ramdisk ...'
initrd (pxe)/initramfs-2.6.32-131.0.15.el6.x86_64.img
}

menuentry 'GNU/Linux, 2.6.32-131.0.15.el6.x86_64 pxe cleint1 root' --class gnu-linux --class gnu --class os {
echo 'Loading Linux 2.6.32-131.0.15.el6.x86_64 ...'
linux (pxe)/vmlinuz-2.6.32-131.0.15.el6.x86_64 ro root=/dev/mapper/vg_client1-lv_root netroot=iscsi:@192.168.1.2::3260::iqn.2011-11.net.foonet:server1.target2.sys2 iscsi_initiator=iqn.2011-11.net.foonet:server1.target2.sys2 ip=eth0:dhcp rd_LVM_LV=vg_client1/lv_root rd_LVM_LV=vg_client1/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto
echo 'Loading initial ramdisk ...'
initrd (pxe)/initramfs-2.6.32-131.0.15.el6.x86_64.img



if I boot from the second menuentry above, the client boots normally. If I boot from the first menu entry above, the kernel panics because it can't find a root to mount. the echo of the net_pxe_rootpath and net_pxe_extensionspath don't show what I was expecting from the dhcp file.
the net_pxe_rootpath is showing a path "/pxe/root/client2" which I think I used at one point in time, but I can't find that string anywhere in any of the config files. (dchp or grub)
the net_pxe_extensionspath is empty.

Is there anyway to pass this type of information over dhcp to grub?

I found some other stuff regarding option 150, but I don't think that was passed either. Not sure if grub2 supports option 150 anymore. (I think it is a grub legacy option only).

hokie92grad 01-26-2012 05:06 PM

Well how embarrasing, I simply forgot to reload the dhcpd configuration everything worked as it was entered.


All times are GMT -5. The time now is 08:05 AM.