How to automatically load SMB shared network disks when macOS starts up
本文最后更新于 442 天前,其中的信息可能已经有所发展或是发生改变,如有失效可到评论区留言。
  Generally, if you want to mount a network disk when booting a Linux system, you can do so by adding a startup item in /etc/fstab, but the implementation of macOS is slightly different. macOS does this by editing /etc/auto_master, as follows:
# # Automounter master map # +auto_master # Use directory service #/net -hosts -nobrowse,hidefromfinder,nosuid /home auto_home -nobrowse,hidefromfinder /Network/Servers -fstab /- -static # SAMBA AutoFS /- auto_smb

The /- indicates that the configuration files auto_smb and auto_master are located in the same folder. Then edit the configuration file /etc/auto_smb:

vim /etc/auto_smb
# content is as follows/System/Volumes/Data/samba_mount/share -fstype=smbfs,soft,noowners,nosuid,rw ://username:password@ip-address:/share

://username:password@ip-address:/share is the shared folder content shared by samba on the mount target ip-address. Username and password can be modified according to the actual situation.

/System/Volumes/Data/samba_mount is the mount path in macos, and the mount path must be placed under /System/Volumes/Data

Official statement:
If you are using macOS Catalina 10.15 and macOS Big Sur 11 (and above)
You just need to prefix the existing automount path with /System/Volumes/Data. This is because macOS will create a second APFS volume for user data, thus moving the existing system installation to the read-only APFS volume.

Also, be careful not to mount directly to /Users/xxx (xxx is the user name), nor to the user's home directory. It is recommended to mount directly to the /Users/xxx/shared directory, so the completed path should be: /System/Volumes/Data/Users/xxx/shared

After configuration, execute the automount command

automount -vc

In Docker Desktop for Mac, the directories that Docker can mount by default include /Users, so you can create mount folders for the corresponding folders in the shared directory under Users, for example: /System/Volumes/Data/Users/Shared/nextcloud. If you create them directly in a subfolder of the /Users/#home directory, autofs will have problems. Also note that the smb user password cannot use @, and for security reasons, it is best to create a separate user for the smb directory and only have secure read and write permissions for this mounted directory. Do not use admin directly.

Note: If the system version is upgraded, the auto_master file will be overwritten and auto_smb will need to be added again.

The content of the blog is original. Please indicate the source when reprinting! For more blog articles, you can go toSitemapUnderstand. The RSS address of the blog is:https://blog.tangwudi.com/feed, welcome to subscribe; if necessary, you can joinTelegram GroupDiscuss the problem together.
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠(ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ°Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
Emoticons
Emoji
Little Dinosaur
flower!
Previous
Next
       

This site has disabled the right mouse button and various shortcut keys. The code block content can be copied directly by clicking the copy button in the upper right corner

en_US