- https://cloudbytes.dev/snippets/how-to-install-multiple-instances-of-ubuntu-in-wsl2
- https://gist.github.com/ScriptAutomate/f94cd44dacd0f420fae65414e717212d?permalink_comment_id=3627426
- open windows powershell in administrative mode
- check online versions available:
wsl -l -o - check installed versions:
wsl -l -v - change directory to
E:\BigFiles\Images\wsl-images Remove-Item alias:curlcurl -kL -o ubuntu-22-04-wsl-rootfs-tar.gz "https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz"curl -kL -o ubuntu-22-10-wsl-rootfs-tar.gz "https://cloud-images.ubuntu.com/wsl/kinetic/current/ubuntu-kinetic-wsl-amd64-wsl.rootfs.tar.gz"curl -kL -o ubuntu-23-10-wsl-rootfs-tar.gz "https://cloud-images.ubuntu.com/wsl/mantic/current/ubuntu-mantic-wsl-amd64-wsl.rootfs.tar.gz"curl -kL -o ubuntu-24-04-wsl-rootfs-tar.gz "https://cloud-images.ubuntu.com/wsl/noble/current/ubuntu-noble-wsl-amd64-ubuntu24.04lts.rootfs.tar.gz"- wsl is installed at: %LOCALAPPDATA%\Packages${Org}-${OS}-${Random} in our case it is
mkdir "C:\Users\xbalaji\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu22.10_01"mkdir "C:\Users\xbalaji\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu24.04"
wsl --import ubuntu-kinetic-1 "C:\Users\xbalaji\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu22.10_01" .\ubuntu-22-10-wsl-rootfs-tar.gzwsl --import ubuntu-noble-1 "C:\Users\xbalaji\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu24.04" .\ubuntu-24-04-wsl-rootfs-tar.gz
wslconfig /l- list all the images installed in the systemwslconfig /s ubuntu-noble-1- make the recently installed distribution as default
wsl -l -vwsl --terminate "Ubuntu-22.04"wslconfig /u Ubuntu-22.04
sudo mkdir -p /mnt/r /mnt/qsudo apt -y install cifs-utilssudo mount -t cifs -o user=$REMOTEUSER,pass=$REMOTEPASS //192.168.1.4/xbalaji /mnt/rsudo mount -t cifs -o user=$REMOTEUSER,pass=$REMOTEPASS //192.168.1.20/xbalaji-home /mnt/q
Commands to mount mac machine directories in wsl, important to give read write permission for the user
- In the MAC
login to the mac, open finder, set the folder to shareor do the following in the terminalsudo sharing -a "$HOME/xbalaji-dev" -S xbalaji-devsudo chmod -R 755 "$HOME/xbalaji-dev"sudo chown -R $USER:staff "$HOME/xbalaji-dev"sudo sharing -r xbalaji-dev<-- to remove the share, use the key from the list command belowsudo sharing -l -f json<-- to list the shares
- In the WSL
sudo mkdir -p /mnt/r /mnt/qsudo apt -y install cifs-utilssudo chown xbalaji:xbalaji /mnt/rsudo mount -t cifs --verbose -o uid=$(id -u),gid=$(id -g),rw,user=$REMOTEUSER,pass=$REMOTEPASS //192.168.1.3/xbalaji-dev /mnt/r
useradd -m -s /bin/bash -G sudo xbalajiecho "xbalaji:balajiv" | sudo chpasswdgrep sudo /etc/groupuseradd -m -s /bin/bash -G sudo xbalajieecho "xbalajie:balajiv" | sudo chpasswdgrep sudo /etc/groupusermod -d /mnt/e/Balaji/home/ xbalajigrep xbal /etc/passwdchown -R xbalaji:xbalaji /mnt/e/Balaji/home
- refer: https://superuser.com/questions/1566022/how-to-set-default-user-for-manually-installed-wsl-distro
- refer: https://cloudbytes.dev/snippets/how-to-install-multiple-instances-of-ubuntu-in-wsl2 - step 6 (configure default user)
- as root:
-
- execute:
echo -e "[user]\ndefault=xbalaji" > /etc/wsl.conf
- execute:
-
- terminate the instance:
wsl --terminate ubuntu-mantic-1
- terminate the instance:
-
- update the settings
wsl.exe -d ubuntu-mantic-1 -u xbalaji
- update the settings
[boot]
systemd=true
[user]
default=xbalaji
[automount]
enabled = true
options = "metadata,umask=22,fmask=11"