Advertisement
corrosiontears

Como criar Montagens Automáticas no Samba via GVFS (inglês)

Jul 7th, 2013
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.92 KB | None | 0 0
  1.  
  2. How To: Auto Mount Samba Shares on Boot ( GVFS Method )
  3.  
  4. Postby altair4 on Wed Feb 24, 2010 1:21 pm
  5. Auto Mount Samba Shares on Boot ( GVFS Method )
  6.  
  7. Updated to include Mint Debian Changes
  8.  
  9. Prerequisites
  10.  
  11. This HowTo assumes you can connect to a remote share from Nautilus. If you cannot, this HowTo will not help you. If you have problems connecting to a remote share manually I suggest you post a separate topic asking for help.
  12.  
  13. Linux Mint Debian Edition Prerequisites
  14.  
  15. You need to install one package:
  16.  
  17. Code: Select all
  18.     sudo apt-get install gvfs-fuse
  19.  
  20.  
  21. You need to add yourself to the fuse group:
  22.  
  23. Code: Select all
  24.     sudo gpasswd -a your_user_name fuse
  25.  
  26.  
  27. You need to logoff and login again for the group to actually change.
  28.  
  29.  
  30. GVFS
  31.  
  32. When you use Nautilus to access a samba share manually you may not know that Nautilus actually creates a mount point. The problem is it's in a hidden directory. You have to enable Nautilus to "see" that directory by going to:
  33. Nautilus > Edit > Preferences > View > Show hidden and backup files.
  34. The mount point is at :
  35. /home/your_user_name/.gvfs ( note the "." in front of the gvfs - that indicates a hidden directory )
  36.  
  37.  
  38. Procedure
  39.  
  40. Step 1: Connect to the Server from Nautilus
  41.  
  42. Nautilus > Network > Workgroup > Machine > Share
  43.  
  44. If the server requires authentication then enter it and click on the "remember forever" option before entering "Connect"
  45. Once you have successfully connected go back and unmount the remote share.
  46.  
  47. Step 2: Connect from the terminal
  48.  
  49. Open Terminal
  50. Type gvfs-mount smb://Server/share_name
  51. Substitute the actual "Server" and "Share_name" for the ones above
  52.  
  53. The "Server" in that command can take many forms, for example:
  54. gvfs-mount smb://WinXP/share_name
  55. gvfs-mount smb://WinXP.local/share_name
  56. gvfs-mount smb://192.168.0.100/share_name
  57. The last one is by ip address of the server which is the most reliable method.
  58.  
  59. Make sure this remounts the remote share to /home/user_name/.gvfs without prompting for authentication.
  60.  
  61. Step 3: Create a script that will automate this process and place it in the Autostart folder:
  62.  
  63. Open Terminal
  64. Type gedit
  65. Enter the following:
  66.  
  67. #!/bin/sh
  68. while true
  69.   do
  70.      if initctl status nmbd|grep -c running
  71.      then
  72.      gvfs-mount smb://Server/share_name
  73.      exit 0
  74.      fi
  75.      sleep 5
  76.   done
  77.  
  78. Again, Substitute the actual "Server" and "Share_name" for the ones above
  79.  
  80. Save the file as, for example: /home/user_name/share_name_mount.sh
  81. Exit gedit
  82. Back in the terminal make the script executable by issuing the command:
  83. chmod +x /home/user_name/share_name_mount.sh
  84.  
  85. Go to Menu > Preferences > Startup Applications > Add > point it to /home/user_name/share_name_mount.sh.
  86.  
  87. Logoff and logon again and you should have your share mounted to /home/user_name/.gvfs/ automatically ( assuming the server is running ) and you should have a mount icon on your desktop.
  88.  
  89.  
  90. Issues
  91.  
  92. []Your Specific Application Cannot Access The Hidden Mount Point
  93.  
  94. One way around this is to create a symlink to the .gvfs folder. For example:
  95.  
  96. Open Terminal
  97. Type mkdir /home/your_user_name/LanShare
  98. Type ln -s /home/your_user_name/.gvfs/"share_name on host_name" /home/your_user_name/LanShare
  99.  
  100.  
  101. Another way to do this is to create a bookmark to the .gvfs folder so that is shows up in the Open and Save boxes:
  102.  
  103. Run the following command:
  104.  
  105. Code: Select all
  106.    nautilus $HOME/.gvfs
  107.  
  108.  
  109. *** Bookmark that location: Bookmarks > Add Bookmark
  110. *** Right click the resulting ".gvfs" bookmark > Rename and rename to LanShares for example. It should then be visible in your application as LanShares.
  111.  
  112. []Multiple Samba Shares.
  113.  
  114. If you have many shares you want to automount you may be tempted to create one script with many gvfs-mount lines in them.
  115. I would advise against that. I have found that if one of them fails, all subsequent lines will not be executed. What I do is simply create a separate script for each share I want to mount.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement