SAN Boot Linux ( iSCSI )
So I built this PXE server to eliminate my need for CD/DVD base installation media. That got me to thinking about SAN boot and how I could eliminate the need for a physical hard drive on some of my physical computers. I knew of 2 SAN boot options, Fiber Channel and iSCSI. I definitely can't afford the equipment necessary for Fiber Channel, so iSCSI was my choice. Here is how I installed and boot Ubuntu and CentOS using an iSCSI target disk.
Build the iSCSI Target Server
First make a virtual disk. I am putting my iscsi disk images in /tftpboot/iscsi. The command below will make a 20GB virtual disk IMG:
sudo dd if=/dev/zero of=/tftpboot/iscsi/centos.img bs=1M count=20000
Next, install and enable the iSCSI target software:
sudo apt-get install iscsitarget sudo nano /etc/default/iscsitarget
make the following change
Change ISCSITARGET_ENABLE=false To ISCSITARGET_ENABLE=true
Next we will define our iSCSI share. Everything in this file should be commented out. If for some reason it isn't, comment everything and put your own information using the following template. You can include more than one target, I have included both my centos.img and ubuntu.img
sudo nano /etc/iet/ietd.conf
Target iqn.2014-06.com.it-joe:centos-server IncomingUser <username> <password> ##Leave blank if you want no authentication OutgoingUser Lun 0 Path=/tftpboot/iscsi/centos.img,Type=fileio Alias centos-server Target iqn.2014-06.com.it-joe:ubuntu-desktop IncomingUser <username> <password> ##Leave blank if you want no authentication OutgoingUser Lun 0 Path=/tftpboot/iscsi/ubuntu.img,Type=fileio Alias ubuntu-desktop
Now you should be ready to start the iSCSI Target Server:
sudo /etc/init.d/iscsitarget start
Installing an OS on iSCSI target disk
I am going to fork these off because each OS installation is different. Choose your operating system by clicking on the tab
Ubuntu doesn't come prepackaged with an iSCSI intiator. Because of this, there are a few extra steps to install and PXE boot an Ubuntu iSCSI drive. Nevertheless, it can be done, and here is how to do it.
First, boot to an Ubuntu LiveCD. I am using Ubuntu 13.04 that I set up to PXE boot in my PXE Server tutorial. Once your booted to the desktop we need to install open-iscsi and discover our iSCSI target disk that we created above.
Install and start open-iscsi
sudo su apt-get install open-iscsi /etc/init.d/open-iscsi start
Discover and connect to your iSCSI target
iscsiadm -m discovery -t st -p 192.168.0.50 iscsiadm -m node --targetname "iqn.2014-06.com.it-joe:ubuntu-desktop" --portal "192.168.0.50:3260" --login
Run fdisk to confirm your disk is connected
Now that Ubuntu can see our iSCSI target disk, we can proceed with the install as we normally would. When you get to the screen below, DO NOT REBOOT.
Next we need to install a few packages on our new installation. How do we do this without booting to our new installation? Simple, by using “chroot”. chroot basically changes our working root ( / ) directory. By using chroot we have direct access to the file system of our new installation and any changes will effect it as if we were booted directly to it.
sudo su mkdir /mnt/temp mount /dev/sda1 /mnt/temp chroot /mnt/temp mount -t proc none /proc echo "nameserver 192.168.0.1" >> /etc/resolv.conf hostname ubuntu apt-get install initramfs-tools open-iscsi sysv-rc-conf echo "iscsi" >> /etc/initramfs-tools/modules echo "InitiatorName=iqn.2014-06.com.it-joe:ubuntu-client1" > /etc/iscsi/initiatorname.iscsi touch /etc/iscsi/iscsi.initramfs update-initramfs -u
Edit the /etc/fstab file to use /dev/sda1 rather than UUID for root
Look for a line similar to:
UUID=5c0bd3d6-b43b-48d4-ac82-cc9b364f4544 / ext4 errors=remount-ro 0 1
/dev/sda1 / ext4 errors=remount-ro 0 1
Make sure /etc/network/interfaces has the following lines
auto eth0 iface eth0 inet manual
Copy the vmlinuz and initrd.img files to your PXE server
scp /boot/initrd.img-3.8.0-19-generic /boot/vmlinuz-3.8.0-19-generic firstname.lastname@example.org:/tftpboot/iscsi/
At this point we should have everthing we need to get our PXE server setup. Just add an entry similar to the one below to your pxelinux.cfg/default file
LABEL Ubuntu KERNEL iscsi/vmlinuz-3.8.0-19-generic APPEND initrd=iscsi/initrd.img-3.8.0-19-generic ip=dhcp ISCSI_INITIATOR=iqn.2014-06.com.it-joe:ubuntu-client1 ISCSI_TARGET_NAME=iqn.2014-06.com.it-joe:ubuntu-desktop ISCSI_TARGET_IP=192.168.0.50 ISCSI_TARGET_PORT=3260 root=/dev/sda1 rw
The LABEL can be what ever you would like. The KERNEL line just needs to be the path to the vmlinuz file (relative to the tftp server /). The APPEND line needs to be initrd=“the path to the initrd.img” and the reset is copied directly from the kernel line in the grub.conf file we transfered earlier