目次

「OS」一覧に戻る

WSLでGoogleDrvieを利用


WindowsでのWSL2の利用方法



方法1:Windows 側でマウント → WSL から参照

Google Drive for Desktopを使い、GドライブをWSL2 から /mnt/g/ として見る

sudo mount -t drvfs G: /mnt/g


方法2:rclone + mount

sudo apt update
sudo apt install -y rclone fuse3
rclone config

n) New remote
name> gdrive
Storage> drive
client_id> (空でOK)
client_secret> (空でOK)
scope> 1 (Full access)
root_folder_id> (空)
service_account_file> (空)
Edit advanced config? n
Use auto config? y
sudo mkdir -p ~/gdrive

## マウント
rclone mount gdrive: ~/gdrive \
  --vfs-cache-mode writes \
  --dir-cache-time 1h \
  --poll-interval 1m \
  --allow-other
## アンマウント
fusermount3 -u ~/gdrive
systemd で常時マウント
sudo vi /etc/wsl.conf

[boot]
systemd=true
<code>

<code>
wsl --shutdown
sudo vi /etc/systemd/system/rclone-gdrive.service
[Unit]
Description=Rclone Mount Google Drive
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/rclone mount gdrive: /home/<ユーザー名>/gdrive \
  --vfs-cache-mode writes \
  --allow-other
ExecStop=/bin/fusermount3 -u /home/<ユーザー名>/gdrive
Restart=always
User=<ユーザー名>

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reexec
sudo systemctl enable --now rclone-gdrive


WindowsでのWSL2の利用方法





「OS」一覧に戻る