Skip to content

WSL storage path configuration

WSL storage path configuration refers to the administrative task of specifying the exact file system location where a Windows Subsystem for Linux (WSL) distribution stores its virtual disk image. By default, WSL manages these paths automatically, but administrators can define custom paths during the import or creation process to organize storage or utilize specific drives.

Configuration via Import

The most direct method to configure the storage path is during the distribution import process. The wsl --import command requires a target location parameter, which determines where the new instance's ext4 virtual hard disk (VHD) will be stored.^[600-developer-tools-windows-wsl-command.md]

Syntax and Parameters

The command syntax follows the pattern wsl --import <DistributionName> <InstallLocation> <FileName>.^[600-developer-tools-windows-wsl-command.md]

  • DistributionName: The name you wish to assign to the Linux instance (e.g., U20.04-tommy).
  • InstallLocation: The directory path where the instance data will be saved (e.g., D:\install\wsl-work\storage\Ubuntu-20.04-tommy).
  • FileName: The path to the backup .tar file being used as the source image (e.g., D:\install\wsl-work\image\Ubuntu-20.04-20220121.tar).^[600-developer-tools-windows-wsl-command.md]

Example

The following PowerShell command demonstrates importing a custom Ubuntu distribution while explicitly defining its storage path on the D: drive:^[600-developer-tools-windows-wsl-command.md]

wsl --import U20.04-tommy D:\install\wsl-work\storage\Ubuntu-20.04-tommy D:\install\wsl-work\image\Ubuntu-20.04-20220121.tar
  • [[WSL]]
  • [[Command line interface]]

Sources

^[600-developer-tools-windows-wsl-command.md]