You are not logged in.

#1 2018-01-13 19:50:16

mihanson
Member
Registered: 2009-04-27
Posts: 9

fsck iSCSI Home Directory Before Mounting

I recently migrated my /home directory to an iSCSI target on my FreeNAS server. I used the iSCSI Initiator wiki page to set up the open-iscsi daemon. In order to automate the mounting of /home at boot time, I modified the open-iscsi.service by adding a script to ExecStartPost and ExecStopPre to log into and out of the iSCSI node.

$  uname -a

Linux desktop 4.9.75-1-lts #1 SMP Fri Jan 5 21:29:02 CET 2018 x86_64 GNU/Linux

$  cat /etc/systemd/system/open-iscsi.service

[Unit]
Description=Open iSCSI Daemon
After=network-online.target
[Service]
Type=forking
ExecStart=/sbin/iscsid
ExecStartPost=/usr/local/bin/logon-iscsi
ExecStopPre=/usr/local/bin/logoff-iscsi
[Install]
WantedBy=multi-user.target

$  cat /usr/local/bin/logon-iscsi

#!/bin/sh
#
# Logon iSCSI node
ADM=`which iscsiadm`
NAME="iqn.2017-12.com.my-site:arch-linux.home:my-hostname"
ADDRESS="192.168.1.3"
UUID="my-home-uuid"
# Login to iSCSI target
"$ADM" -m node -l -p "$ADDRESS" -T "$NAME"

$  cat /usr/local/bin/logoff-iscsi

#!/bin/sh
#
# Logoff iSCSI node
ADM=`which iscsiadm`
UMNT=`which umount`
MNTPT=`which mountpoint`
DIR="home"
NAME="iqn.2017-12.com.my-site:arch-linux.home:my-hostname"
ADDRESS="192.168.1.3"
# uMount device if still mounted
if `$MNTPT -q /$DIR` ; then
  "$UMNT" "/$DIR"
fi
# Logout of iSCSI target
"$ADM" -m node -u -p "$ADDRESS" -T "$NAME"

The relevant part of my fstab:

tmpfs                  /tmp          tmpfs     nodev,nosuid    0       0
UUID=my-root-uuid / ext4 defaults,noatime 0 1
UUID=my-boot-uuid /boot ext4 defaults,noatime 0 1
UUID=my-boot-efi-uuid                            /boot/efi vfat defaults 0 1
UUID=my-home-uuid /home ext4 defaults,x-systemd.after=open-iscsi.service,noatime 0 2

My issue is that fsck is never run on /home no matter what the mount count or interval is set to.

$ sudo dumpe2fs -h /dev/disk/by-uuid/my-home-uuid

Mount count:              21
Maximum mount count:      10
Last checked:             Sat Dec 13 08:11:39 2017
Check interval:           604800 (1 week)
Next check after:         Sat Dec 20 08:11:39 2017

I only get a warning is dmesg that the maximum mount count has been reached and fsck is recommended.
I tried to remove the /home mount entry from fstab and added a systemd .mount unit file instead, with no change in behavior (I am warned about fsck, but it’s not actually run).

[Unit]
Description=Mount Home Directory
[Mount]
What=/dev/disk/by-uuid/my-home-uuid
Where=/home
Type=ext4
Options=defaults,_netdev,x-systemd.after=open-iscsi.service
[Install]
WantedBy=multi-user.target

I know fsck is run early in the boot process, before network is available and the open-iscsi.service is running. How can I get fsck to run when needed before /home is mounted? Thanks in advance for any tips!

Mike

Offline

Board footer

Powered by FluxBB