0

I am trying to mount a Linux SMB share onto a macOS machine running Ventura 13.4. I must have the share mounted after the macOS machine bootup is completed, but before any possible user has logged into the machine via the desktop UI. This is to permit SSH connections into the machine that perform maintenance and requires access to those Linux shares as local mounted folders. Per User scripts cannot help as we are using AD, and a user may not have ever logged into the machine at any time, plus the script must be run before the user has logged in.

I've tried using fstab: My command line equivalents for that with the mount command work, but fstab does not seem to be processed by macOS at startup any longer, so the fstab entries are ignored unless utilized with a manual command line of mount -a

I've also tried using a bash script launched at startup to utilize various combinations of launchd, including Library/LaunchAgents, System/Library/LaunchDaemons, Library/LaunchDaemons, and System/Library/LaunchAgents. Some of these will mount the share at startup, but none of them seem to mount the share before a user has logged into the UI.

Any suggestions on a solution that mount the share before the user has logged in?

agarza
  • 2,274
  • Have you thought of using NFS in this scenario? NFS, though old, is a better fit for this type of “global” mount. – Allan Jul 03 '23 at 13:19
  • Why wouldn't this process that connects to the machine simply mount what it needs mounted, and unmount it when done? – Marc Wilson Jul 03 '23 at 14:00
  • Automatic network mounts are handled by autofs. All you should need to know is in the auto_master(5) man page. – Linc D. Jul 03 '23 at 14:30
  • Also LaunchAgents execute upon user login. Only LaunchDaemons will execute prior to user login but those run as root. Is there a reason you need the mount available prior to logging in? – Allan Jul 03 '23 at 15:04
  • @Allan: In addition to the stated Linux server, there are several other devices which do not support NFS, but do support SMB, so SMB is a requirement for us. Also Yes, it must mount before because the maintenances routines that are run via SSH must run after machines have been logged out and left in an "unlogged" state. – Sam Marrocco Jul 03 '23 at 17:26
  • @Marc Wilson: We wish the mounts to persist after startup before login, and persist after login as well. – Sam Marrocco Jul 03 '23 at 17:28
  • @SamMarrocco Why? What problem is being solved by the mounts hanging around? – Marc Wilson Jul 03 '23 at 17:45
  • Ok..let’s say we do get this to connect before a user login, if I remember correctly SMB shares timeout (server) after 15 to 20 minutes. On the client, when it goes into power save, those connections are also broken. Why can’t these shares be mounted at the time of the SSH connection rather than leaving them idle? – Allan Jul 03 '23 at 18:16
  • @Marc Wilson: The problems that is solved by "mounts hanging around" is that of "What if a backup is started before a user logs in, and is still taking place when they log in and after they are logged in", enabling the SSH backup routines to continue without being interrupted with the persistent mount. – Sam Marrocco Jul 04 '23 at 12:39
  • @ Alan: SMB Shares on the server can be 'forever' if configured properly with no timeout. Power save(s) and such on the clients are disabled (Backups can take several hours) and users cannot power down machines themselves. Only occasionally are machine power cycled by engineering. – Sam Marrocco Jul 04 '23 at 12:48
  • @Alan: (Continued).....As for the "why", because there are other pieces of code running on the machines that do no rely on SSH expecting the mount to be there before the user log in as well that are unmentioned. Effectively, they are similiar to services on a windows machine and can run before and after user logins. This all comes down to being able to mount the shares before login and having them stay persistent. – Sam Marrocco Jul 04 '23 at 12:48
  • @SamMarrocco A backup should check to see if its target is present, mount it if it is not, and unmount it when it is completed. – Marc Wilson Jul 04 '23 at 14:59

0 Answers0