Is usb supported on Bash on Ubuntu on Windows 10?
Good news, it is now possible to mount USB media (including FAT formated) and network shares with drvfs on Windows 10:
Mount removable media: (e.g. D:)
$ sudo mkdir /mnt/d
$ sudo mount -t drvfs D: /mnt/d
To safely unmount
$ sudo umount /mnt/d
You can also mount network shares without smbfs:
$ sudo mount -t drvfs '\\server\share' /mnt/share
You need at least Build 16176 so you might have to opt-in to the Windows Insider programm and then update Windows. Source: https://blogs.msdn.microsoft.com/wsl/2017/04/18/file-system-improvements-to-the-windows-subsystem-for-linux/
External HDD on bash on ubuntu on windows
The Ubuntu on Windows on the current build (Build 14393, a.k.a. anniversary update) doesn't support accessing external drive. This feature is on their backlog for future consideration.
Source: https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13355724-unable-to-access-usb-devices-from-bash
Edit: Mounting removable drives are supported since Build 16176. [1][2]
- https://blogs.msdn.microsoft.com/wsl/2017/04/18/file-system-improvements-to-the-windows-subsystem-for-linux/
- https://stackoverflow.com/a/44001783/643011
- https://learn.microsoft.com/en-us/windows/wsl/wsl2-mount-disk
Move WSL (Bash on Windows) root filesystem to another hard drive?
If you are using Windows 10 version 1903 (April 2019 Update) or later, you can try the WSL command line tool with the export
and import
options. If you are using an older Windows 10 version, you can move the distribution to another drive using lxRunOffline.
Using the WSL command line tool
In Windows 10 version 1903 (April 2019 Update) or later, you can use the wsl.exe
command line tool.
1. Export the distribution. Create a .tar
file with the distribution to move using wsl.exe --export
wsl.exe --export <DistributionName> <Tar-FileName>
For instance, to export an Ubuntu
distribution, you can use
C:\> wsl.exe --export Ubuntu c:\data\ubuntu.tar
2. Import the distribution into the target folder. Then, you can import the exported distribution into another folder
wsl.exe --import <DistributionName> <Folder-To-Install> <Tar-FileName>
For instance, to import the exported Ubuntu
into a new UbuntuCustom
distribution, you can use
C:\> wsl.exe --import UbuntuCustom d:\wsl\UbuntuCustom c:\data\ubuntu.tar
NOTE: You may check an script for moving WSL distros that use these commands at https://github.com/pxlrbt/move-wsl
Using LxRunOffline
In any Windows 10 version, you can move the distribution to another drive using lxRunOffline.
1. Set permissions to the target folder. First, I think you must set some permissions to the folder where the distribution will be moved. You may use icacls <dir> /grant "<user>:(OI)(CI)(F)"
to set the proper permissions.
C:\> whoami
test\jaime
C:\> icacls D:\wsl /grant "jaime:(OI)(CI)(F)"
NOTE: In addition to the above permissions, I have activated the long path names in Windows.
2. Move the distribution. Using lxrunoffline move
.
C:\wsl> lxrunoffline move -n Ubuntu-18.04 -d d:\wsl\installed\Ubuntu-18.04
You may check the installation folder using
C:\wsl> lxrunoffline get-dir -n Ubuntu-18.04
d:\wsl\installed\Ubuntu-18.04
3. Run the distribution. after moving the distribution, you can run the distribution using wsl
or the same lxrunoffline
C:\wsl> lxrunoffline run -n Ubuntu-18.04 -w
user@test:~$ exit
logout
C:\wsl> wsl
user@test:/mnt/c/wsl$ exit
logout
Related Topics
How to Preserve Command Line Spaces in a Linux Application
How to Shell Have More Than One Job in Linux
Learning Kernel Hacking and Embedded Development at Home
Check Whether a Certain File Type/Extension Exists in Directory
How to Set Nginx Max Open Files
How to Count Number of Unique Values of a Field in a Tab-Delimited Text File
Id_Rsa.Pub File Ssh Error: Invalid Format
Linux - Yum Install Gcc - Missing Kernel-Headers
How to Make Find and Printf Works in Bash Script
Delimited by Comma Using Awk or Sed with the Tags Below
In Unix, How to Run 'Make' in a Directory Without Cd'Ing to That Directory First
How to Know Which of the /Dev/Input/Eventx (X=0..7) Have the Linux Input Stream
I Get "Dquote>" as a Result of Executing a Program in Linux Shell
Is Usb Supported on Bash on Ubuntu on Windows 10
Difference Between Vm.Dirty_Ratio and Vm.Dirty_Background_Ratio