Article
11198
This tip explains how to create, manage iSCSI volumes (including LVM managed) on SLES 10 SP1 then mount them automatically at reboot.
Problem:
Unfortunately the documentation doesn't discuss this matter well and it gets really tricky when you have a large volume and want to manage it with LVM.
Solution:
I shall demonstrate the solution with an assumption that you have some SLES, iSCSI knowledge already and you have a system installed with mainly default settings.
1. Open-iSCSI software installation and configuration
geeko:~ # yast2 sw_single
When finished, find out your generated initiator id:
geeko:~ # grep . /etc/iscsi/initiatorname.iscsi | grep -v ^# InitiatorName=iqn.1996-04.de.suse:01.df9759e0f317
Now you have to get your storage allocated in the iSCSI system as well so let your iSCSI admin know your IP address, hostname and the generated initiator id above. Once it's ready, configure your client:
geeko:~ # yast2 iscsi-client &
Select “When Booting” at the first tab.
At the second tab enter either the IP address (preferred) of your iSCSI array or its DNS name, leave the port default. I don't have authentication set therefor it's selected also.
Go to the third tab then select “Discovery”. If you did everything right (and of course your storage is set in iSCSI as well) it should find your allocated storage area. Select each of them then “Log In”.
Now switch back to the second tab:
On the second tab select each target then “Toggle Start-Up” which will cause the targets set to automatically come up at next reboot. At completion click “Finish”.
2. LVM2 over iSCSI
I have a large 5T storage area allocated therefor I am forced to use LVM2 due to traditional Linux partitions cannot be larger than 2T. If you won't use LVM2 then you can skip this section and jump to step 3. right now.
My storage area is split up as 2x2TB and 1x1TB so I have 3 devices under dev:
geeko:~ # ls /dev/sd* sda sdb sdc
I set up LVM from the command line:
geeko:~ # pvcreate /dev/sda /dev/sdb /dev/sdc
After initializing the disks set up a volume group:
geeko:~ # vgcreate iscsigroup1 /dev/sda /dev/sdb /dev/sdc
Once done, we can create logical volume:
geeko:~ # lvcreate -L5T -n iscsi_volume1 iscsigroup1
Find out the device mapper ID for the new LVM volume:
geeko:~ # lvdisplay /dev/iscsigroup1/iscsi_volume1 --- Logical volume --- LV Name /dev/iscsigroup1/iscsi_volume1 VG Name iscsigroup1 LV UUID CYmaJw-gRdv-9LIi-ULPU-2PTX-cxup-c70TNE LV Write Access read/write LV Status available # open 1 LV Size 5.00 TB Current LE 1310717 Segments 3 Allocation inherit Read ahead sectors 0 Block device 253:0
What matters here is the last line 253:0 which tells us that the DM number is 0. It's required to find out the device's uuid what we will use to mount the volume at boot. The device what we will need to query is /dev/dm-<number> which is dm-0 in my case.
3. Set up fstab
Find out the uuid of your new LVM2 volume:
geeko:~ # udevinfo -q symlink -n /dev/dm-0 disk/by-uuid/de9f51df-2375-4e83-947b-b5b7f4126db2
Users who didn't need LVM2 can just do the same for their device for instance sda1, sdb3, etc.
The correct fstab entry after all:
geeko:~ # vi /etc/fstab -snip- /dev/disk/by-uuid/de9f51df-2375-4e83-947b-b5b7f4126db2 /mnt/iscsi xfs hotplug 0 2
Explanation:
We need to insert “/dev/” in front of to the uuid we retrieved and use “hotplug” option instead of “_netdev”. To read more about this please visit this page:
http://en.opensuse.org/Open-iSCSI_and_SUSE_Linux
I recommend xfs filesystem on LVM2 volumes because it allows you to grow it even online.
Now the system is supposed to be set for users not using LVM2 over iSCSI and ready for reboot but at compilation we ensure that the necessary services are set for startup:
geeko:~ # chkconfig -l open-iscsi open-iscsi 0:off 1:off 2:off 3:on 4:off 5:on 6:off
4. LVM discovery on iSCSI volumes at startup
Unfortunately when iSCSI was added to SLES10, LVM discovery was not considered in the design. It exists in bugzilla as defect 254723 but there will be no fix for it as it's a feature.
However I was assured by the support team that it has been accepted as feature upgrade in the upcoming releases SLES11 and for SLES10 SP2 also hence the solution I am providing here is just “for the time being” and should not be used after SP2.
I backed up the original init script then created a patch:
geeko:~ # cp /etc/init.d/open-iscsi /etc/init.d/open-iscsi.dist
geeko:~ # cat /etc/init.d/open-iscsi.patch
--- open-iscsi.dist 2007-08-03 04:55:31.000000000 +1200
+++ open-iscsi 2007-12-10 16:38:15.000000000 +1300
@@ -23,11 +23,15 @@
# Source LSB init functions
. /etc/rc.status
+# Source LVM configuration
+. /etc/sysconfig/lvm
+
# Reset status of this service
rc_reset
iscsi_login_all_nodes()
{
+ /bin/sleep 4
echo -n "Setting up iSCSI targets: "
$ISCSIADM -m node --loginall=automatic
rc_status -v
@@ -94,6 +98,17 @@
done
}
+iscsi_scan_lvm_nodes()
+{
+ #
+ # Find and activate iSCSI volume groups
+ #
+ echo "Scanning for iSCSI LVM volume groups..."
+ /sbin/vgscan --mknodes
+ echo "Activating iSCSI LVM volume groups..."
+ /sbin/vgchange -a y $LVM_VGS_ACTIVATED_ON_BOOT
+}
+
case "$1" in
start)
[ ! -d /var/lib/iscsi ] && mkdir -p /var/lib/iscsi
@@ -109,6 +124,9 @@
fi
if [ "$RETVAL" == "0" ]; then
iscsi_login_all_nodes
+ iscsi_scan_lvm_nodes
+ /bin/sleep 2
+ /bin/mount -a > /dev/null 2>&1
fi
;;
stop)
Save it somewhere, perhaps at the same location then apply it:
geeko:~ # cd /etc/init.d geeko:/etc/init.d # patch -p0 < open-iscsi.patch
The system is ready and should mount your iSCSI volumes at next reboot.
Environment:
SLES10SP1
open-iscsi-2.0.707-0.24
Related Articles
User Comments
SLES10 SP2 - iSCSI mount hangs system on reboot
Submitted by tbiles on 20 July 2009 - 8:02am.
It doesn't appear that this support made it into SP2 as may have been suggested above but I was able to modify our startup environment to included the diffs in your patch file which allowed us to successfully connect to iSCSI at boot time without manual intervention.
However, we have trouble with the system hanging on reboot and are wondering if other modifications could be suggested to cleanly disconnect from the iSCSI volume when a reboot is issued. If we manually umount the volume, it seems we can generally reboot without incident.
- Login to post comments











1