mount a shared disk between two Linux Guest (OEL6.4)

Discussions about using Linux guests in VirtualBox.
Post Reply
Paul_A
Posts: 1
Joined: 29. Dec 2015, 07:32

mount a shared disk between two Linux Guest (OEL6.4)

Post by Paul_A »

Dear experts,

I'm running Virtualbox 4.3.30.
I have two Linux hosts (Oracle Linux 6.4): roma and rome. What I try to accomplish, is a disk that is read/writeable by both guest-hosts.

On one host I add a new disk, fixed size, 12Gb. I make it shareable and startup that host.
I create a filesystem on the new disk, and it becomes /dev/sdb1

I connect that same disk to the second host too, and start up that host as well.
On both hosts I create a mountpoint /SWLib and mount the disk there:
fstab:

Code: Select all

/dev/sdb1        /SWLib      ext4  defaults  1 2
When I touch a file on the one, I don't see it on the other hosts until I umount/mount.
And vice-versa. Obviously, I mounted it wrong, I have been trying to mount it also with:

Code: Select all

mount -t vboxsf /dev/sdb1 /SWLib
But that gives a protocol error:

Code: Select all

[root@rome ~]# mount -t vboxsf /dev/sdb1 /SWLib
/sbin/mount.vboxsf: mounting failed with the error: Protocol error
I have not found a solution yet. Any ideas highly appreciated.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: mount a shared disk between two Linux Guest (OEL6.4)

Post by mpack »

It isn't possible to actually have a drive which is writable by multiple PCs. Physical drives can only be installed in one PC at a time, and as to VMs: the drives are host files, and it simply isn't possible for the file to be opened for writing twice or more times.

You can however simulate such a feature, in fact that feature is built into VirtualBox and is called "Shared Folders". See the user manual for details.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: mount a shared disk between two Linux Guest (OEL6.4)

Post by socratis »

There is this special-cases, experts-only mode of a VDI, called "Shareable hard disk". From the user manual:
5.4 Special image write modes wrote:3. Shareable hard disks are a variant of write-through hard disks. In principle they behave exactly the same, i.e. their state is not saved when a snapshot is taken, and not restored when a snapshot is restored. The difference only shows if you attach such disks to several VMs. Shareable disks may be attached to several VMs which may run concurrently. This makes them suitable for use by cluster filesystems between VMs and similar applications which are explicitly prepared to access a disk concurrently. Only fixed size images can be used in this way, and dynamically allocated images are rejected.
Warning: This is an expert feature, and misuse can lead to data loss – regular filesystems are not prepared to handle simultaneous changes by several parties.
Disclaimer: never tried it or heard of anyone that did.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: just about all that run

Re: mount a shared disk between two Linux Guest (OEL6.4)

Post by loukingjr »

I certainly never tried it and most likely never will. The phrase "explicitly prepared" seems to be the key factor.

I agree with Don that using shared folders would be much easier.
OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: mount a shared disk between two Linux Guest (OEL6.4)

Post by mpack »

Shareable disks are essentially read only: the same mechanism is used by linked clones and immutable drives. I doubt this is what the OP wants.
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: just about all that run

Re: mount a shared disk between two Linux Guest (OEL6.4)

Post by loukingjr »

It's odd that they are listed under "Special image write modes" then.
OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: mount a shared disk between two Linux Guest (OEL6.4)

Post by mpack »

Why is that strange? Immutable drives are listed there too.
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: just about all that run

Re: mount a shared disk between two Linux Guest (OEL6.4)

Post by loukingjr »

Only in the sense it doesn't actually say they are read only. I use shared folders anyway. :)
OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: mount a shared disk between two Linux Guest (OEL6.4)

Post by socratis »

mpack wrote:Shareable disks are essentially read only: the same mechanism is used by linked clones and immutable drives. I doubt this is what the OP wants.
That's not my understanding from the manual. They are a variant of write-through hard disks. The latter are definitely not read-only. Unfortunately I don't have a cluster-aware OS to try it out.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: mount a shared disk between two Linux Guest (OEL6.4)

Post by mpack »

Possibly you are correct. I'm simply guessing that the only way to make a virtual image shareable and writeable is to use a differencing scheme, which will of course mean that each VMs writes are hidden from the others - and of course the base disk would be locked down. I can't see how else it would work: at some point there has to be one controller which handles writes to the drive, and that controller must belong to one VM.

However, like you, this is not a feature I've ever been tempted to use.

@Paul_A: this disagreement between experts doesn't change the fact that this is not a substitute for shared folders, in fact the feature shouldn't be used at all by non-experts.
Post Reply