我想使用 Manjaro Linux 共享两台计算机的驱动器,并将它们全部视为两台计算机中的一个目录。
我一直在使用 mergefs 和 sshfs,当我与 A 共享 B 的一个驱动器、将它们合并并与 B 共享合并的文件夹时,它正在工作。现在我也尝试过合并 B 的驱动器,但我还没有设法做到了。
如果可能的话,我希望计算机在另一台计算机断开连接时仍然可以工作。当另一台计算机断开连接时,NFS 会使另一台计算机挂起,这就是我最终使用 sshfs 的原因。
我之前遇到的唯一错误是某些应用程序给出input/output error
或permission denied
。我猜这是因为我没有适当的权限。我也想避免这个错误,而不必经常执行某些操作chmod -R 777 /mnt/merged
。我不知道是否这个解决方案与 mergefs 一起使用。
这就是我尝试做的但没有成功
user@A ❯ cat /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=1615d12a-a9fb-41a9-a84b-34c618f16832 /mnt/hdd1 ext4 nosuid,nodev,nofail,x-gvfs-show 0 0
UUID=d605a480-f133-443c-8fe7-5b0a2d1c60c1 /mnt/hdd2 ext4 nosuid,nodev,nofail,x-gvfs-show 0 0
[email protected]:/mnt/hdd0 /mnt/hdd0 fuse.sshfs IdentityFile=/home/user/.ssh/id_rsa,uid=1000,gid=1000,allow_other,default_permissions,_netdev,follow_symlinks,ServerAliveInterval=45,ServerAliveCountMax=2,reconnect,noatime,auto 0 0
/mnt/hdd* /mnt/storage fuse.mergerfs allow_other,use_ino,cache.files=partial,dropcacheonclose=true,ignorepponrename=true,func.mkdir=epall,x-gvfs-show 0 0
user@B ❯ cat /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=301e3d8d-6c0a-4f7c-864b-4185a70efbb0 /mnt/hdd1 auto nosuid,nodev,nofail,x-gvfs-show 0 0
UUID=be8b9fd3-7ed2-45ae-881a-25fa06f4de47 /mnt/hdd2 auto nosuid,nodev,nofail,x-gvfs-show 0 0
[email protected]:/mnt/storage /mnt/hdd0 fuse.sshfs IdentityFile=/home/user/.ssh/id_rsa,uid=1000,gid=1000,allow_other,default_permissions,_netdev,follow_symlinks,ServerAliveInterval=45,ServerAliveCountMax=2,reconnect,noatime 0 0
/mnt/hdd* /mnt/storage fuse.mergerfs allow_other,use_ino,cache.files=partial,dropcacheonclose=true,ignorepponrename=true,func.mkdir=epall,x-gvfs-show 0 0
这就是我正在使用的。它会减慢对合并文件夹的访问速度,因为它来回共享驱动器。
user@A ❯ cat /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=1615d12a-a9fb-41a9-a84b-34c618f16832 /mnt/hdd1 ext4 nosuid,nodev,nofail,x-gvfs-show 0 0
UUID=d605a480-f133-443c-8fe7-5b0a2d1c60c1 /mnt/hdd2 ext4 nosuid,nodev,nofail,x-gvfs-show 0 0
[email protected]:/mnt/hdd1 /mnt/hdd0 fuse.sshfs _netdev,follow_symlinks,IdentityFile=/home/user/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1000,ServerAliveInterval=45,ServerAliveCountMax=2,reconnect,noatime,auto,x-gvfs-show 0 0
/mnt/hdd* /mnt/storage fuse.mergerfs allow_other,use_ino,cache.files=partial,dropcacheonclose=true,ignorepponrename=true,func.mkdir=epall,x-gvfs-show 0 0
user@B ❯ cat /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=301e3d8d-6c0a-4f7c-864b-4185a70efbb0 /mnt/hdd1 auto nosuid,nodev,nofail,x-gvfs-show 0 0
UUID=be8b9fd3-7ed2-45ae-881a-25fa06f4de47 /mnt/hdd2 auto nosuid,nodev,nofail,x-gvfs-show 0 0
[email protected]:/mnt/storage /mnt/storage fuse.sshfs _netdev,follow_symlinks,IdentityFile=/home/user/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1000,ServerAliveInterval=45,ServerAliveCountMax=2,reconnect,noatime,auto,x-gvfs-show 0 0
答案1
user@A ❯ cat /etc/fstab
/mnt/hdd* /mnt/merged fuse.mergerfs allow_other,use_ino,cache.files=partial,dropcacheonclose=true,ignorepponrename=true,func.mkdir=epall,posix_acl=true 0 0
[email protected]:/mnt/merged /mnt/shared fuse.sshfs _netdev,user,idmap=user,follow_symlinks,IdentityFile=/home/user/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1001,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,noatime,x-gvfs-show 0 0
/mnt/hdd*:/mnt/shared /mnt/storage fuse.mergerfs allow_other,use_ino,cache.files=partial,dropcacheonclose=true,ignorepponrename=true,func.mkdir=epall,posix_acl=true,x-gvfs-show 0 0
user@B ❯ cat /etc/fstab
/mnt/hdd* /mnt/merged fuse.mergerfs allow_other,use_ino,cache.files=partial,dropcacheonclose=true,ignorepponrename=true,func.mkdir=epall,posix_acl=true 0 0
[email protected]:/mnt/merged /mnt/shared fuse.sshfs _netdev,user,idmap=user,follow_symlinks,IdentityFile=/home/user/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1001,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,noatime,x-gvfs-show 0 0
/mnt/hdd*:/mnt/shared /mnt/storage fuse.mergerfs allow_other,use_ino,cache.files=partial,dropcacheonclose=true,ignorepponrename=true,func.mkdir=epall,posix_acl=true,x-gvfs-show 0 0
我在两台电脑上都这样做了
- 更改权限
❯ sudo chown $USER:$USER /mnt/storage &
❯ chmod -R ugo+rw /mnt/storage &
- 设置该
setgid
位,以便下面的文件/文件夹将使用相同的组创建
❯ chmod g+s /mnt/storage &
- 设置组和其他组的默认 ACL
# Gives read,write,exec permissions for currently existing files and folders, recursively.
❯ setfacl -R -m u::rwx,g::rwx,o::rwx /mnt/storage &
# Gives rwx permissions by default, recursively.
❯ setfacl -R -d -m u::rwx,g::rwx,o::rwx /mnt/storage &