ubuntu:samba:mount_a_windows_share
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ubuntu:samba:mount_a_windows_share [2019/12/08 20:01] – peter | ubuntu:samba:mount_a_windows_share [2020/07/15 09:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Ubuntu - Samba - Mount a Windows Share ====== | ====== Ubuntu - Samba - Mount a Windows Share ====== | ||
- | ===== Command line basic syntax ===== | ||
- | The most basic mount options is: | + | ===== Quick Example ===== |
<code bash> | <code bash> | ||
- | mount -t cifs -o username=USERNAME,password=PASSWD | + | sudo mount -t cifs -o username=peter,password=xxxxxxxxxxxxxxxxxxxx, |
</ | </ | ||
---- | ---- | ||
- | ===== Command line mount ===== | + | |
+ | ===== Command line basic syntax | ||
+ | |||
+ | The most basic mount options is: | ||
<code bash> | <code bash> | ||
- | sudo mount -t cifs -o username=peter,password=xxxxxxxxxxxxxxxxxxxx, | + | mount -t cifs -o username=USERNAME,password=PASSWD |
</ | </ | ||
- | ===== Full breakdown of Command | + | ---- |
+ | |||
+ | ===== Extended command | ||
+ | If the basic mount does not work, you may need to use extended features | ||
<code bash> | <code bash> | ||
- | mount -t cifs // | + | mount -t cifs -o username=USERNAME,password=PASSWD, |
</ | </ | ||
where: | where: | ||
+ | |||
+ | * **USERNAME** The uid of the user who will own all the files and directories in the share. | ||
+ | * **PASSWD** the password of the USERNAME user. | ||
+ | * **iocharset=utf8** | ||
+ | * **file_mode** | ||
+ | * **dir_mode** | ||
<WRAP info> | <WRAP info> | ||
- | **NOTE:** All mounted files and directories owned by root. | + | **__FURTHER INFORMATION:__** |
- | Yes by default all the files and directories will be owned by the uid of the process or by root. You can force it otherwise. | + | **USERNAME: |
+ | <code bash> | ||
sudo id user_name | sudo id user_name | ||
+ | </ | ||
If, for example, the user id is 1000 then you can use the following... | If, for example, the user id is 1000 then you can use the following... | ||
+ | <code bash> | ||
uid=1000(user_name) gid=1000(user_name) groups=... | uid=1000(user_name) gid=1000(user_name) groups=... | ||
+ | </ | ||
- | Make the following entry in your /etc/fstab file : | ||
- | // | + | ---- |
- | Now when the share is mounted all files and folders will appear as the user with uid 1000. This is fine if you are the only user of the system. On a multiuser system this is problematic as other users will still be denied. Another option is to use dir_mode | + | **__dir_mode |
- | dir_mode=0777, | + | Setting the uid or gid is fine if you are the only user of the system. |
- | which will look like: | + | On a multiuser system this is problematic as other users will still be denied. |
+ | |||
+ | Therefore use **dir_mode / file_mode** to give everyone access: | ||
+ | |||
+ | <code bash> | ||
+ | dir_mode=0777, | ||
+ | </ | ||
- | // | ||
</ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | sudo mount -t cifs -o username=${USER}, | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
Line 57: | Line 85: | ||
===== fstab persistent mount ===== | ===== fstab persistent mount ===== | ||
- | Quick basic example of a cfis mount entry in fstab to connect to shares | + | Permanently |
- | Permanently mount the shares so that they will be available after reboot. | + | ==== Edit the host file ==== |
Edit your **/ | Edit your **/ | ||
Line 69: | Line 97: | ||
</ | </ | ||
- | Next create | + | ---- |
+ | |||
+ | ==== Create mount points ==== | ||
+ | |||
+ | Create | ||
<code bash> | <code bash> | ||
Line 77: | Line 109: | ||
</ | </ | ||
- | Make sure you have cifs installed. | + | ---- |
+ | |||
+ | ==== Edit /etc/fstab ==== | ||
- | Edit **/ | + | Edit **/ |
<file bash / | <file bash / | ||
Line 86: | Line 120: | ||
// | // | ||
</ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | ** NOTE:** If the system complains add the ' | ||
+ | </ | ||
---- | ---- | ||
- | ==== Mount the shares | + | === Mount the shares === |
<code bash> | <code bash> | ||
sudo mount -a | sudo mount -a | ||
</ | </ | ||
+ | |||
+ | or Reboot. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Extended fstab settings ===== | ||
+ | |||
+ | Make the following entry in your /etc/fstab file : | ||
+ | |||
+ | <file bash / | ||
+ | // | ||
+ | </ | ||
+ | |||
+ | Now when the share is mounted all files and folders will appear as the user with uid 1000. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <WRAP info> | ||
+ | **__FURTHER INFORMATION: | ||
+ | |||
+ | |||
+ | **__dir_mode / file_mode__** | ||
+ | |||
+ | Setting the uid or gid is fine if you are the only user of the system. | ||
+ | |||
+ | On a multiuser system this is problematic as other users will still be denied. | ||
+ | |||
+ | Therefore use **dir_mode / file_mode** to give everyone access: | ||
+ | |||
+ | |||
+ | <file bash / | ||
+ | // | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Extende fstab to assign full permissions to newly created files and directories ===== | ||
+ | |||
+ | Add these lines to / | ||
+ | |||
+ | <file bash / | ||
+ | ... | ||
+ | create mask = 0666 | ||
+ | force create mode = 0666 | ||
+ | directory mask = 0777 | ||
+ | force directory mode = 0777 | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | This gives 0777 permission to every samba users in the write list for new created directory or files. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Hide Credentials ===== | ||
+ | |||
+ | Setup a credentials file so you don't need to enter your password in the command; causing it to be stored in your command history in plain-text) or at the prompt (a nuisance). | ||
+ | |||
+ | <code bash> | ||
+ | sudo mount -t cifs //nas/docs / | ||
+ | </ | ||
+ | |||
+ | Note the **credentials option** | ||
+ | |||
+ | <file bash / | ||
+ | username=peter | ||
+ | password=[REAL PASSWORD] | ||
+ | domain=WORKGROUP | ||
+ | </ | ||
ubuntu/samba/mount_a_windows_share.1575835281.txt.gz · Last modified: 2020/07/15 09:30 (external edit)