WSL: Writing USB key broken after April Update
After April update I cannot copy files on USB key preserving their timestamps.
Before the update, I had created the mount point:
sudo mkdir -p /mnt/e/
and could copy files preserving timestamps:
sudo mount -t drvfs e: /mnt/e
/bin/cp -p foo /mnt/e/
rsync -av bar /mnt/e/
I did and used this since Fall Creators Update.
Now, I get:
/bin/cp -p foo /mnt/e/
/bin/cp: preservati gli orari di '/mnt/e/foo': Operazione non permessa
/usr/bin/rsync -av foo /mnt/e/
sending incremental file list
foo
rsync: mkstemp "/mnt/e/.foo.lMsStT" failed: Operation not permitted (1)
sent 103 bytes received 111 bytes 428.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.1]
If you do not have a quick solution about this, what I described is a big regression of WSL April Update which has brought WSL back before Fall Update was released…
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 15 (5 by maintainers)
This is indeed a manifestation of #2770. When you mount your USB stick with default options, all the files will be owned by root, and your user doesn’t have the permission to change the timestamps in that case. DrvFs used to bypass the owner check, but this is no longer the case since we added support for different owners with the “metadata” option.
Mounting with “metadata” works in this case because it allows the files you create to be owned by you, rather than root, however it’s not the only option (and doesn’t solve the problem for files already created by Windows, which don’t have metadata and would therefore still be owned by root). For this reason, we added mount options to DrvFs that specify the owner uid and gid to use for files that don’t have metadata.
The solution is to mount your USB drive using mount options setting the default uid/gid for files without metadata:
sudo mount -t drvfs e: /mnt/e -o uid=1000,gid=1000You should use your actual uid/gid instead of 1000 (run
idto determine your default account’s uid/gid). Using the metadata option shouldn’t be necessary unless you want to use non-default Linux permissions. If you do want to use this option, I recommend you use it together with the uid/gid options.DrvFs mount options are described at the bottom of this blog post.