On 13.8.2024 12.23, Roger Oberholtzer wrote:
I have tried installing openSUSE Leap 15.6 in WSL 2. It actually works great. My motivation was that I should be able to mount the ext4 partition via wsl, and then access it in Windows. See, for example, https://windowsreport.com/ext4-windows-11/. That is sort of true if by 'access' you mean in Windows Explorer only. That is not a workable solution. I need access in programs and shell scripts.
By programs I assume you mean CLI applications? You can access files on WSL2 mounted partitions via \\wsl$\<Distro>\<Mountpoint> path either from Command Prompt (cmd.exe) or from PowerShell (https://learn.microsoft.com/en-us/windows/wsl/wsl2-mount-disk#access-the-dis...). The documentation is a bit misleading, since it only mentions accessing the disk content from File Explorer, but the path does work in Command Prompt or PowerShell too.
Finally, I tried Paragon Software's ext4 for Windows. It seems to be properly read/write and, generally looks great. But then I see that I cannot access SQLite databases that are on these disks. SQLite (general programs and database browsers) all complain that the database is locked. We had this issue when, from Linux, accessing databases on CIFS mounted drivers. That was sorted by adding nobrl to the CIFS mount command on Linux. It's a known issue. So this method was close, but no cigar. A support question is pending as I cannot think I am the first person who wanted to access an SQLite database this way.
SQLite database file access seems to hinge on the fact that WSL2 mounted filesystems do not support file locking when accessed from the Windows side (https://github.com/microsoft/WSL/issues/4689, https://github.com/microsoft/WSL/issues/5762). Depending on your use case, you may be able to work around that problem by opening the SQLite database using file: URI and passing some query string parameters (nolock=1 or immutable=1): https://www.codejam.info/2021/10/bypass-sqlite-exclusive-lock.html https://www.sqlite.org/uri.html C:\Users\testuser>sqlite3 file:\\wsl$\opensuse-tumbleweed\mnt\wsl\backup\clementine.db SQLite version 3.46.0 2024-05-23 13:25:27 (UTF-16 console I/O) Enter ".help" for usage hints. sqlite> .databases main: \\wsl$\opensuse-tumbleweed\mnt\wsl\backup\clementine.db r/w sqlite> .tables Error: database is locked sqlite> .quit C:\Users\testuser>sqlite3 file:\\wsl$\opensuse-tumbleweed\mnt\wsl\backup\clementine.db?nolock=1 SQLite version 3.46.0 2024-05-23 13:25:27 (UTF-16 console I/O) Enter ".help" for usage hints. sqlite> .databases main: \\wsl$\opensuse-tumbleweed\mnt\wsl\backup\clementine.db r/w sqlite> .tables amazon_cloud_drive_songs podcast_episodes amazon_cloud_drive_songs_fts podcasts amazon_cloud_drive_songs_fts_content schema_version amazon_cloud_drive_songs_fts_segdir seafile_songs amazon_cloud_drive_songs_fts_segments seafile_songs_fts box_songs seafile_songs_fts_content box_songs_fts seafile_songs_fts_segdir box_songs_fts_content seafile_songs_fts_segments box_songs_fts_segdir skydrive_songs box_songs_fts_segments skydrive_songs_fts devices skydrive_songs_fts_content directories skydrive_songs_fts_segdir dropbox_songs skydrive_songs_fts_segments dropbox_songs_fts songs dropbox_songs_fts_content songs_fts ... sqlite> select playcount from songs where title = 'How Dare You'; 1 sqlite> update songs set playcount = 2 where title = 'How Dare You'; sqlite> select playcount from songs where title = 'How Dare You'; 2 sqlite> .quit C:\Users\testuser>sqlite3 file:\\wsl$\opensuse-tumbleweed\mnt\wsl\backup\clementine.db?immutable=1 SQLite version 3.46.0 2024-05-23 13:25:27 (UTF-16 console I/O) Enter ".help" for usage hints. sqlite> .databases main: \\wsl$\opensuse-tumbleweed\mnt\wsl\backup\clementine.db r/o sqlite> select playcount from songs where title = 'How Dare You'; 2 sqlite> update songs set playcount = 3 where title = 'How Dare You'; Runtime error: attempt to write a readonly database (8) sqlite> .quit -- Martti Laaksonen