Perform Conditional Mount At Boot

Swerved

Member
Ok bear with me, this is kind of a weird situation..

I have two machines. Machine A is running MX Linux 19 and Win10, and Machine B is on MX Linux 19 and operates as an FTP server.

Ok, here goes...

Machine B runs an FTP server.. it mounts a drive in machine A over the network for the ftp content. We'll call that share ARCHIVES.. When machine A is booted to MX Linux, the drive is mounted to /media/ARCHIVES via NFS entry in fstab. When machine A is booted to windows, the shared drive (D:) is called ARCHIVES for the share name, and it requires a CIFS mount.

I can get it to mount using the appropriate entry in fstab for either situation, however I cannot make them mount using one entry that works with both scenarios. SO... here's what I'm trying to do...

1) Make a way for the machine (B) check to see which OS the share on machine A is in... If machine A is booted to windows, the share is 192.168.x.x/ARCHIVES and uses CIFS to mount... If it's booted to MX Linux, then the share is in 192.168.x.x/media/ARCHIVES and uses NFS to mount... So at boot, I want to check which of those two statements is true, and have it mount accordingly.

2) Can it be set to check at some interval to make sure the share machine A is still there? That way in case I boot to the other OS it can refresh and use the appropriate mounting method as needed?

Thanks in advance.


I know this is a bit unorthodox; I'm still learning.
 


Rob

Administrator
Staff member
I'd maybe write a little bash script on B that uses netcat or some way to probe A .. for instance, if A is booted to linux, you'd probably have port 22 (ssh) open.. so the script would check A for the open port, then mount the appropriate path.

Another easier idea is maybe on A, linux side.. can you create a symlink so /ARCHIVES works as well for the mount - that way it wouldn't matter whether it's booted into linux or windows? Not sure if that'd work out or not though.

ln -s /media/ARCHIVES /ARCHIVES
 

Swerved

Member
Thanks for the reply, Rob.

I got it (the first question) figured out; it was much simpler than I originally thought. Turns out I was over-thinking this, which I tend to do sometimes. All I had to do was on computer A, Linux booted.. I just had to declare /ARCHIVES as a samba share and set up access to it. Once I did that, the same fstab entry for computer B works whether A is in Windows, or MX Linux.

Now I just need to set up a way to make machine B check at some interval to see if machine A has changed OS and refresh the mount if so.


**** UPDATE: Done.. I set up a cron job that runs a script every 5 minutes to see if the mount is valid and if not, it remounts.
 
Last edited:



Members online


Latest posts


Top