LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-27-2022, 08:01 AM   #1
gllisse
LQ Newbie
 
Registered: Dec 2022
Posts: 4

Rep: Reputation: 0
How to disable linux virtual hard disk cache


Hello,
'd like to disable write cache for a virtual hard drive on linux. Is it possible ?

Actually, I'd like to use the same virtual hard disk mounted within 2 different WSL instances running at the same time, and in such a way that this virtual hard disk is synced between both WSL instances. Up to now, I can mount the same virtual hard disk and access it with 2 different WSL instances, but modifications to this virtual hard disk are not synced between the different WSL instances. To sync modifications from the other WSL instance, I have to umount and remount the virtual hard disk.
I've tried echo 1 | sudo tee /proc/sys/vm/drop_caches;
and also sudo hdparm -W 0 /mnt/d/VHD_home.img ( VHD_home.img is the mounted VHD ), but neither trick works.

Thanks for your help!
 
Old 12-28-2022, 05:28 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,154

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
Sharing a VHD between guests (as WLS2 instances are) would be a function of the virtualizing hipervisor. That would be Windows. Unless it is specifically supported, it ain't.
The fact that drop_caches has no effect proves it ain't a Linux problem.

Personally it sounds like crazy talk, but I've never seen the need to use WSL for anything other than CLI bits and pieces.
 
1 members found this post helpful.
Old 12-28-2022, 10:10 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,693
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
And you would never want to disable the cache anyway, because your computer would instantly turn into a slow pig that's shaking the spindles off the drives, beating them to death.
 
2 members found this post helpful.
Old 12-29-2022, 02:44 PM   #4
gllisse
LQ Newbie
 
Registered: Dec 2022
Posts: 4

Original Poster
Rep: Reputation: 0
Finally googling, I've found the solution to my problem that was to find a way to share a directory between several different running linux distributions using WSL.

It is actually possible using mount bind to a directory within /mnt/wsl, such directories are accessible to any distribution without concurrent access trouble.

From the distribution containing the directory, let's say /home/user:

mkdir /mnt/wsl/user

sudo mount -o bind /home/user /mnt/wsl/user

From another distribution, to access /home/user from the first distribution and mount it on /home/user, for instance, it's then just sufficient to do:

mount -o bind /mnt/wsl/user /home/user

This way, in both distribution /home/user represents the same directory and files and it's as quick as with other linux filesystem on wsl, thus far quicker than 9P.

Using .profile, it's possible to do that each time both distributions are launched, provided the first one is launched first in order that /mnt/wsl/user is bind mounted before the other distributions are run.

As to the question of the need or interest to share home directory between several distribution, it seems obvious to me: you can test different distribution without needing to backup and reinstall all your data. Why test new distribution ? To get newer versions of packages for instance, stay up to date and skip buggy distribution.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to enable a Hard Disk to read/write to a USB device but disable the USB device to read/write to the hard disk without user permission? ce309 Linux - General 33 05-22-2019 04:30 PM
smp Linux able to run with L1 I-cache and D-cache disable? jordanplus Programming 2 08-29-2014 02:40 AM
Now I have a scsi hard disk, two IDE hard disk, i want install linux on scsi hard dis tecpenguin Linux - Server 4 11-10-2007 06:44 AM
Can I use a virtual machine hard disk as a real hard disk, or vice versa? onlineapps Linux - Software 1 02-24-2007 08:40 PM
Ram wiht suse, cache Disk cache??? fadelhomsi Linux - Newbie 2 02-05-2006 11:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration