LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   Single HDD shared between multiple machines (VMs) (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/single-hdd-shared-between-multiple-machines-vms-905159/)

prushik 09-26-2011 11:24 PM

Single HDD shared between multiple machines (VMs)
 
This is really a file system question, but I am posting here in VM land because this is something that will probably only ever come into play in VMs (for now at least).

My question is this, I create 3 hard drive images on my machine, image A and B both contain full linux operating systems, and image C has whatever on it. I start two simultaneous virtual machines, One boots from image A, the other boots from image B, however, BOTH VMs attempt to mount C with Read and Write access.
What will happen to C? Will the filesystem be damaged immediately? Will it be damaged when one machine unmounts the image? Will it work fine?
I assume that the filesystem will be damaged somehow, if I am using most types of filesystems, such as ext2, ext3, or ext4. However, I know that filesystems such as NFS can handle multiple machines accessing the fs with rw access, however, to my knowledge you cant format a partition with NFS.
Are any filesystems capable of this? which ones?

Chuck56 09-27-2011 06:33 AM

Why not loop mount image C from the host and have the host offer C using NFS?

jefro 09-27-2011 03:52 PM

It is not a good idea to do that. Better to use access via nfs or ftp or some other indirect method instead. You may be able to mount a drive to two OS's but it will fail and you will loose data. Also do not use a similar shared folder for two machines.

prushik 09-28-2011 02:14 AM

Quote:

Originally Posted by jefro (Post 4483786)
It is not a good idea to do that. Better to use access via nfs or ftp or some other indirect method instead. You may be able to mount a drive to two OS's but it will fail and you will loose data. Also do not use a similar shared folder for two machines.

Because NFS uses the network which is insane in this case, why use something that is inherently crazy slow when both machines have direct physical access to the hard drive. What if one of the machines does not have a network capabilities? What if one machine is a linux based OS that I am working on for my company that doesn't have any network drivers installed, and we did that on purpose for security reasons? It's all hypothetical up in here.
NFS is a workaround, not a solution.
Its totally possible to design an FS that can handle two machines mounting it simultaneously, I know that because NFS does it. I am interested in other filesystems that can do that without NFS.

jefro 09-28-2011 03:46 PM

I think you are confused about what nfs is and what ext2/3/4 format is and how a vm works and how an OS interacts with a mounted filesystem. What you suggest has not been created except on a very special type of filesystem used in a very special way. You do not want to use a mount command to mount a drive or partition to two VM's at the same time.

prushik 09-28-2011 07:14 PM

Quote:

Originally Posted by jefro (Post 4484756)
I think you are confused about what nfs is and what ext2/3/4 format is and how a vm works and how an OS interacts with a mounted filesystem. What you suggest has not been created except on a very special type of filesystem used in a very special way. You do not want to use a mount command to mount a drive or partition to two VM's at the same time.

I like to think that I understand them all pretty well, better than most folks I think. I think you are confused about exactly what I am asking. I am fully aware that NFS is a very specialized file system, and I know that it is a different beast from ext2/3/4 etc filesystems. I understand how and why a filesystem can become damaged by being mounted on two separate machines at once, for instance, I am fairly sure that if I mounted an ext2 FS from a second machine simultaneously, it would fail because ext2 checks to see if the file system was properly unmounted prior to actually mounting the file. However, ext3 introduces methods of preserving data in the case of an error, these may also help prevent data loss when mounted simultaneously, or maybe not.
I am fully aware that these file systems were not DESIGNED with that functionality in mind, but that doesn't mean that it won't work. I used NFS as an example because the NFS server IS able to handle multiple mounts without damage, this is nothing more than proof that it is possible for a system to exist that can preserve data when it is being accessed by two simultaneous devices which are unaware of each other.
There are many other file system types, NTFS, FAT, btrfs, ReiserFS, BeFS, XFS, YAFFS, UFS, XFS, HFS+, NILFS, GFS2, OCFS, JFS, etc..
As a matter of fact, I read over some of the Linux kernel source (3.0.1, kernel.org is still down), and apparently GFS2 has a locking mechanism that will allow one machine to lock it while writing to prevent data corruption, so it looks like it actually was designed to do what I want. OCFS may also be another option.

jefro 09-28-2011 07:56 PM

I think you are trying to fix something that isn't broken. The basic mount command was never designed to have more than one OS controlling it. You are missing the way a host host controls a drive. No matter how you think of it a VM in many ways acts like a real computer. You can't easily mount a virtual file system as a mounted drive to two OS's.

You have an issue that has been addressed for decades in many cics type of transactional projects. That is way I said to use some other means to share the data that has transactional locks in place. Read up on how IBM and other database's address this issue. You handle it at the software level not the hardware level.

prushik 09-29-2011 12:59 AM

Quote:

Originally Posted by jefro (Post 4484932)
I think you are trying to fix something that isn't broken. The basic mount command was never designed to have more than one OS controlling it. You are missing the way a host host controls a drive. No matter how you think of it a VM in many ways acts like a real computer. You can't easily mount a virtual file system as a mounted drive to two OS's.

You have an issue that has been addressed for decades in many cics type of transactional projects. That is way I said to use some other means to share the data that has transactional locks in place. Read up on how IBM and other database's address this issue. You handle it at the software level not the hardware level.

The mount command is not the issue here, the mount command is designed to mount file systems, what that particular file system does internally has no bearing on what the mount command does, mount just calls the kernels FS drivers.
And I was never trying to say that it should work because they are VM's, I understand that a VM acts as a real computer, and what I want to do should work on real hardware too, but since that type of hardware is very specialized, so its easier to express the problem with VMs.
I know that it needs to be handled on the software level, thats what I have been talking about this whole time, filesystems are software.
Anyway, its pointless to argue as I have already found the solution I was looking for:
GFS2 Global File System, its a file system that was designed to do exactly what I said, it uses DLM as a lock manager and is designed to be accessed by a cluster of computers. The linux kernel has built in drivers to mount and use that file system, so all you need on top of that is the userland tools to actually create the FS.

Slax-Dude 09-29-2011 09:46 AM

Quote:

Originally Posted by prushik (Post 4484143)
Because NFS uses the network which is insane in this case

Quote:

Originally Posted by prushik (Post 4484143)
Anyway, its pointless to argue as I have already found the solution I was looking for:
GFS2 Global File System

Errr... you do understand that in order to mount an OCFS2 filesystem located on a different machine you will have to use the network, right?

prushik 09-29-2011 11:26 PM

Quote:

Originally Posted by Slax-Dude (Post 4485589)
Errr... you do understand that in order to mount an OCFS2 filesystem located on a different machine you will have to use the network, right?

Yeah, oh well. I've already started messing around with GFS2, so I don't see a reason to use OCFS for anything. I'm not sure how I feel about Oracle yet.

Slax-Dude 10-06-2011 11:55 AM

Quote:

Originally Posted by prushik (Post 4486127)
Yeah, oh well. I've already started messing around with GFS2, so I don't see a reason to use OCFS for anything. I'm not sure how I feel about Oracle yet.

Sorry, I meant GFS2. Got my acronyms mixed up :redface:
But it still applies: you WILL have to use network


All times are GMT -5. The time now is 08:31 AM.