Windows 7 on iSCSI Root/Boot device via gPXE

April 2nd, 2012 By arlinton Categories: System Administration

What is iSCSI?

The SCSI protocol implemented over TCP/IP. It allows for iSCSI targets (servers) to export block/storage devices over the network to iSCSI initiators (client). For more technical details please checkout:

Some RFCs:

What is gPXE?

gPXE is an open-source bootloader that can run from the Pre-eXecution Environment (PXE) as well as be chainloaded from other bootloaders. PXE usually works well on good network boot roms (caution to those who use certain realtek chips). Once loaded gPXE allows the loading of various types of boot code over various protocols. Protocols such as HTTP, AoE (ATA over Ethernet), iSCSI, and more are supported by gPXE. We will be using gPXE to connect to our iSCSI target and use it as a boot device on our iSCSI initiator (client). For a better overview of gPXE, you can read the wikipedia article on gPXE, http://en.wikipedia.org/wiki/GPXE . For more details the gPXE wiki is the best source, http://etherboot.org/wiki/start .

Setting up ISC DHCPd for the iSCSI boot
Before you begin you should know how to configure DHCPd:

The following code will be found in the host section of the dhcpd.conf. It has a conditional that detects if the dhcp client request is coming from gpxe or not. This is required to prevent an infinite boot loop. When the boot rom from the NIC does it’s dhcp client request the options held with the ‘else’ clause will be run. The ‘else’ clause loads the undionly.kpxe file which is obtained from the gPXE package from your respective distribution. Upon the successful load of the undionly.kpxe code into memory, gPXE is executed and then it issues its own dhcp client request. The conditional confirming the existence of ‘user-class and option user-class = “gPXE”‘ sets the root-path and gpxe.keep-san options. These options allow for the binding of the iSCSI target as a boot device.

Keep in mind that the default gateway is configured in windows as the iSCSI target. If you have multiple NICs I would recommend you use an alternate NIC to access your network and the internet. If you’re on a machine with a single NIC setting up ipforwarding and firewall rules are trivial. This must be done on the iSCSI target.

hardware ethernet ff:ff:ff:ff:ff:ff;
fixed-address 192.168.1.100;
next-server 192.168.1.50;
if exists user-class and option user-class = "gPXE" {
  filename "";
  option root-path "iscsi:192.168.1.50::::iqn.2008-07.example.com:target0";
  option gpxe.keep-san 1;
  option routers 192.168.1.50;
} else {
  filename "/undionly.kpxe";
  option routers 192.168.1.1;
}

The following options may be required. I believe they’re optional but if you have any issues put this in the global section of the dhcpd.conf:

# gPXE-specific encapsulated options
option space gpxe;
option gpxe-encap-opts code 175 = encapsulate gpxe;
option gpxe.priority code 1 = signed integer 8;
option gpxe.keep-san code 8 = unsigned integer 8;
option gpxe.no-pxedhcp code 176 = unsigned integer 8;
option gpxe.bus-id code 177 = string;
option gpxe.bios-drive code 189 = unsigned integer 8;
option gpxe.username code 190 = string;
option gpxe.password code 191 = string;
option gpxe.reverse-username code 192 = string;
option gpxe.reverse-password code 193 = string;
option gpxe.version code 235 = string;

# Other options that may be useful
#
option iscsi-initiator-iqn code 203 = string;

Setting up tftpd
If you need to know how to setup tftpd see this:

This is a matter of getting the gPXE bits into your tftpboot root directory. In Fedora 15 the ‘gpxe-bootimgs’ package has all of the binary images. You can download and compile the source from http://etherboot.org/wiki/download .You will need to copy the ‘undionly.kpxe’ to the tftpboot directory.

Setting up a iSCSI Target

I’ve used the netbsd-iscsi target package. The Fedora 15 package name is ‘netbsd-iscsi’ the source is available here, http://pkgsrc.se/devel/netbsd-iscsi-target . Here is a howto on configuring the iSCSI Target: ftp://ftp.netbsd.org/pub/NetBSD/misc/agc/HOWTO-iSCSI-target.txt . Here is a sample of my config, I am using LVM and the volume size is 650GB:

# Simple file showing 1 extent, mapped straight into 1 target

# extents       file                                                   start   length
extent0         /dev/volume_group/logical_volume             0     655360MB

# target        flags   storage         netmask
target0         rw      extent0         192.168.1.100/32

Installing Windows 7
This is an excellent guide on installing Windows over gPXE:

On the machine that will be using the iSCSI have your respective windows installation media. It’s important that you set the CD device to boot after the NIC (remember gPXE sets up the install block device). After gPXE fails to boot your iSCSI target the CD should boot. Proceed with the installation as normal. It’s important that the windows installation has drivers for your NIC or else nothing will work. The windows install should detect the iSCSI drive and you should be able to install to it. At any point during the installation press, Shift+F10, and check the network & status.

Proof of Concept video
Check it out in action, https://www.youtube.com/watch?v=Cnb-Mcq303Q

Tags:

8 Responses to “Windows 7 on iSCSI Root/Boot device via gPXE”

  1. Pantrabd
    June 26th, 2012 at 08:24
    1

    would you please explain how i can setup my iSCSI target to boot from CD and install win 7. I am stuck here and no help found anywhere.

  2. July 25th, 2012 at 07:21
    2

    That is very fascinating, You’re an excessively professional blogger. I’ve joined your feed and stay up for seeking extra of your fantastic post. Additionally, I have shared your site in my social networks

  3. arlinton
    October 1st, 2012 at 18:23
    3

    Sorry for the delay, in response. What is the exact issue you’re encountering? Did you take into account the issue with the boot order? Also finally some BIOSes do have issues with falling back after PXE boot to the next device, could you confirm if this is an issue but loading gPXE on to a USB stick(http://etherboot.org/wiki/removable) – of course you need to have the proper options setup in DHCP still and having the USB stick boot before the CDROM. Feel free to paste the relevant parts of your configuration preferrably using pastebin (http://pastebin.com/).

    Thanks.

  4. arlinton
    October 1st, 2012 at 18:24
    4

    Thanks, I am glad it was helpful. If there are any more cool things I do with this I’ll be sure to update it here.

  5. April 2nd, 2013 at 04:38
    5

    Hi there very nice site!! Man .. Beautiful .. Superb .

    . I will bookmark your web site and take the feeds additionally?
    I’m satisfied to search out a lot of useful information here in the post, we need work out more techniques in this regard, thanks for sharing. . . . . .

  6. Anton
    June 12th, 2013 at 11:16
    6

    Hey there,

    is there also a guide how to make an existing installation iscsi bootable?
    Most pcs are shipped with recovery dvds or even worse with recovery partitions.
    How can I prepare such an installation for iscsi boot before moving an image of the hdd into the san?

  7. arlinton
    June 12th, 2013 at 22:01
    7

    Yes sir. While I haven’t tried it, in theory you can use the dd command (which comes with any good Linux or BSD distro) and dump the existing hard drive into a logical volume or image file (depends on how you’re exporting the iSCSI LUN).

    I would personally go with the logical volume since there’s a lot flexibility.

    HTH
    ~Arlinton

  8. arlinton
    June 13th, 2013 at 09:33
    8

    As for prep, I would try to test using some sort of Virtualization technology. It’s also possible that you may need to create another Hardware Profile within windows so it can behave as if it needs to detect new hardware.

Leave a Comment