I have a question about how to move several trees together under the same directory structure. These are usually referred to as mount points, but the problem with mount points is that they have to come from a physical volume or some loopback device volume.
Suppose you have a common directory like /usr/local/ and you want to mount several volumes beneath it.
One way to do it is to use a different volume for each and every directory. E.g. there can be directory "games" and it is located on a volume such as /dev/mapper/group-games. Another directory is "share" and it is located on a volume such as /dev/mapper/group-share. The downside of this is that these volumes are physically separated and they have fixed boundaries in allocation space.
What that means is that you now have clear mount points but you have to put your files on several volumes.
Now you might also have a volume that contains several of these directories. Call them /share and /games. You want to mount that volume under /usr/local. Fair enough.
Then you have another volume and it contains /setup and /download. You also want to mount it under /usr/local. Is this possible?
The only thing I know of is using overlays. But an overlayfs will have one upper and one lower. Moreover, it requires both upper and lower to be mounted elsewhere, or at least mounted somewhere ( I believe one of them may already be mounted on the merged mountpoint ).
So you can have:
mount /dev/mapper/group-one /usr/local/
mount /dev/mapper/group-two /somewhere
mount -t overlay /usr/local -o lowerdir=/usr/local,upperdir=/somewhere
And it will merge the directories, but now you have /somewhere mounted in two positions.
What is more: all the changes always go to the upper dir. You cannot have a overlay mount and have the changes written to the subsequent trees. That is to say, now all the directories in /somewhere get their changes written to /usr/local on /dev/mapper/group-one.
What I want of course, what you want of course, is for your changes to be written to the respective trees for the respective volumes, or you create real nightmares.
This however requires simply mounting with a bind operation, some part of a tree somewhere else. You could do
mount -o bind /somewhere/setup /usr/local/setup and it would work.
BUT THAT LEAVES a mountpoint visible elsewhere as well and this is not nice for a security perspective as well as presentation to unwilling users like yourself. You want this data to be accessible in only one way. They call it the "canonical" url supposedly and it is important for e.g. search indexing. You don't want e.g. your site to appear under two links in a google index, but it is the same for a local system.
Now there is UnionFS
There is a package aufs-tools and a package unionfs-fuse. The latter provides the filesystem in user space, which I do not want.
The OverlayFS is considered a form of UnionFS, so basically it seems that there is not really any UnionFS anymore in Linux. OverlayFS is supported by the Linux kernel although documentation seems to be scarce.
Hiding a mount point that has already been mounted with some filesytem prior to the union mount can only really be done by mounting an empty directory on top of it.
The aufs-tools package allows to easily create a mounted merged directory using for example: mount -t aufs br:/firstdir=rw:/seconddir:rw none /merged and it will work as intended straight away. The manual page however is horrendous to read.
I am wondering what thoughts you have? The merged directory with aufs is completely merged. Writing to one subdirectory will just write to one of the filesystems. Changes written to the total root of the merged directory is just written to the former. I'm not sure how it works further than that, but I can use it right away as long as I study it a bit more.
Suppose you have a common directory like /usr/local/ and you want to mount several volumes beneath it.
One way to do it is to use a different volume for each and every directory. E.g. there can be directory "games" and it is located on a volume such as /dev/mapper/group-games. Another directory is "share" and it is located on a volume such as /dev/mapper/group-share. The downside of this is that these volumes are physically separated and they have fixed boundaries in allocation space.
What that means is that you now have clear mount points but you have to put your files on several volumes.
Now you might also have a volume that contains several of these directories. Call them /share and /games. You want to mount that volume under /usr/local. Fair enough.
Then you have another volume and it contains /setup and /download. You also want to mount it under /usr/local. Is this possible?
The only thing I know of is using overlays. But an overlayfs will have one upper and one lower. Moreover, it requires both upper and lower to be mounted elsewhere, or at least mounted somewhere ( I believe one of them may already be mounted on the merged mountpoint ).
So you can have:
mount /dev/mapper/group-one /usr/local/
mount /dev/mapper/group-two /somewhere
mount -t overlay /usr/local -o lowerdir=/usr/local,upperdir=/somewhere
And it will merge the directories, but now you have /somewhere mounted in two positions.
What is more: all the changes always go to the upper dir. You cannot have a overlay mount and have the changes written to the subsequent trees. That is to say, now all the directories in /somewhere get their changes written to /usr/local on /dev/mapper/group-one.
What I want of course, what you want of course, is for your changes to be written to the respective trees for the respective volumes, or you create real nightmares.
This however requires simply mounting with a bind operation, some part of a tree somewhere else. You could do
mount -o bind /somewhere/setup /usr/local/setup and it would work.
BUT THAT LEAVES a mountpoint visible elsewhere as well and this is not nice for a security perspective as well as presentation to unwilling users like yourself. You want this data to be accessible in only one way. They call it the "canonical" url supposedly and it is important for e.g. search indexing. You don't want e.g. your site to appear under two links in a google index, but it is the same for a local system.
Now there is UnionFS
There is a package aufs-tools and a package unionfs-fuse. The latter provides the filesystem in user space, which I do not want.
The OverlayFS is considered a form of UnionFS, so basically it seems that there is not really any UnionFS anymore in Linux. OverlayFS is supported by the Linux kernel although documentation seems to be scarce.
Hiding a mount point that has already been mounted with some filesytem prior to the union mount can only really be done by mounting an empty directory on top of it.
The aufs-tools package allows to easily create a mounted merged directory using for example: mount -t aufs br:/firstdir=rw:/seconddir:rw none /merged and it will work as intended straight away. The manual page however is horrendous to read.
I am wondering what thoughts you have? The merged directory with aufs is completely merged. Writing to one subdirectory will just write to one of the filesystems. Changes written to the total root of the merged directory is just written to the former. I'm not sure how it works further than that, but I can use it right away as long as I study it a bit more.
Comment