Google Drive for Desktopを使い、GドライブをWSL2 から /mnt/g/ として見る
sudo mount -t drvfs G: /mnt/g
sudo vi /etc/fstab ## 以下を追加 G: /mnt/g drvfs defaults 0 0
sudo vi /etc/wsl.conf ##以下を追加 [automount] enabled = true mountFsTab = true
sudo vi /etc/wsl.conf ### [automount] enabled = true root = /mnt/ options = "metadata" mountFsTab = true
/mnt/c、/mnt/g が自動マウントされる
vi ~/.bashrc if ! mount | grep -q "/mnt/g"; then sudo mount -t drvfs G: /mnt/g fi
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
sudo vi /etc/wsl.conf [boot] systemd=true
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