0683.html 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Persistently Mount a SAMBA/CIFS Share in Linux</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Linux,Debian,Samba,SMB,CIFS,Persistent,Mount Samba Share,FSTab,Network Share,Linux Tips,Home Lab,Home Lab Ideas,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Persistently Mount a SAMBA/CIFS Share in Linux">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="07/25/2024 05:10:48 AM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Persistently Mount a SAMBA/CIFS Share in Linux</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <ol>
  26. <li>Log into the Linux device</li>
  27. <li>Run the following commands in terminal:
  28. <div class="codeBlock"># update software repositories<br />
  29. sudo apt update<br />
  30. # install cifs utilities<br />
  31. sudo apt install cifs-utils -y<br />
  32. # create a hidden smb credentials file<br />
  33. nano ~/.myshare.smb</div>
  34. </li>
  35. <li>Paste the following into the .smb, updating the credentials as needed to authenticate to the share
  36. <p>user=LinuxShare<br />
  37. password=SomethingSecure!!<br />
  38. domain=i12bretro.local</p>
  39. </li>
  40. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  41. <li>Continue with the following commands in the terminal
  42. <div class="codeBlock"># create a folder in /media to mount the share<br />
  43. sudo mkdir /media/myshare -p<br />
  44. # edit the fstab file<br />
  45. sudo nano /etc/fstab</div>
  46. </li>
  47. <li>Add a line to the bottom of fstab with the following, updating the server, share and host file location as needed<br />
  48. NOTE: fstab entries are formatted as //&lt;%server%&gt;/&lt;%share%&gt; &lt;%mount location%&gt; &lt;%filesystem type%&gt; &lt;%mount options%&gt;
  49. <p># windows share on i12bretrodc<br />
  50. //i12bretrodc/myshare /media/myshare cifs uid=0,credentials=/home/i12bretro/.myshare.smb,iocharset=utf8,vers=3.0,noperm 0 0</p>
  51. </li>
  52. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  53. <li>Continue with the following commands in the terminal
  54. <div class="codeBlock"># remount filesystems listed in fstab<br />
  55. sudo mount -a<br />
  56. # change directory to the share mount point<br />
  57. cd /media/myshare<br />
  58. # reboot to test the share is mounted on started<br />
  59. sudo reboot now</div>
  60. </li>
  61. </ol>
  62. <p>Documentation: <a href="https://man7.org/linux/man-pages/man8/mount.8.html" target="_blank">https://man7.org/linux/man-pages/man8/mount.8.html</a></p> </div>
  63. </div>
  64. </body>
  65. </html>