{"id":1202,"date":"2013-09-12T23:10:37","date_gmt":"2013-09-12T21:10:37","guid":{"rendered":"http:\/\/michlstechblog.info\/blog\/?p=1202"},"modified":"2013-09-12T23:19:41","modified_gmt":"2013-09-12T21:19:41","slug":"linux-automount-windows-shares","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/linux-automount-windows-shares\/","title":{"rendered":"Linux: Automount Windows or Samba shares"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_1202 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_1202')){$('.twoclick_social_bookmarks_post_1202').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Linux%3A%20Automount%20Windows%20or%20Samba%20shares\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Atoday%20I%20will%20explain%20how%20to%20easy%20it%20is%20to%20automatically%20mount%20a%20windows%20share%20on%20linux.%0D%0A%0D%0AThe%20following%20packages%20are%20necessary%3A%20autofs%2C%20cifs%2Fsamba%20client%20tools%0D%0A%0D%0AIn%20this%20example%20I%20use%20a%20debian%20linux%20system.%0D%0A%0D%0Aroot%40dev%20%23%20apt-get%20install%20autofs%20cifs-utils%0D%0A%0D%0Aedit%20the%20auto.master%20file%20with%20your%20favorite%20editor%3A%0D%0A%0D%0Aroot%40dev%20%23%20vi%20%2Fetc%2Fauto.master%0D%0A%0D%0Aadd%20the%20following%20line%0D%0A%0D%0A%2Fmedia%2Fcifs%20%2F%20...\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/linux-automount-windows-shares\\\/\",\"post_id\":1202,\"post_title_referrer_track\":\"Linux%3A+Automount+Windows+or+Samba+shares\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>today I will explain how to easy it is to automatically mount a windows share on linux.<\/p>\n<p>The following packages are necessary: autofs, cifs\/samba client tools<\/p>\n<p>In this example I use a debian linux system.<\/p>\n<p><code>root@dev # apt-get install autofs cifs-utils<\/code><\/p>\n<p>edit the auto.master file with your favorite editor:<\/p>\n<p><code>root@dev # vi \/etc\/auto.master<\/code><\/p>\n<p>add the following line<\/p>\n<p><code>\/media\/cifs \/etc\/auto.cifs --ghost<\/code><\/p>\n<ul>\n<li><code>\/media\/cifs<\/code> &#8211; is the root directory where the mount points are created (this is not the mount point itself!), the directory must exist.<\/li>\n<li><code>\/etc\/auto.cifs<\/code> &#8211; the definition file of the mount points<\/li>\n<li><code>--ghost<\/code> This option will create the mount point permanently, even the share isn&#8217;t mounted (there are doubledashes before ghost:-))<\/li>\n<\/ul>\n<p>Create a new file \/etc\/auto.cifs and add your share definition. In this example the Windows computer is mediaserver with the share multimedia$ (Note: you have to quote the $ character in auto.cifs file or you got \u00a0cifs_mount failed w\/return code = -6). The share should be mounted as user michl which has UID 1000 and GID 1000. Insert the following line to \/etc\/auto.cifs:<\/p>\n<p><code>root@dev # touch \/etc\/auto.cifs<\/code><\/p>\n<p><code>root@dev # vi \/etc\/auto.cifs<\/code><br \/>\n<!--more--><br \/>\n<code>multimedia -fstype=cifs,credentials=\/root\/cred_mediaserver,uid=1000,gid=1000 :\/\/mediaserver\/multimedia\\$<\/code><\/p>\n<p>Whats left is to define the Windows User which have the appropriate rights to connect. Create the file \/root\/cred_mediaserver<\/p>\n<p><code>root@dev # touch \/root\/cred_mediaserver<\/code><\/p>\n<p>Set only permission for user root to read the file<\/p>\n<p><code>root@dev # chmod 600 \/root\/cred_mediaserver<br \/>\n<\/code><\/p>\n<p><code>root@dev # vi \/root\/cred_mediaserver<\/code><\/p>\n<p>and insert 2 lines. One with the Username and one with the password:<br \/>\n<code>username=michl<br \/>\npassword=michlsPassword<\/code><\/p>\n<p>Note: Be carefully with special characters in your password. Some have to quote because there are running shell scripts in background of the automounter! If you have a domain login use domain\/username as username.<\/p>\n<p>Start the automounter if it isn&#8217;t already started.<\/p>\n<p><code>root@dev #\/etc\/init.d\/autofs start<\/code><\/p>\n<p>Then accessing the mount point \/media\/cifs\/multimedia. The share is now mounted. If not see \/var\/log\/syslog for details.<\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, today I will explain how to easy it is to automatically mount a windows share on linux. The following packages are necessary: autofs, cifs\/samba client tools In this example I use a debian linux system. root@dev # apt-get install autofs cifs-utils edit the auto.master file with your favorite editor: root@dev # vi \/etc\/auto.master add &hellip; <a href=\"https:\/\/michlstechblog.info\/blog\/linux-automount-windows-shares\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Linux: Automount Windows or Samba shares<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[296,297,299,224,298],"class_list":["post-1202","post","type-post","status-publish","format-standard","hentry","category-linux","tag-automount","tag-cifs","tag-cifs_mount-failed-wreturn-code-6","tag-linux-2","tag-windows-share"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/1202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=1202"}],"version-history":[{"count":13,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/1202\/revisions"}],"predecessor-version":[{"id":1217,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/1202\/revisions\/1217"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=1202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=1202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=1202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}