Sunday, October 16, 2016

boot up a diskless ubuntu using iscsi with ixpe

***setup information
- iscsi target ip: 192.168.56.43

1- configure iscsi target server following the following link
http://www.atechnote.com/2016/10/configrue-iscsi-target-and-initiator-on.html

2- up setup a ubuntu os to the disk that diskless client will boot from, there are two method,

- method 1
install os to it manually

-method 2, if you already have install os on vmware machine,
copy it from vmware machine to the  iscsi disk
    for example i have yakkety.vmdk
*- mount vmware disk
$ mkdir yakdir
$ sudo vmware-mount yakkety.vmdk 1 yakdir

*- connect to iscsi server
$ sudo iscsiadm -m discovery -t st -p 192.168.56.43
$ sudo iscsiadm -m node --login -p 192.168.56.43


*- use fdisk to partition it to 3 partition, primary 1, extended 2 and logical 5

*- if you have one disk, the iscsi will initialize disk to /dev/sdb, or you can read /var/log/syslog for sure

*- format it to ext4 file system
$ sudo mkfs.ext4 /dev/sdb1

*-mount and copy content from yakkety.vmdk to it
$ sudo mount /dev/sdb1 /mnt
$ sudo rsync -avhPHAXx yakdir/* /mnt/

3- install grub to it,
$ sudo grub-install --target=i386-pc --boot-directory=mnt/boot /dev/sdb

4- prepare grub and initramfs to boot with iscsi
$ sudo mount --bind /dev /mnt/dev
$ sudo chroot /mnt
$ mount none -t proc /proc
$ mount none -t sysfs /sys
$ mount none -t devpts /dev/pts

$ echo "InitiatorName=iqn.2008-09.test.domain1:siscsi.target5client " > /etc/iscsi/initiatorname.iscsi

- add the following lines to  /etc/default/grub  (only two lines)
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="ISCSI_INITIATOR=iqn.2008-09.test.domain1:siscsi.target5client ISCSI_TARGET_NAME=iqn.2008-09.test.domain1:siscsi.target5 ISCSI_TARGET_IP=192.168.56.43 ISCSI_TARGET_PORT=3260 root=/dev/sda1 ip=dhcp"


- update fstab to the following content
/dev/sda1 / ext4 defaults 0 0
/dev/sda5 none swap defaults 0 0


$ update-grub
$ update-initramfs -u 
$ umount /proc
$ umount /sys
$ umount /dev/pts
$ exit
$ umount /mnt/dev
$ umount /mnt

5- prepare xpe and ixpe
- create script call start.sh with the following content
#/bin/bash
dnsmasq --dhcp-range=192.168.56.100,192.168.56.200 \
    --dhcp-boot=ipxe.pxe \
    --enable-tftp --tftp-root=/home/user1/ipxe/ -d -p0 -K --log-dhcp --bootp-dynamic


- install ixpe and copy it to /home/user1/ipxe/
$ sudo apt-get install ipxe 
$ cp  /usr/lib/ipxe/ipxe.pxe /home/user1/ipxe/ 

6- start it pxe, dhcp, tftp server,
$ sudo sh start.sh

7- how create can boot from network ,
- to drop to ipxe shell press ctrl+B (also shown on the screen, if you configure correctly)

- in ixpe shell

*- configure ip
ipxe> ifconf  

*- show ip
ipxe> show net0/ip

*- boot from iscsi
ipxe> sanboot iscsi:192.168.56.43:::1:iqn.2008-09.test.domain1:siscsi.target5

***note the sanboot syntax
 iscsi:<servername>:<protocol>:<port>:<LUN>:<targetname>


after a moment it will boot into the system and the disk is store on remote server (iscsi target)

the iscsi disk seem transparent to client, but can see iscsi initiate with dmesg

-snapshot of dmesg on client







No comments:

Post a Comment