Ceci est une ancienne révision du document !
Le protocole iSCSI permet à un hôte d'offrir un espace disque (du mode bloc) à un hôte distant.
Linux/Debian intègre dans la Squeeze (version 6.0.4) tout ce qui permet d'accéder à des volumes iSCSI ou de les créer.
De mon expérience (près de 5 ans sur iSCSItarget et un 1 et demi mois sur TGT), j'aurai tendance à préférer iSCSItarget. Le principal avantage de TGT réside dans son absence de module noyau et donc facile implantation sur un serveur, mais il a un problème de taille : impossible de retirer un volume déclaré !
Sur un noyau rétro-porté (3.2.0), il est nécessaire de rétroporté le paquet iSCSItarget de la Sid, de le compiler et l'installer. Là, le module doit impérativement installé avec DKMS.
Il est supposé que la machine MyHost dispose d'une infrastructure LVM :
lvcreate -L 20G -n MyLViSCSI MyVG
mkfs.ext3 -m 0 /dev/MyVG/MyLViSCSI
mkdir /media/MyLViSCSI mount -o noatime /dev/MyVG/MyLViSCSI /media/MyLViSCSI
e2label /dev/MyVG/MyLViSCSI MyLViSCSI
# pour une architecture x86_64 debootstrap --arch amd64 wheezy /media/MyLViSCSI http://ftp.fr.debian.org/debian # pour une architecture i386 debootstrap --arch i386 wheezy /media/MyLViSCSI http://ftp.fr.debian.org/debian
chroot /media/MyLViSCSI
tee /etc/apt/sources.list <<EOF deb http://ftp2.fr.debian.org/debian/ wheezy main contrib non-free deb-src http://ftp2.fr.debian.org/debian/ sid main contrib non-free deb-src http://ftp2.fr.debian.org/debian/ experimental main contrib non-free deb http://security.debian.org/ wheezy/updates main contrib non-free deb-src http://security.debian.org/ wheezy/updates main contrib non-free EOF
mount -t proc none /proc
passwd
apt-get -y install dhcp3-common openssh-server locales initramfs-tools dhcp3-client aufs-tools firmware-linux-nonfree firmware-linux firmware-bnx2 open-iscsi iftop htop iotop emacs mtr lsof tshark mbw memtest86 cpuburn bonnie dbench iozone3 console-setup less && apt-get clean # Pour les architectures i686 apt-get -t squeeze-backports -y install linux-image-3.2.0-4-686-pae # Pour les architectures x86_64 apt-get -t squeeze-backports -y install linux-image-3.2.0-4-amd64
insserv -r open-iscsi
touch /etc/iscsi/iscsi.initramfs update-initramfs -k all -u
lsinitramfs /boot/initrd.img-* | grep “local-top/iscsi”
retourne : scripts/local-top/iscsi scripts/local-top/iscsi
sed -i "s/DEVICE\=/DEVICE\=eth0/g" /etc/initramfs-tools/initramfs.conf
rm /etc/hostname
tee /etc/network/interfaces <<EOF auto lo iface lo inet loopback EOF
apt-get install ssmtp
/etc/init.d/dbus stop
/proc
umount /proc
exit
cp /media/MyLViSCSI/boot/initrd.img-3.2.0-4-686-pae /root/initrd.img-3.2.0-4-686-pae-iSCSI cp /media/MyLViSCSI/boot/vmlinuz-3.2.0-4-686-pae /root/vmlinuz-3.2.0-4-686-pae-iSCSI cp /media/MyLViSCSI/boot/initrd.img-3.2.0-4-amd64 /root/initrd.img-3.2.0-4-amd64-iSCSI cp /media/MyLViSCSI/boot/vmlinuz-3.2.0-4-amd64 /root/vmlinuz-3.2.0-4-amd64-iSCSI
mkdir /media/MyLViSCSI/root/.ssh cp -a /root/.ssh/authorized_keys /media/MyLViSCSI/root/.ssh/
umount /media/MyLViSCSI
# Le serveur TFTP/PXE est MyPXE : scp /root/*iSCSI PyPXE:/srv/tftp
iqn.2012-04.MySite.MyHost:MyLViSCSI
inputname
MyInputPwd
/dev/MyVG/MyLViSCSI
# Renommage de l'ancien fichier de configuration cp /etc/iet/ietd.conf /etc/iet/ietd.conf-$(date +%Y%m%d) # Ajout de l'entree précedente tee -a /etc/iet/ietd.conf <<EOF Target iqn.2013-06.MySite.MyHost:MyLViSCSI IncomingUser inputname MyInputPwd Lun 0 Path=/dev/MyVG/MyLViSCSI,BlockSize=4096,Type=fileio EOF
ietadm --op new --tid=86 --params Name=iqn.2013-06.MySite.MyHost:MyLViSCSI ietadm --op new --tid=86 --lun=0 --params Path=/dev/MyVG/MyLViSCSI,BlockSize=4096,Type=fileio ietadm --op new --tid=86 --lun=0 --user --params IncomingUser=inputname,Password=MyInputPwd
cat /proc/net/iet/volume | grep MyLViSCSI
cat /proc/net/iet/volume | grep MyLViSCSI tid:86 name:iqn.2013-03.MySite.MyHost:MyLViSCSI lun:0 state:0 iotype:fileio iomode:wt blocks:5242880 blocksize:4096 path:/dev/MyVG/MyLViSCSI
/srv/tftp
, maintenant cd /srv/tftp/pxelinux.cfg
ISCSI_TARGET_NAME
: IQNISCSI_TARGET_IP
: hôte de cibles iSCSIISCSI_INITIATOR
: IQN ISCSI_USERNAME
: identifiantISCSI_PASSWORD
: mot de passeISCSI_TARGET_GROUP
: groupe, généralement 1tee iscsi <<EOF DEFAULT linux64 LABEL linux64 KERNEL vmlinuz-3.2.0-4-amd64-iSCSI APPEND console=tty1 initrd=initrd.img-3.2.0-4-amd64-iSCSI ip=dhcp rw ISCSI_TARGET_NAME=iqn.2013-06.MySite.MyHost:MyLViSCSI ISCSI_TARGET_IP=MyHost ISCSI_INITIATOR=iqn.2013-06.MySite.MyHost:default ISCSI_USERNAME=inputname ISCSI_TARGET_GROUP=1 ISCSI_PASSWORD=MyInputPwd root=LABEL=MyLViSCSI rootflags=data=journal LABEL linux64 KERNEL vmlinuz-3.2.0-4-686-pae-iSCSI APPEND console=tty1 initrd=initrd.img-3.2.0-4-686-pae-iSCSI ip=dhcp rw ISCSI_TARGET_NAME=iqn.2013-06.MySite.MyHost:MyLViSCSI ISCSI_TARGET_IP=MyHost ISCSI_INITIATOR=iqn.2013-06.MySite.MyHost:default ISCSI_USERNAME=inputname ISCSI_TARGET_GROUP=1 ISCSI_PASSWORD=MyInputPwd root=LABEL=MyLViSCSI rootflags=data=journal EOF
00:AA:BB:CC:DD:EE
doit être écrite sous la forme 01-00-AA-BB-CC-DD-EE</note>ln -sf iscsi 01-00-AA-BB-CC-DD-EE
— Emmanuel Quemener 2013/06/13 06:05