Target
Start target
/etc/init.d/target
Checking
tree -L 4 /sys/kernel/config/target | less
Initiator
Install
apt-get install open-iscsi
Checking
iscsiadm -V
iscsiadm version 2.0-873
Service
/etc/init.d/open-iscsi start
Checking
ps aux | grep iscsid
root 8709 0.0 0.2 2908 1464 ? Ss 16:53 0:00 /usr/sbin/iscsid root 8710 0.0 0.6 3392 3260 ? S<Ls 16:53 0:00 /usr/sbin/iscsid
After iscsi installation
Before you reboot, we have a few more steps to complete.
!!! DO NOT REBOOT !!!
[0] 補救不小心 reboot
如果不小心 reboot 了, 就要改 VM 的 XML 用 Harddisk boot 先
<os> <boot dev='network'/> </os>
改成
<os>
<boot dev='hd'/>
</os>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/home/pxe/iscsi/u16.img'/>
<blockio logical_block_size='512' physical_block_size='4096'/>
</disk>
[1] 更新 Mirror
/etc/apt/sources.list
:%s/192.168.123.10/hk.archive.ubuntu.com/g
[2] Install 常用 Package
apt-get install openssh-server screen vim
/etc/ssh/sshd_config
PermitRootLogin yes
service sshd restart
[3] 修正 grub
/etc/default/grub
# GRUB_CMDLINE_LINUX_DEFAULT="splash quiet" GRUB_CMDLINE_LINUX_DEFAULT="ip=dhcp ISCSI_INITIATOR=iqn.? ISCSI_TARGET_NAME=iqn.? ISCSI_TARGET_IP=192.168.123.10 quiet"
Other Setting
ISCSI_TARGET_PORT=3260 ISCSI_USERNAME=<username> ISCSI_PASSWORD=<password>
update-grub
[4] OS 設定 iscsi
apt-get install initramfs-tools open-iscsi
echo "iscsi" >> /etc/initramfs-tools/modules
echo "InitiatorName=iqn.?" > /etc/iscsi/initiatorname.iscsi
# mechanism for iscsi-booting (Debian)
# 在 /usr/share/initramfs-tools/hooks/iscsi
/etc/iscsi/iscsi.initramfs
ISCSI_TARGET_NAME="iqn.?" ISCSI_TARGET_IP="192.168.123.10" ISCSI_TARGET_PORT="3260" ISCSI_TARGET_GROUP="1"
update-initramfs -u
[5] 設定 NIC 不再行 DHCP 拎 IP
# If the networking systems try to renegotiate an IP address,
# our connection to the iSCSI device will be lost
/etc/network
# Ensure the OS does not try to reconfigure the interface later # dhcp --> manual auto eth0 iface eth0 inet manual
swap on file
https://datahunter.org/dphys-swapfile