# Mounting a file system twice



## supradave (Apr 19, 2011)

Currently running FreeBSD as a Xen DomU.  I would like to be able to mount a data-only file system image on that DomU as a read/write mount.  I would also like to mount it read-only, by definition in the Xen config and in fstab, on another system, be that FreeBSD or Linux or whatever running in another DomU to gather whatever statistic or information we want to publish there.  A remount will update the second mount but the second mount doesn't appear live on the second Xen DomU.  Is there a file system that can be mounted twice.  I noticed one called the Global File System, but there were no files for it.  I've also thought NFS may suffice, but that requires more software and am trying to keep the initial system as stripped as possible for security purposes.


----------



## SirDice (Apr 20, 2011)

Mount the filesystem as you would normally. Then you can add a second mountpoint using nullfs(5) like so:

```
mount /dev/ad4s2d /some/storage
mount -t nullfs -o ro /some/storage /somewhere/else/readonly
mount -t nullfs /some/storage /another/place/readwrite
```

Works great in combinations with jails.


----------



## mamalos (Apr 21, 2011)

SirDice is right,

be careful, though, nullfs does not support sockets and named pipes.


----------

