侧边栏壁纸
  • 累计撰写 99 篇文章
  • 累计创建 54 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

Mounting WebDAV Drive in Debian

FlyingEagle
2023-04-25 / 0 评论 / 0 点赞 / 40 阅读 / 8,056 字

Mounting WebDAV Drive in Debian

Message From You:

how to mount webdav in debian as mnt drive?

Message From ChatGPT:

To mount a WebDAV share as a mount drive in Debian, follow these steps:

  1. Install davfs2 package:

sudo apt-get install davfs2

  1. Create a directory for the mount point:

sudo mkdir /mnt/webdav

  1. Edit the davfs2 configuration file /etc/davfs2/davfs2.conf and uncomment the line #use_locks 1 by removing the # character:

sudo nano /etc/davfs2/davfs2.conf

  1. Add the mount point to the davfs2 configuration file /etc/fstab by appending the following line:

https://webdav.example.com/remote.php/webdav /mnt/webdav davfs user,noauto 0 0

Note: Replace https://webdav.example.com/remote.php/webdav with your WebDAV share URL.

  1. Save and close the file /etc/fstab.

  2. Create a file ~/.davfs2/secrets with the following content:

https://webdav.example.com/remote.php/webdav username password

Note: Replace https://webdav.example.com/remote.php/webdav with your WebDAV share URL and replace username and password with your WebDAV account credentials.

  1. Set the permission of the file ~/.davfs2/secrets to 600:

sudo chmod 600 ~/.davfs2/secrets

  1. Mount the WebDAV share by running the following command:

sudo mount /mnt/webdav

  1. Enter your WebDAV account credentials when prompted.

Now you can access your WebDAV share as a mount drive at /mnt/webdav. To unmount the WebDAV share, run the following command:

sudo umount /mnt/webdav

Message From You:

how to create the file in point 6

Message From ChatGPT:

To create the file ~/.davfs2/secrets in point 6, you can use any text editor of your choice. Here are the steps to create the file using the Nano text editor:

  1. Open the terminal.
  2. Type nano ~/.davfs2/secrets to open the Nano text editor with a new blank file.
  3. Type the following content in the file, replacing the variables https://webdav.example.com/remote.php/webdav, USERNAME, and PASSWORD with your WebDAV server URL, username and password:
https://webdav.example.com/remote.php/webdav USERNAME PASSWORD
  1. Press Ctrl + O to save the file.
  2. Press Ctrl + X to exit the Nano text editor.

Note: If you use a different text editor or already have a file named secrets in the ~/.davfs2/ directory, you can use that instead of creating a new one.

Message From You:

it shown error [ Error writing /root/.davfs2/secrets: No such file or directory ]

Message From ChatGPT:

If you receive the error message [ Error writing /root/.davfs2/secrets: No such file or directory ], it means that the ~/.davfs2/ directory might not exist yet.

To solve this, follow these steps:

  1. Open the terminal.
  2. Type mkdir -p ~/.davfs2 to create the ~/.davfs2/ directory if it does not exist already.
  3. Type nano ~/.davfs2/secrets to open the Nano text editor with a new blank file.
  4. Type the following content in the file, replacing the variables https://webdav.example.com/remote.php/webdav, USERNAME, and PASSWORD with your WebDAV server URL, username and password:
https://webdav.example.com/remote.php/webdav USERNAME PASSWORD
  1. Press Ctrl + O to save the file.
  2. Press Ctrl + X to exit the Nano text editor.

Now you can continue with the remaining steps to mount the WebDAV share as a mount drive.

Message From You:

why the webdav disconnected once I closed the terminal?

Message From ChatGPT:

If the WebDAV share disconnects once you close the terminal, it is because the mount point /mnt/webdav was mounted with the superuser (sudo) privileges from the terminal.

The sudo command temporarily elevates your privileges to those of the superuser (i.e., root) in order to mount the WebDAV share. But when you close the terminal, the elevated privileges also end, causing the WebDAV share to be unmounted.

To permanently mount the WebDAV share, you need to add an entry to the /etc/fstab file, which specifies the mount options for the device at boot time.

To do this, you can follow these steps:

  1. Open the /etc/fstab file with a text editor using the command: sudo nano /etc/fstab.
  2. Add the following line at the end of the /etc/fstab file:
https://webdav.example.com/remote.php/webdav /mnt/webdav davfs user,rw,noauto 0 0

Note: Replace https://webdav.example.com/remote.php/webdav with the URL of your WebDAV server.

  1. Save the modified /etc/fstab file by pressing Ctrl + O, then exit the text editor by pressing Ctrl + X.
  2. Create a new directory in your home directory to store your WebDAV credentials file by typing the following command: mkdir -p ~/.davfs2.
  3. Create your secrets file in the created directory with appropriate content by typing: nano ~/.davfs2/secrets. See the sample content:
https://webdav.example.com/remote.php/webdav USERNAME PASSWORD
  1. Save the secrets file by pressing Ctrl + O, then exit the text editor by pressing Ctrl + X.
  2. Change the permissions of the secrets file to be readable only by the owner of the file by typing the following command: chmod 600 ~/.davfs2/secrets.
  3. You can now mount the WebDAV share by typing the following command: mount /mnt/webdav. The noauto option in /etc/fstab means that the WebDAV share will not be mounted automatically during the boot process. To mount the share, you need to manually run the mount /mnt/webdav command.

Now the WebDAV share will be permanently mounted on your system and you don’t need to start over every time you start a new terminal session, unless you intentionally unmount it with the sudo umount /mnt/webdav command.

Message From You:

I didn’t use the sudo to promt the command

Message From ChatGPT:

If you did not use sudo to mount the WebDAV share as a mount drive, it might be because you already have the necessary permissions to mount it on your system.

However, if the WebDAV share still disconnects once you close the terminal, you can create an entry in the /etc/fstab file, as explained in the previous message, to make the mount permanent.

You can proceed with the remaining steps to create the directory, modify the secrets file, and add the mount point to /etc/fstab.

Finally, you can run the mount /mnt/webdav command to mount the WebDAV share. This will ensure that the WebDAV share is always available as a mount drive, even after you close the terminal.

Message From You:

if I want to mount another webdav, how do I amend the above command?

Message From ChatGPT:

If you want to mount another WebDAV share on your system, you can follow the same process explained earlier with some modifications.

First, you will need to create a new mount point directory to mount the second WebDAV share. For example, let’s say you want to mount the second WebDAV share at /mnt/webdav2, you can create a new directory by typing the following command: sudo mkdir /mnt/webdav2.

Then you can modify the /etc/fstab file to include an entry for the new WebDAV share. For example, let’s say the new WebDAV share has the URL https://webdav2.example.com and your desired mount point is /mnt/webdav2, you can add the following line to the /etc/fstab file:

https://webdav2.example.com /mnt/webdav2 davfs user,rw,noauto 0 0

You will also need to create a new secrets file with the credentials for the new WebDAV share. To do this, you can follow the steps I explained earlier:

  1. Create a new directory for the secrets file by typing the following command: mkdir -p ~/.davfs2.
  2. Create the secrets file for the new WebDAV share by typing the following command: nano ~/.davfs2/secrets.
  3. Add the credentials for the new WebDAV share in the format https://webdav2.example.com USERNAME PASSWORD and then save the file and exit the text editor.
  4. Change the permissions of the secrets file by typing the following command: chmod 600 ~/.davfs2/secrets.

Finally, you can mount the new WebDAV share by running the command mount /mnt/webdav2. This will mount the new WebDAV share on your system, and it will persist even after you close the terminal.

Message From You:

if I want to revise the mounted drive name in /mnt, what should I do?

Message From ChatGPT:

If you want to rename the mount point directory for your WebDAV share located in /mnt, there are a few steps you can follow:

  1. Unmount the WebDAV share by running the following command: umount /mnt/webdav.
  2. Rename the mount point directory to the desired name by running a command similar to the following: sudo mv /mnt/webdav /mnt/new-name.
  3. Update the /etc/fstab file with the new directory name. For example, if you changed the directory name to /mnt/new-name, you would change the entry in the /etc/fstab file to reflect that. It would look similar to this: https://webdav.example.com /mnt/new-name davfs user,rw,noauto 0 0.
  4. Mount the WebDAV share again using the updated mount point directory by running the command mount /mnt/new-name.

After these steps, the WebDAV share will be mounted using the new directory name, and it will still be persistent even after closing the terminal.

Message From You:

single webdav can be mount to how many debian?

Message From ChatGPT:

A single WebDAV share can be mounted on multiple Debian systems, as long as the credentials used to access the share are valid on each system.

To mount the same WebDAV share on another Debian system, you can follow the same steps you used to mount it on the first system. First, you would need to install the davfs2 package, then create a mount point directory, edit the davfs2 configuration file, create a credentials file for the WebDAV account, and add an entry to the /etc/fstab file to enable permanent mounting.

You would then be able to mount the WebDAV share on the other Debian system by running the command mount <mount-point>. Just be sure to use the same credentials file and mount point directory that you used on the first system.

0

评论区