Skip to content

Commit

Permalink
mount cifs at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
sky-bro committed Dec 16, 2023
1 parent b8788f4 commit 86892df
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 23 deletions.
49 changes: 40 additions & 9 deletions content-org/all-posts.en.org
Expand Up @@ -3421,17 +3421,17 @@ You should use NFS for dedicated Linux Client to Linux Server connections.

For mixed Windows/Linux environments use Samba.

** Server (linux)
** Server

*** install
*** linux

*Dependency Installation*

#+begin_src shell
sudo pacman -Sy samba
#+end_src

*** configure

**** configuration file
*configuration file*

Need to create =/etc/samba/smb.conf= before starting the service =systemctl start smb=

Expand Down Expand Up @@ -3461,7 +3461,7 @@ Here's mine:
printable = no
#+end_src

**** user management
*user management*

we need to have a user to access linux files.

Expand All @@ -3476,7 +3476,7 @@ We need to specifically add a user (an existing linux user, or a non-existing on

And by default, when you access a samba server with a user, you can browser that user's home directory (if it has one).

*** start
*start*

#+begin_src shell
systemctl start smb.service
Expand All @@ -3498,19 +3498,50 @@ tips: to clean user credentials (or with the control panel GUI)

*** linux

1. With a file manager:
**** With a file manager:

https://wiki.archlinux.org/title/samba#File_manager_configuration

In the location bar, input: =smb://servername/share=

2. With a command line tool: =smbclient=
**** With a command line tool: =smbclient=

#+begin_src shell
smbclient //xyz/public -U nobody
smbclient //xyz/sky -U sky
#+end_src

**** mount at startup

#+begin_src shell
sudo pacman -Sy cifs-utils

# prepare mount entry
sudo vim /etc/fstab
# add smbshare like:
# //192.168.31.248/Dev /home/sky/share/Dev cifs credentials=/home/sky/.smbcredentials,user,uid=sky,gid=sky 0 0
# user: allow any user to mount the drive
# noauto: the dirve is not mounted during startup, do not add this if you want to mount at startup

systemctl daemon-reload # make /etc/fstab change effective

# create mount credentials
vim ~/.smbcredentials
# username=sky
# password=sky
chmod 0600 ~/.smbcredentials

# create the mount point
mkdir -p ~/share/Dev

# mount
mount ~/share/Dev

# umount
umount ~/share/Dev

#+end_src

** Resources

- [[https://jeffshee.github.io/2021-01-29-samba-fedora33-kvm-windows-10/][File transfer between Linux and KVM Guest Windows 10]]
Expand Down
55 changes: 41 additions & 14 deletions content/en/posts/file-sharing-with-samba/index.md
Expand Up @@ -16,20 +16,18 @@ You should use NFS for dedicated Linux Client to Linux Server connections.
For mixed Windows/Linux environments use Samba.


## Server (linux) {#server--linux}
## Server {#server}


### install {#install}
### linux {#linux}

**Dependency Installation**

```shell
sudo pacman -Sy samba
```


### configure {#configure}


#### configuration file {#configuration-file}
**configuration file**

Need to create `/etc/samba/smb.conf` before starting the service `systemctl start smb`

Expand Down Expand Up @@ -59,8 +57,7 @@ Here's mine:
printable = no
```


#### user management {#user-management}
**user management**

we need to have a user to access linux files.

Expand All @@ -75,8 +72,7 @@ sudo smbpasswd -a sky

And by default, when you access a samba server with a user, you can browser that user's home directory (if it has one).


### start {#start}
**start**

```shell
systemctl start smb.service
Expand All @@ -101,22 +97,53 @@ net use /delete *.

### linux {#linux}

1. With a file manager:

#### With a file manager: {#with-a-file-manager}

<https://wiki.archlinux.org/title/samba#File_manager_configuration>

In the location bar, input: `smb://servername/share`

1. With a command line tool: `smbclient`

<!--listend-->
#### With a command line tool: `smbclient` {#with-a-command-line-tool-smbclient}

```shell
smbclient //xyz/public -U nobody
smbclient //xyz/sky -U sky
```


#### mount at startup {#mount-at-startup}

```shell
sudo pacman -Sy cifs-utils

# prepare mount entry
sudo vim /etc/fstab
# add smbshare like:
# //192.168.31.248/Dev /home/sky/share/Dev cifs credentials=/home/sky/.smbcredentials,user,uid=sky,gid=sky 0 0
# user: allow any user to mount the drive
# noauto: the dirve is not mounted during startup, do not add this if you want to mount at startup

systemctl daemon-reload # make /etc/fstab change effective

# create mount credentials
vim ~/.smbcredentials
# username=sky
# password=sky
chmod 0600 ~/.smbcredentials

# create the mount point
mkdir -p ~/share/Dev

# mount
mount ~/share/Dev

# umount
umount ~/share/Dev
```


## Resources {#resources}

- [File transfer between Linux and KVM Guest Windows 10](https://jeffshee.github.io/2021-01-29-samba-fedora33-kvm-windows-10/)
Expand Down

1 comment on commit 86892df

@vercel
Copy link

@vercel vercel bot commented on 86892df Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blog-src – ./

blog-src-ky13.vercel.app
k4i.top
blog-src-git-master-ky13.vercel.app

Please sign in to comment.