You are not logged in.

#1 2015-03-11 15:24:44

kamaradclimber
Member
Registered: 2012-07-29
Posts: 8

[Solved] Wait for external usb disk before mounting partition

Hello,

I have a fresh setup where 3 btrfs subvolumes are supposed to be mounted on /var /home and /opt. Those subvolumes are on an external usb drive (root fs is on a sd card).

During boot, systemd tries to mount /var first but encounter "var not empty, mounting anyway" (probably due to several boot attempts) and then "special device uUID=12f15a3e-cf5c-4bc2-9475-6b4686a30f90 does not exist" where 12f15a3e-cf5c-4bc2-9475-6b4686a30f90 is the correct id of the drive.

From journactl extract it seems that usb drive is not ready yet when /var is being mounted.

Is there a way to make systemd wait for "the disk is ready" before trying to mount /var ?

Information:
- mounting /var in rescue mode works perfectly (mount -o subvol=var /dev/sda /var)
- device is a raspberry but I think it has no link to the issue (except maybe being slow to send power to usb)
- the usb drive is behind a 4 port usb hub (externally powered)
- the usb drive indeed take some time to be powered up
- /home and /opt are mounted in rescue mode automatically a few seconds later

journatctl wrote:

Jan 01 01:00:07 capodimonte systemd[1]: Starting Local File Systems (Pre).
Jan 01 01:00:07 capodimonte systemd[1]: Reached target Local File Systems (Pre).
Jan 01 01:00:07 capodimonte systemd[1]: Mounting /var...
Jan 01 01:00:07 capodimonte systemd[1]: var.mount: Directory /var to mount over is not empty, mounting anyway.
Jan 01 01:00:07 capodimonte systemd-udevd[138]: starting version 218
Jan 01 01:00:07 capodimonte mount[139]: mount: special device uUID=12f15a3e-cf5c-4bc2-9475-6b4686a30f90 does not exist
Jan 01 01:00:07 capodimonte kernel: scsi 0:0:0:0: Direct-Access     Inateck                   0001 PQ: 0 ANSI: 6
Jan 01 01:00:07 capodimonte kernel: sd 0:0:0:0: [sda] 1953525168 512-byte logical blocks: (1.00 TB/931 GiB)
Jan 01 01:00:07 capodimonte kernel: sd 0:0:0:0: [sda] Write Protect is off
Jan 01 01:00:07 capodimonte systemd[1]: var.mount mount process exited, code=exited status=32
Jan 01 01:00:07 capodimonte kernel: sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
Jan 01 01:00:07 capodimonte kernel: sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Jan 01 01:00:07 capodimonte systemd[1]: Failed to mount /var.
[...]
Jan 01 01:00:09 capodimonte kernel:  sda: unknown partition table
Jan 01 01:00:09 capodimonte kernel: sd 0:0:0:0: [sda] Attached SCSI disk
Jan 01 01:00:09 capodimonte kernel: random: nonblocking pool is initialized
Jan 01 01:00:09 capodimonte kernel: BTRFS: device label external_hdd devid 1 transid 24 /dev/sda
Jan 01 01:00:09 capodimonte systemd[1]: Found device NS1066 external_hdd.
Jan 01 01:00:09 capodimonte systemd[1]: Mounting /home...
Jan 01 01:00:09 capodimonte systemd[1]: Mounting /opt...
Jan 01 01:00:09 capodimonte kernel: BTRFS info (device sda): enabling auto defrag
Jan 01 01:00:09 capodimonte kernel: BTRFS info (device sda): disk space caching is enabled
Jan 01 01:00:09 capodimonte kernel: BTRFS: has skinny extents
Jan 01 01:00:09 capodimonte systemd[1]: Mounted /home.
Jan 01 01:00:09 capodimonte systemd[1]: Mounted /opt.
Jan 01 01:00:09 capodimonte systemd[1]: Startup finished in 5.088s (kernel) + 4.607s (userspace) = 9.696s.

My fstab:

# /dev/mmcblk0p3
UUID=4660fa0a-bcf6-4d83-b956-d7bf9df222b9	/         	ext4      	rw,relatime,data=ordered	0 1

# /dev/sda LABEL=external_hdd
UUID=12f15a3e-cf5c-4bc2-9475-6b4686a30f90	/home     	btrfs     	rw,relatime,space_cache,noatime,compress=lzo,autodefrag,subvol=home	0 0

# /dev/sda LABEL=external_hdd
uUID=12f15a3e-cf5c-4bc2-9475-6b4686a30f90	/var      	btrfs     	rw,relatime,space_cache,noatime,compress=lzo,autodefrag,x-systemd.device-timeout=30s,subvol=var	0 0

# /dev/sda LABEL=external_hdd
UUID=12f15a3e-cf5c-4bc2-9475-6b4686a30f90	/opt      	btrfs     	rw,relatime,space_cache,noatime,compress=lzo,autodefrag,subvol=opt	0 0

# /dev/mmcblk0p1
UUID=95DB-C13B      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro	0 2

Last edited by kamaradclimber (2015-03-12 19:25:40)

Offline

#2 2015-03-11 16:16:14

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [Solved] Wait for external usb disk before mounting partition

See the FSTAB section of systemd.mount(5)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#3 2015-03-11 17:08:10

kamaradclimber
Member
Registered: 2012-07-29
Posts: 8

Re: [Solved] Wait for external usb disk before mounting partition

I had not been RTFM-ed in a while smile

Can you more specific on which part of the section you advise me to dig into ?

I forgot to mention that I've tried to add the x-systemd.device-timeout option without any luck.

Offline

#4 2015-03-11 17:56:07

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [Solved] Wait for external usb disk before mounting partition

I was talking about x-systemd-device-timeout, and I see now you already have that option for the fstab entry. As my one of my favorite HS teachers was wont to say, "My mistake, your fault, I'll forgive you this time." wink

Anyway, I wonder if this could be peculiar to btrfs. Do subvolumes get an associated device node (something in /dev/)? Maybe the full info of the var.mount unit could be helpful:

systemctl show var.mount

But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#5 2015-03-12 19:23:36

kamaradclimber
Member
Registered: 2012-07-29
Posts: 8

Re: [Solved] Wait for external usb disk before mounting partition

Thanks for your reply.

I don't see any btrfs subvolume information in /dev.

Here is the var.mount config:

systemctl show var.mount wrote:

Where=/var
What=/dev/sda
Options=rw,relatime,compress=lzo,space_cache,autodefrag
Type=btrfs
TimeoutUSec=1min 30s
ControlPID=0
DirectoryMode=0755
SloppyOptions=no
Result=exit-code
ExecMount={ path=/bin/mount ; argv[]=/bin/mount -n uUID=12f15a3e-cf5c-4bc2-9475-6b4686a30f90 /var -t btrfs -o rw,relatime,space_cache,noatime,compress=lzo,autodefrag,subvol=var ; ignore_errors=no ; start_time=[Thu 1970-01-01 01:00:07 CET] ; stop_time=[Thu 1970-01-01 01:00:07 CET] ; pid=141 ; code=exited ; status=32 }
Slice=system.slice
ControlGroup=/system.slice/var.mount
Delegate=no
CPUAccounting=no
CPUShares=18446744073709551615
StartupCPUShares=18446744073709551615
CPUQuotaPerSecUSec=infinity
BlockIOAccounting=no
BlockIOWeight=18446744073709551615
StartupBlockIOWeight=18446744073709551615
MemoryAccounting=no
MemoryLimit=18446744073709551615
DevicePolicy=auto
UMask=0022
LimitCPU=18446744073709551615
LimitFSIZE=18446744073709551615
LimitDATA=18446744073709551615
LimitSTACK=18446744073709551615
LimitCORE=18446744073709551615
LimitRSS=18446744073709551615
LimitNOFILE=4096
LimitAS=18446744073709551615
LimitNPROC=7329
LimitMEMLOCK=65536
LimitLOCKS=18446744073709551615
LimitSIGPENDING=7329
LimitMSGQUEUE=819200
LimitNICE=0
LimitRTPRIO=0
LimitRTTIME=18446744073709551615
OOMScoreAdjust=0
Nice=0
IOScheduling=0
CPUSchedulingPolicy=0
CPUSchedulingPriority=0
TimerSlackNSec=50000
CPUSchedulingResetOnFork=no
NonBlocking=no
StandardInput=null
StandardOutput=journal
StandardError=inherit
TTYReset=no
TTYVHangup=no
TTYVTDisallocate=no
SyslogPriority=30
SyslogLevelPrefix=yes
SecureBits=0
CapabilityBoundingSet=18446744073709551615
MountFlags=0
PrivateTmp=no
PrivateNetwork=no
PrivateDevices=no
ProtectHome=no
ProtectSystem=no
SameProcessGroup=yes
IgnoreSIGPIPE=yes
NoNewPrivileges=no
SystemCallErrorNumber=0
RuntimeDirectoryMode=0755
KillMode=control-group
KillSignal=15
SendSIGKILL=yes
SendSIGHUP=no
Id=var.mount
Names=var.mount
Requires=-.mount
Wants=system.slice
RequiredBy=systemd-journal-flush.service man-db.service shadow.timer man-db.timer local-fs.target systemd-random-seed.service logrotate.timer systemd-update-utmp.service
Conflicts=umount.target
Before=systemd-journal-flush.service man-db.service shadow.timer man-db.timer local-fs.target systemd-random-seed.service logrotate.timer systemd-update-utmp.service umount.target
After=local-fs-pre.target -.mount systemd-journald.socket system.slice
RequiresMountsFor=/
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
Description=/var
LoadState=loaded
ActiveState=active
SubState=mounted
FragmentPath=/run/systemd/generator/var.mount
SourcePath=/etc/fstab
UnitFilePreset=disabled
InactiveExitTimestamp=Thu 1970-01-01 01:01:11 CET
InactiveExitTimestampMonotonic=71204114
ActiveEnterTimestamp=Thu 1970-01-01 01:01:11 CET
ActiveEnterTimestampMonotonic=71204114
ActiveExitTimestampMonotonic=0
InactiveEnterTimestamp=Thu 1970-01-01 01:00:07 CET
InactiveEnterTimestampMonotonic=7409499
CanStart=yes
CanStop=yes
CanReload=yes
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureJobMode=replace
IgnoreOnIsolate=yes
IgnoreOnSnapshot=no
NeedDaemonReload=no
JobTimeoutUSec=0
JobTimeoutAction=none
ConditionResult=yes
AssertResult=yes
ConditionTimestamp=Thu 1970-01-01 01:00:07 CET
ConditionTimestampMonotonic=7365732
AssertTimestamp=Thu 1970-01-01 01:00:07 CET
AssertTimestampMonotonic=7365738
Transient=no

Offline

#6 2015-03-12 19:25:11

kamaradclimber
Member
Registered: 2012-07-29
Posts: 8

Re: [Solved] Wait for external usb disk before mounting partition

Argh !

It is not RFTM that you should have said but LTT (learn to type).

ExecMount={ path=/bin/mount ; argv[]=/bin/mount -n uUID=12f15a3e-cf5c-4bc2-9475-6b4686a30f90 /var -t btrfs -o 

sed s/uUID/UUID

issue solved.

thanks for your time.

Offline

Board footer

Powered by FluxBB