📜 ⬆️ ⬇️

iSCSI Target Box

I want to bring to your attention an interesting project iSCSI Target Box - a mini Linux distribution that allows you to quickly deploy an iSCSI server (so-called Target) on any supported hardware.
It is based on Arch Linux and its Mkinitcpio initrd image generation script, which allows you to quickly and easily rebuild it when updating the kernel or other components. In essence, this is the Linux + BusyBox + iSCSI Enterprise Target kernel, packed into the Initrd-image and the necessary configuration files brought out.

Installation


We download a binary image of the system from the site , unpack it into the root of the boot disk (HDD, USB Flash, Memory Card, etc.), install grub (or any other favorite boot manager) and write the Linux kernel in its config:
  title Linux iSCSI Target Box
  root (hd0,0)
  kernel / vmlinuz26 root = / dev / sdb1 ro ip = <this-box-ip> :: <gw-ip>: <netmask> :: eth0: none
  initrd /initrd-iscsi.img

Where / dev / sdb1 is the name of the section in the root of which is the iscsi-target-etc directory with the settings files. And ip = ::: - network settings.
More information about the parameters of the kernel can be found in the documentation for Mkinitcpio

Customization


All tunable settings are located in the iscsi-target-etc directory, which should be located in the root of the partition specified when the kernel loads. When booting the system, the contents of this directory are simply copied to / etc and may contain any Linux environment settings files. If the rc.local file is present in the copied files, then it starts up after copying, thus allowing you to further customize the environment for yourself without rebuilding the system image.
Configuring the iSCSI Enterprise Target daemon is located in the / iscsi-target-etc / iet / directory copied when loaded in / etc / iet / and requires preliminary configuration. For example, we can write these lines in the ietd.conf file:
  Target iqn.2001-04.com.example: storage.disk1.sys1.xyz
 Lun 0 Path = / dev / sda, Type = blockio, ScsiId = xyz, ScsiSN = xyz 

That allows you to share the disk / dev / sda as a block device.

You can also control the daemon dynamically using the ietadm administration utility. For example, create a Target with the command:
ietadm --op new --tid = 1 --params Name = iqn.2001-04.com.example: storage.disk1.sys1.xyz
and add LUN to it:
ietadm --op new --tid = 1 --lun = 0 --params Path = / dev / sda, Type = blockio
Read more about configuring iSCSI Enterprise Target in its documentation.
')
Access to the console is possible either directly or via telnet. The default password is root: 666666
To change the password, simply place the shadow file in the iscsi-target-etc directory with the newly generated password for root, and when the system boots it will overwrite the one that is sewn into the image.

So, as you can see, deploying an iSCSI server for data backup or virtualization systems is easy and takes several minutes. True, the project has just started to develop and therefore in production its use is not recommended yet.

Assembly


All scripts used for building are available in source code under the GPLv2 license. Arch Linux with mkinitcpio and mkinitcpio-nfs-utils packages is required to build the image. You also need to install iSCSI Enterprise Target, which can be taken from AUR - iscsitarget-kernel and iscsitarget-usr or download the latest version of the source code from the official site and compile it manually:
 tar xf iscsitarget-1.4.20.1.tar.gz
 cd iscsitarget-1.4.20.1
 make
 make install

Then we download the archive with source codes from the iSCSI Target Box project site , unpack it into the / lib / initcpio / directory and create a hardlink to the base system installation script:
  ln base-iscsi ../install/base-iscsi 

We generate the image:
  mkinitcpio -c /lib/initcpio/iscsi-target-box/mkinitcpio.conf -g /boot/initrd-iscsi.img 

Quickly check the performance of the assembly using QEMU:
  qemu -snapshot -kernel / boot / vmlinuz26 -initrd /boot/initrd-iscsi.img 

Source: https://habr.com/ru/post/98463/


All Articles