问:I want to mount the same disk to two linux machines and both machine must be able to read/write on the same disk at the same time.
答:You can do that through NFS. Mount the disk to a machine and share that drive through NFS to the other machine.
Suppose the disk to be shared is /dev/sdb and the machines that you want to share the disk is machine1.example.com and machine2.example.com, then:
-
Mount /dev/sdb in machine1 (You can skip this step if the said disk is already mounted and being used by machine1)
-
Make the machine1 as the NFS server and export the directory on which /dev/sdb is mounted. Say, if /dev/sdb is mounted on /mnt/sharemount. The NFS export entries in
/etc/exports
should say:/mnt/sharemount machine2.example.com(rw,sync)
-
Now that machine2 is allowed to use /mnt/sharemount from machine1 through NFS from step2, just mount /mnt/sharemount from machine1 on machine2
mount machine1.example.com:/mnt/sharemount /mnt/sharemount
Data will not get corruped if these two machines start writing to the same location in /mnt/sharemount since the required locks will be applied and it will all happen transparent to you.
This answer is only an outline. If you are not familiar mounting a new disk to a server and with setting up NFS, please google how to configure nfs client and server linux
. The search results will present you dozens of easy to follow tutorials and step-by-step guides. If you are comfortable using the command line(which I assume you are), you should be able to get the setup done with minimal time.