System Administration Guide: Devices and File Systems

ProcedureHow to Access iSCSI Disks Upon Reboot

Follow the steps below to access iSCSI disks after the system is rebooted.

  1. Add entries for the iSCSI LUN(s) to the /etc/vfstab file. Set the mount at boot option to no.


    #device         device          mount           FS      fsck    mount   mount
    #to mount       to fsck         point           type    pass    at boot options
    #
    /dev/dsk/c3t600144F04B555F370000093D00495B00d0s0        -       /mnt    ufs     -       no      -
  2. Create an SMF service manifest that automatically mounts the iSCSI LUN after the system is rebooted.

    For example, create an XML manifest file, /var/svc/manifest/network/iscsi/iscsimount.xml, with the following contents:


    <?xml version="1.0"?>
     <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
     
     <service_bundle type="manifest" name="iscsimount">
         <service
             name="iscsimount"
             type="service"
             version="1" >
     
             <single_instance/>
     
             <!--
     	    We depend on the iscsi initiator service
     	    -->
             <dependency
                 name="client"
                 type="service"
                 grouping="require_all"
                 restart_on="none">
                 <service_fmri value="svc:/network/iscsi/initiator"/>
             </dependency>
     
             <instance name="default" enabled="false">
     
             <!-- mount iSCSI volumes -->
                 <exec_method
                     type="method"
                     name="start"
                     exec="/var/tmp/iscsi_mount"
                     timeout_seconds="60"/>
     
             <!-- umount iSCSI volumes -->
                 <exec_method
                     type="method"
                     name="stop"
                     exec="/var/tmp/iscsi_umount"
                     timeout_seconds="60" />
     
                 <property_group name="startd" type="framework">
                     <propval name="duration" type="astring" value="transient"/>
                 </property_group>
             </instance>
     
             <template>
                 <common_name>
                     <loctext xml:lang="C">
                         iSCSI Mount Service
                     </loctext>
                 </common_name>
             </template>
         </service>
     </service_bundle>
  3. Create the following files in the /var/tmp directory.

    The following sample bash shell scripts mount and umount iSCSI disks from the /mnt directory.


    bash-4.0# cat /var/tmp/iscsi_mount
    #!/usr/bin/bash
    mount /mnt           #Add multiple iscsi lun(s) to mount
    bash-4.0# cat /var/tmp/iscsi_umount 
    #!/usr/bin/bash
    umount /mnt          #Add multiple iscsi lun(s) to umount

    Set execute permission on these scripts. For example:


    bash-4.0# chmod u+x /var/tmp/iscsi_mount
    bash-4.0# chmod u+x /var/tmp/iscsi_umount
    
  4. Import the manifest.


    # svccfg import /var/svc/manifest/network/iscsi/iscsimount.xml
    # svccfg enable iscsimount
    

    Note –

    After this service is enabled, you might get the following messages when the system is shut down or rebooted:


    iscsi: NOTICE: iscsi session(4) - session logout failed (1)
    iscsi: NOTICE: iscsi discovery failure - SendTargets method is not enabled
    iscsi: NOTICE: iscsi discovery failure - iSNS method is not enabled

    You can safely ignore these messages or you can run the following command just prior to reboot to avoid the messages:


    # svcadm disable -t iscsimount

    After the devices have been discovered by the Solaris iSCSI initiator, the login negotiation occurs automatically. The Solaris iSCSI driver determines the number of available LUNs and creates the device nodes. Then, the iSCSI devices can be treated as any other SCSI device.