[SOLVED ]Delayed & Conditioned Mount Script for NFS mount ?


Recommended Posts

I am looking for a startup script to mount an NFS share delayed and under the condition that a certain vm is online, like the following:

 

1. wait 60 secs

2. check vm #.. -> if its online continue 

3. wait 180 secs

4. mount share

 

Reason for that: I followed one of Space invader ones tutorials to virtualize TrueNAS. This is going to be my main/central NAS and I am also hosting any futures storages (SMB/ NFS/ AFS shares, scsi's etc.) and disk from it. Unraid itself barely has storage. Just 2x 500gb ssds for plugins, the most important vm's etc. 

 

Now I want to use the virtualization power of Unraid and start am Windows 10 VM which is located on a NFS share of the virtualized NAS. So far so good the windows vm works and is tremendously fast (Just changing the windows from my browser to Remote Desktop is enough to boot into windows, I was really surprised to see these speeds). 

 

The only problem is that after a reboot of Unraid, it tries to immediately mount the share which I guess fails and Unraid doesn't retry (I disabled the Mount button and it was not mounted after reboot, auto mount was on). The vm obviously doesn't work anymore and just boots into the EFI shell. That's why I am asking for a script like mentioned above. I use Unassigned devices.

 

Would appreciate any answer :) And please be nice about the virtualization, I know it polarizes :P 

Edited by blacklight
Solved
Link to comment
  • 2 months later...

Found the solution myself after research and trying some variants of User Scripts (plugin) I settled with this variant:

1. Created two custom scripts, one executed after start of the machine, one executed before stopping the machine

image.thumb.png.6d224da9b2014efe75fd76c38dbcaff9.png

2. Customize scripts with mkdir and mount e.g.:

Start Script

#!/bin/bash
sleep 150
mkdir /mnt/remotes/fastVMs_ext
mkdir /mnt/remotes/nextcloud
mount -t nfs 192.168.0.116:/mnt/fast_data/fastNAS_Data/fastVMs /mnt/remotes/fastVMs_ext
mount -t nfs 192.168.0.116:/mnt/main_data/PC_Data/nextcloud_main /mnt/remotes/nextcloud

 

Stop Script

#!/bin/bash
umount -t nfs 192.168.0.116:/mnt/fast_data/fastNAS_Data/fastVMs /mnt/remotes/fastVMs_ext --lazy
umount -t nfs 192.168.0.116:/mnt/main_data/PC_Data/nextcloud_main /mnt/remotes/nextcloud --lazy

rmdir /mnt/remotes/fastVMs_ext
rmdir /mnt/remotes/nextcloud

 

The paths of the scripts are located on the flash (mounted it on my Mac after opening the share on the Unraid guy):

->  /Volumes/flash/config/plugins/user.scripts/scripts/delayed mount of Icarus TrueNAS share

-> /Volumes/flash/config/plugins/user.scripts/scripts/delayed mount of Icarus TrueNAS share - SHUTDOWN

The modified file is always the script file. No restart of the machine needed, the script works right away.

 

The scripts, for now, just wait to assume the VM had enough time to start. 

I will have a look into conditioned startup (check if VM is up before connecting to it's SHARES) and a potential custom shutdown script (first shutdown depended VMs, then UNMOUNT main NAS share, in my case Truenas, then Shutdown VM, then shutdown machine, to ensure no data loss or abrupt share unmount) later.

I will update my results here to provide my information ; )

Link to comment
  • blacklight changed the title to [SOLVED ]Delayed & Conditioned Mount Script for NFS mount ?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.