Difference between revisions of "ISCSI/Boot"

From ArchWiki
Jump to navigation Jump to search
Line 20: Line 20:
 
== Client / Initiator Setup ==
 
== Client / Initiator Setup ==
  
=== Install over iSCSI ===
+
=== Overview ===
 +
1. install {{Pkg|open-iscsi}} package in installer system
  
Download Arch Linux ISO image [https://www.archlinux.org/download/] and boot Arch Linux using the ISO image.  After Arch Linux is booted, either use net as the install source or manually ifconfig and dhcp.
+
2. connect to iSCSI target and create partitions on logical drive of target.
  
Now before you continue to "Prepare Hard Drive(s)" install open-iscsi and connect to target.
+
3. install Arch Linux system in usual way
  
Be sure to your servers IP address, Name, etc.
+
4. install {{Pkg|open-iscsi}} package in installed system
  
<pre>
+
5. create initial RAM disk image containing open-iscsi modules.
wget https://aur.archlinux.org/packages/op/open-iscsi/open-iscsi.tar.gz
 
  
tar xzvf open-iscsi.tar.gz
+
=== Install over iSCSI ===
  
cd open-iscsi
+
Download Arch Linux ISO image [https://www.archlinux.org/download/] and boot Arch Linux using the ISO image.  After Arch Linux is booted, either use net as the install source or manually ifconfig and dhcp.
  
pacman -Sy
+
Before you continue to "Partition the disks", [[pacman|install]] the {{Pkg|open-iscsi}} package from the [[official repositories]] and connect to target.
  
pacman -S patch make gcc
+
In the following, server's(target's) IP address is 192.168.1.100, client's(initiator's) IP address is 192.168.2.101, iSCSI initiator name is "iSCSI.Initiator.Name" and target name is "iSCSI.Target.Name". You should, of course, be sure to your network configration and so on.
 
 
makepkg --asroot
 
 
 
pacman -U open-iscsi...pkg.tar.xz
 
  
 +
<pre>
 +
pacman -Sy
 +
pacman -S open-iscsi
 
modprobe iscsi_tcp
 
modprobe iscsi_tcp
 
+
iscsistart -i iSCSI.Initiator.Name -t iSCSI.Target.Name -g 1 -a 192.168.1.100
iscsistart -i iqn.2010-06.ClientName:desc -t iqn.2010-06.ServerName:desc -g 1 -a 192.168.1.100
 
 
</pre>
 
</pre>
  
During the above procedures, if "pacman -Sy" asks you to upgrade pacman, answer "no" otherwise pacman may fail to install patch, make, and gcc, which are essential to the compilation of the open-iscsi source.
+
Now your local host connects to the drive of target host (see dmesg output). You can create a partition table and partitions in the same way as a local drive.
  
 
(Optional) If you want to make sure that your iSCSI target is up and running, you may start "iscsid" and check whether the iSCSI target is available.
 
(Optional) If you want to make sure that your iSCSI target is up and running, you may start "iscsid" and check whether the iSCSI target is available.
Line 54: Line 52:
 
<pre>
 
<pre>
 
# iscsid
 
# iscsid
# iscsiadm -m discovery -t sendtargets -p <server-IP>
+
# iscsiadm -m discovery -t sendtargets -p 192.168.1.100
 
</pre>
 
</pre>
  
Continue to prepare the hard drive, using the iSCSI target drive.  It is suggested that you manually create a partition that uses the entire iSCSI target drive.
 
 
{{Note|When you "Manually Configure block devices, filesystems and mountpoints" make sure that you use '''UUID'''. This way there won't be any issues booting if the number of devices changes (/dev/sda /dev/sdb ...) by adding or removing hard drives, usb thumb drives, etc... or booting it on different machines.}}
 
 
{{Note|It is recommended that you '''NOT''' include swap on the iSCSI drive when creating the partitions, you can just '''ignore''' the warning.}}
 
{{Note|It is recommended that you '''NOT''' include swap on the iSCSI drive when creating the partitions, you can just '''ignore''' the warning.}}
  
Before you "Configure System" you must install open-iscsi to the "future" root filesystem, and download and install the hook for booting from iSCSI.  This should be done after all selected packages are installed.
+
Next, before doing [[mkinitcpio]] in the "future" root file system, you have to prepare the following two files and have to install {{Pkg|open-iscsi}} package.
 
 
Create these hook files, replacing the IP, etc.  You may create these hook files after open-iscsi is installed to the "future" filesystem.
 
  
 
1. /mnt/usr/lib/initcpio/install/iscsi: It should look like the following.
 
1. /mnt/usr/lib/initcpio/install/iscsi: It should look like the following.
  
 
<pre>
 
<pre>
# vim: set ft=sh:
 
 
 
build ()
 
build ()
 
{
 
{
Line 94: Line 85:
  
 
<pre>
 
<pre>
# vim: set ft=sh:
 
 
 
run_hook ()
 
run_hook ()
 
{
 
{
Line 101: Line 90:
 
     ifconfig eth0 192.168.1.101 netmask 255.255.255.0 broadcast 192.168.1.255
 
     ifconfig eth0 192.168.1.101 netmask 255.255.255.0 broadcast 192.168.1.255
 
     sleep 10
 
     sleep 10
     iscsistart -i iqn.2010-06.ClientName:desc -t iqn.2010-06.ServerName:desc -g 1 -a 192.168.1.100
+
     iscsistart -i iSCSI.Initiator.Name -t iSCSI.Target.Name -g 1 -a 192.168.1.100
 
}
 
}
 
</pre>
 
</pre>
Line 107: Line 96:
 
If you want to use dhcp for the above script, you may try to replace the "ifconfig" line with "dhcpcd eth0", but make sure that dhcpcd is installed.
 
If you want to use dhcp for the above script, you may try to replace the "ifconfig" line with "dhcpcd eth0", but make sure that dhcpcd is installed.
  
Now, you can install open-iscsi into the "future" root filesystem.
+
[[pacman|Install]] the {{Pkg|open-iscsi}} package in the "future" root file system. Of cource, you have to set up and bring up network interface of "future" system previously.
  
 
<pre>
 
<pre>
mv open-iscsi...pkg.tar.xz /mnt/root
+
pacman -Sy
 
+
pacman -S open-iscsi
chroot /mnt/ /bin/bash
 
 
 
cd /root/
 
 
 
pacman -U open-iscsi...pkg.tar.xz
 
 
</pre>
 
</pre>
  
Now you can create the above hook files by pasting the above scripts.
+
Add "iscsi" to the HOOKS line in [[mkinitcpio|/etc/mkinitcpio.conf]] and run "mkinitcpio -p linux". A new initial RAM disk(initramfs) will be generated.
 
 
<pre>
 
nano /lib/initcpio/install/iscsi
 
 
 
nano /lib/initcpio/hooks/iscsi
 
 
 
exit
 
</pre>
 
 
 
Now you are ready to "Configure System."  Most of the configuration files can remain unchanged.
 
 
 
Add "iscsi" to the HOOKS in /etc/mkinitcpio.conf.  The "mkinitcpio" will generate a new kernel image after you are done with "Configure System."
 
  
 
{{Note|If you plan on booting this installation of Arch on machines with nic cards that require different modules, remove "autodetect" from HOOKS}}
 
{{Note|If you plan on booting this installation of Arch on machines with nic cards that require different modules, remove "autodetect" from HOOKS}}
 
{{Note|Rebuilding the initial ramdisk will take some time if autodetect is removed from HOOKS}}
 
{{Note|Rebuilding the initial ramdisk will take some time if autodetect is removed from HOOKS}}
  
When configuring grub find the lines for Arch that are
+
Now your new system can mount the file systems from iSCSI target drive after reboot.
 
 
<pre>root (hdX,0)</pre>
 
and change to
 
<pre>root (hd0,0)</pre>
 
  
 
== Troubleshooting ==
 
== Troubleshooting ==

Revision as of 02:16, 27 December 2014

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:ISCSI/Boot#)

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: The actual boot will use an extra drive / usb drive or pxe boot? (Discuss in Talk:ISCSI/Boot#)

You can install Arch on an iSCSI Target. This howto will guide you through the process.

Server / Target Setup

You can set up an iSCSI target with any hosting server OS. Follow the procedure outlined in iSCSI Target if you use Arch Linux as the hosting server OS.

Client / Initiator Setup

Overview

1. install open-iscsi package in installer system

2. connect to iSCSI target and create partitions on logical drive of target.

3. install Arch Linux system in usual way

4. install open-iscsi package in installed system

5. create initial RAM disk image containing open-iscsi modules.

Install over iSCSI

Download Arch Linux ISO image [1] and boot Arch Linux using the ISO image. After Arch Linux is booted, either use net as the install source or manually ifconfig and dhcp.

Before you continue to "Partition the disks", install the open-iscsi package from the official repositories and connect to target.

In the following, server's(target's) IP address is 192.168.1.100, client's(initiator's) IP address is 192.168.2.101, iSCSI initiator name is "iSCSI.Initiator.Name" and target name is "iSCSI.Target.Name". You should, of course, be sure to your network configration and so on.

pacman -Sy
pacman -S open-iscsi
modprobe iscsi_tcp
iscsistart -i iSCSI.Initiator.Name -t iSCSI.Target.Name -g 1 -a 192.168.1.100

Now your local host connects to the drive of target host (see dmesg output). You can create a partition table and partitions in the same way as a local drive.

(Optional) If you want to make sure that your iSCSI target is up and running, you may start "iscsid" and check whether the iSCSI target is available.

# iscsid
# iscsiadm -m discovery -t sendtargets -p 192.168.1.100
Note: It is recommended that you NOT include swap on the iSCSI drive when creating the partitions, you can just ignore the warning.

Next, before doing mkinitcpio in the "future" root file system, you have to prepare the following two files and have to install open-iscsi package.

1. /mnt/usr/lib/initcpio/install/iscsi: It should look like the following.

build ()
{
    local mod
    for mod in iscsi_tcp libiscsi libiscsi_tcp scsi_transport_iscsi crc32c; do
        add_module "$mod"
    done

    add_checked_modules "/drivers/net"
    add_binary "/usr/bin/iscsistart"
    add_runscript
}

help ()
{
cat <<HELPEOF
  This hook allows you to boot from an iSCSI target.
HELPEOF
}

2. /mnt/usr/lib/initcpio/hooks/iscsi: It should look like the following.

run_hook ()
{
    modprobe iscsi_tcp
    ifconfig eth0 192.168.1.101 netmask 255.255.255.0 broadcast 192.168.1.255
    sleep 10
    iscsistart -i iSCSI.Initiator.Name -t iSCSI.Target.Name -g 1 -a 192.168.1.100
}

If you want to use dhcp for the above script, you may try to replace the "ifconfig" line with "dhcpcd eth0", but make sure that dhcpcd is installed.

Install the open-iscsi package in the "future" root file system. Of cource, you have to set up and bring up network interface of "future" system previously.

pacman -Sy
pacman -S open-iscsi

Add "iscsi" to the HOOKS line in /etc/mkinitcpio.conf and run "mkinitcpio -p linux". A new initial RAM disk(initramfs) will be generated.

Note: If you plan on booting this installation of Arch on machines with nic cards that require different modules, remove "autodetect" from HOOKS
Note: Rebuilding the initial ramdisk will take some time if autodetect is removed from HOOKS

Now your new system can mount the file systems from iSCSI target drive after reboot.

Troubleshooting

Device not found

If you are having problems with detecting your eth0 interface, simply install mkinitcpio-nfs-utils package from the official repositories and dhcpcd on your iSCSI drive and add net HOOK to /etc/mkinitcpio.conf.

Also add ip=::::::dhcp to your kernel parameters and now you can use dhcpcd eth0 as described before.

For more informations, please refer to [2].