Can I mount a block device both over iSCSI and locally?

I have a block device (/dev/mapper/vg0-data) on a server. I am planning to mount it locally on the server directly through Linux mount, but also expose is through iSCSI to another server, which will connect to it twice to have multi-path connection. I wonder if this is OK or will there be any data corruption because there might be potentially both local changes on the server and remote changes coming from iSCSI. If there is any caching involved there might be conflicts? Should I mount also locally the block device over iSCSI?

The block device contains an ext4 partition.

This is all on Linux, Ubuntu 16.04 LTS.


Solution 1:

Short answer: Don't do that

Long answer: to double-mount a block device on two different machines, you need to use a cluster filesystem, as OCFS or GFS2. On the other hand, EXT4 is not a clustered filesystem: concurrently mounting it on two different machines will immediately cause extended corruption. Latest EXT4 versions even have a multiple-mount-protection mechanism, or mmp, to explicitly deny any form of double mounts.

So, you either need to use a cluster filesystem, or abandon the idea of block device sharing in favour of file sharing, for example via NFS.

Solution 2:

Using one drive for multiple connections without clustered file system is a suicide. Data corruption is the first that you will see after a few data iterations. You must run clustered file system to avoid such issues. There are a lot of topics answering such scenario, but this one is my favorite. https://forums.starwindsoftware.com/viewtopic.php?f=5&t=1392