blacklight Posted December 18, 2023 Share Posted December 18, 2023 (edited) 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 Edited March 10 by blacklight Solved Quote Link to comment
blacklight Posted March 10 Author Share Posted March 10 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 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 ; ) Quote Link to comment
Recommended Posts
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.