# Mounting an iSCSI disk at boot

## FatherBusa

After much pain and suffering, I've managed to get iSCSI runnning.

However, I just can't seem to get the disks to automatically mount at boot.  I've read lots of different posts on this, and it seems like the right way to do this is fairly distro-specific, and I can't find any discussion of it with Gentoo.

I've tried adding a line to fstab (and played around with _netdev).  I've also tried adding mount and umount lines directly to the iscsid init script, but no luck.

Anyone got this working?

----------

## mwoodiupui

Me, too!

I think it's going to need a mount script of its own.  The thing about iSCSI is that starting it is like hotplugging a disk drive (or thousands of 'em).  It's not like NFS or CIFS where the medium implies a distinct filesystem type; instead, new devices come into being, containing anything a disk could hold:  they may be partitioned, or contain LVM PVs with LVs mapped into them, with each partition or LV containing ext2/3/4, reiserfs, xfs, FAT or NTFS -- you name it.  And it could all be sitting on multipath.  Yikes!

So, first you get iSCSI started and logged on, then something has to notice this and (possibly) mount the new devices as if they were local disks.  Something like 'mount -a -O no_netdev'.

Come to think of it, hotplugging is the way to think about this.  We need the right udev rules to trigger a new 'mount -a' when new SCSI devices appear.  (Also 'vgchange -ay', etc.)

----------

## mwoodiupui

I've cobbled together an /etc/init.d/san startup script:

```
#! /sbin/runscript

# Copyright 2013 Indiana University

# Mark H. Wood, IUPUI University Library, 03-May-2013

description="Prepare SAN volumes for mounting."

depend()

{

        need    net

        use     multipath lvm

}

start()

{

        ebegin "Prepare SAN volumes for mounting"

        if [ -x /sbin/multipath ]; then

                multipath >/dev/null

        fi

        if [ -x /sbin/vgchange ]; then

                vgchange -a y >/dev/null

        fi

        mount -a -O _netdev -t no${net_fs_list}

        eend $? "Some SAN volumes may be unavailable"

}

#stop()

#{

#       # Nothing to do

#}

```

It seems to do what I want, if I mark all of the SAN volumes with the _netdev option.

----------

## mwoodiupui

Near as I can tell, nothing has changed in the intervening years.  Unless I missed something?

To whom should I suggest that being able to list iSCSI volumes in fstab for auto mounting would be really desirable and BTW I already have some code to start from?

----------

## szatox

What about 

 *man genkernel wrote:*   

>       --[no-]iscsi
> 
>            Includes or excludes iSCSI support
> 
> 

 

I'd expect it to do what you want... and a bit more, like allowing root on iSCSI

----------

## mwoodiupui

 *szatox wrote:*   

> What about 
> 
>  *man genkernel wrote:*         --[no-]iscsi
> 
>            Includes or excludes iSCSI support
> ...

 

Thanks, my kernels are already built with iSCSI support and it is working.  It's the initscripts that are lacking, and it just seems incredible that there wouldn't be any support for mounting iSCSI volumes automatically when userspace is starting, but I can't find any.

----------

## szatox

This switch changes init script inside initramfs, it doesn't change kernel options. The whole point was that iSCSI devices behave just like any local disk, once you are connected to them.

Booting from iSCSI (which this switch is supposed to enable) requires that you can mount iSCSI drive before reading fstab.This way once you reach the fstab part, you already have network connection up and initiator running, so I'd expect mount to do it's job regarding iSCSI drives too.

----------

