How can I access more than 251GB in a Docker named volume in WSL2?

1.5k views Asked by At

I've created a named volume for my SQL Linux data files but the default size of 251G was too small. I followed the instructions to expand the size of a WSL2 VHD and then use resize2fs to increase to about 900GB.

sudo resize2fs /dev/sdb 900000M

Using df -Th I can see the increased size of 865GB, which is great. But the devices with the docker mounts still show the old size of 251GB.

Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/sdb       ext4      865G  1.2G  826G   1% /
tools          9p        3.8T  250G  3.5T   7% /init
none           devtmpfs   13G     0   13G   0% /dev
tmpfs          tmpfs      13G     0   13G   0% /sys/fs/cgroup
none           tmpfs      13G   12K   13G   1% /run
none           tmpfs      13G     0   13G   0% /run/lock
none           tmpfs      13G     0   13G   0% /run/shm
none           tmpfs      13G     0   13G   0% /run/user
tmpfs          tmpfs      13G  399M   13G   4% /mnt/wsl
C:\            9p        3.8T  250G  3.5T   7% /mnt/c
G:\            9p        3.8T  428G  3.4T  12% /mnt/g
/dev/sdd       ext4      251G  2.8G  236G   2% /mnt/wsl/docker-desktop-data/isocache
none           tmpfs      13G   12K   13G   1% /mnt/wsl/docker-desktop/shared-sockets/host-services
/dev/sdc       ext4      251G  126M  239G   1% /mnt/wsl/docker-desktop/docker-desktop-proxy
/dev/loop0     iso9660   384M  384M     0 100% /mnt/wsl/docker-desktop/cli-tools

I can't resize /dev/sdd or /dev/sdc - I get the following result:

The containing partition (or device) is only 67108864 (4k) blocks.
You requested a new size of 74240000 blocks.

I have tried restarting Docker and recreating the named volumes.

Can anyone tell me what I'm doing wrong here? How I can increase the space available for the named volumes or get docker to use all of the available space?

1

There are 1 answers

2
Milos Nedeljkovic On

Use the same instructions as in expand the size of a WSL2 VHD, only instead of doing steps 2. and 3. use %LOCALAPPDATA%\Docker\wsl\data\<disk>.vhdx as <pathToVHD> in further steps, where <disk>.vhdx is most likely ext4.vhdx and full path is most likely %LOCALAPPDATA%\Docker\wsl\data\ext4.vhdx.

Also, in step 6. be sure to use Docker partition in resize2fs command instead of wsl2 partition. In your opening post the Docker one would be /dev/sdd instead of wsl2 /dev/sdb.