PC ボックスのネットワークドライブを drvfs を使用して wsl2 にマウントすると、手動では機能しますが、/etc/fstab では機能しません。

PC ボックスのネットワークドライブを drvfs を使用して wsl2 にマウントすると、手動では機能しますが、/etc/fstab では機能しません。

Box ドライブを wsl2 にマウントして、2 つの異なるシステム (Windows と Linux) 上の同じローカル/クラウド同期ファイルにアクセスできるようにしたいと考えています。Box は FAT32 ファイル システムであり、drvfs マウントによってサポートされていると思います。

次のマウント コマンドを使用して .bashrc ファイルからマウントすると、問題なくマウントできます。

sudo mount -t drvfs 'C:\Users\Jakda\Box' /mnt/box

その後、ホームディレクトリのシンボリックリンクを介して /mnt/box にアクセスできるようになります。

これの問題は、WSL ターミナルを開くたびに sudo パスワードを入力する必要があることですが、これは必ずしも実行できるわけではありません。

この行を/etc/fstab

'C:\Users\Jakda\Box'    /mnt/box        drvfs     defaults     0       0

実行するとmount -a次のようになります:

<4>WARNING: mount: waiting for virtio device...
<3>init: (110) ERROR: MountPlan9WithRetry:285: mount drvfsa on /mnt/box (cache=mmap,rw,msize=262144,trans=virtio,aname=drvfs;path='C:\Users\Jakda\Box';symlinkroot=/mnt/) failed: 2
mount: No such file or directory

しばらくこれを試していますが、何をすればいいのかわかりません。

答え1

Linux でのファイルの処理は/etc/fstab関数によって行われますgetmntent。マニュアル ページによると、次のようになります。

GETMNTENT(3)               Linux Programmer's Manual              GETMNTENT(3)

.
.
.

DESCRIPTION
       These routines are used  to  access  the  filesystem  description  file
       /etc/fstab and the mounted filesystem description file /etc/mtab.

.
.
.

       Since fields in the mtab and fstab files are separated  by  whitespace,
       octal  escapes  are  used to represent the characters space (\040), tab
       (\011), newline (\012), and backslash (\\) in those files when they oc‐
       cur in one of the four strings in a mntent structure.  The routines ad‐
       dmntent() and getmntent() will convert from  string  representation  to
       escaped  representation  and back.  When converting from escaped repre‐
       sentation, the sequence \134 is also converted to a backslash.

(これらの中で最も一般的に使用されているのは\040スペース文字です。タブと改行は Linux パス名では合法ですが、実際にはほとんど使用されません)。

したがって、引用符を削除し、バックスラッシュを8進エスケープに置き換えます\134

C:\134Users\134Jakda\134Box    /mnt/box        drvfs     defaults     0       0

関連情報