0
1

wsl2 samba 開発環境構築

Last updated at Posted at 2024-01-09

wsl2 samba 開発環境構築手順

wslで作業

  1. sambaをインストール
    sudo apt update
    sudo apt install samba
    
  2. sambaの設定ファイルの末尾に追記
    /etc/samba/smb.conf
    [share]
    path = {共有したいディレクトリパス}
    read only = no
    guest ok = yes
    writable = yes
    force user = {username}
    force group = {groupname}
    
  3. samba起動用シェルスクリプトを作成
    ~/start
    #!/bin/bash
    
    set -eax
    
    sudo mkdir -p /run/samba/ncalrpc
    sudo systemctl restart smbd
    sudo systemctl status smbd --no-pager
    sudo systemctl restart nmbd
    sudo systemctl status nmbd --no-pager
    
    ~/startの権限を実行可能に変更
    sudo chmod 777 ~/start
    

windowsで作業

  1. 起動用バッチを作成
    wslmount.bat
    wsl -d Ubuntu exec sh -c "~/start"
    FOR /F "usebackq" %%i in (`wsl -d Ubuntu exec hostname -I`) do set IP=%%i
    echo %IP%
    net use Z: /delete
    net use Z: \\%IP%\share /persistent:no
    
  2. マシン起動時に自動実行する
    wslmount.batをC:\Users\{UserName}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startupに移動
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1