9/25/2018 - 7:06 AM

Mount remote partitions

How to mount remote partitions linux

A partition form a remote linux server:

$ sshfs user@server_ip:server_base_folder_path mount_path

for example:

$ sshfs user@server:/media/data /media/user/server

If you need to mount a windows style partition, use cifs protocol:

$ sudo mount -t cifs path_to_server_disk -o username=user,password=password mount_path

When you need to use the domain users, you can specify the domain in the user field (like: 'DOMAIN/username') or you can add the 'domain' field to the command.

$ sudo mount -t cifs path_to_server_disk -o username=user,password=password,domain=domain mount_path

And if there are issues with the user permissions (you can not write in the mounted folder) you should include the information about the local user. When you include the user id of the local user, the mount command knows better how to manage your credentials to let you write in the device. So add 'uid=$(id -u),gid=$(id -g),forceuid,forcegid' to get the user and group ids from the current session.

$ sudo mount -t cifs path_to_server_disk -o username=user,password=password,domain=domain,uid=$(id -u),gid=$(id -g),forceuid,forcegid mount_path

Now, another trick. The folder servers can use different file system version standards to share the folders. Before the kernel 4.13, the default version used to mount elemets was 1.0, but after this version is 3.0. So, if the element you try to mount does not support the version 3.0 you have to define a supported version if you want to write in the mounted path. This can be done using the option 'vers=1.0' for example. The full example looks like:

$ sudo mount -t cifs path_to_server_disk -o username=user,password=password,domain=domain,vers=1.0,uid=$(id -u),gid=$(id -g),forceuid,forcegid mount_path

for example:

$ sudo mount -t cifs //server/download -o username=user,password=myPassword,domain=mydomain,uid=$(id -u),gid=$(id -g),forceuid,forcegid /media/user/server

Where: * -t smbfs : File system type to be mount (outdated, use cifs) * -t cifs : File system type to be mount * -o : are options passed to mount command, in this example I had passed two options. First argument is password (vivek) and second argument is password to connect remote windows box * //server/download : Windows 2000/NT share name * /media/user/server Linux mount point (to access share after mounting)

This is a full example on how to use this in a shell script:


read -p "User: " user
read -p "Password: " -s pass
sudo mount -t cifs //server/download -o username=$user,password=$pass /media/user/server
echo ""


  • -p adds a text prompt
  • -s reads the text in secure mode