This will delete the page "Flexible and easy outsourcing of data with bind (btrfs subvolume like)"
. Please be certain.
There are in general these methods:
ln -s /actual-folder /linked-folder
mount --bind /actual-folder /virtual-folder
While Symlinks are well known on all Operating Systems, binds are more UNIX specific and a well kept open secret.
The approach is the same, but there are differences...
I won't go into details about the bind option, because there are actually good docs about it:
man mount_namespaces
man mountpoint
man mount
In this case I just focus on one use case:
Create a private binding of a folder.
So lets say you a external Disk of some kind I don't want to spend time on shrinking and creating a new partition just for outsourcing the /home
folder.
Normally you would create a partition at the installation process and set the mountpoint /home
on it. But this time you have one partition for the /
(root directory).
Expectations:
Process:
/etc/fstab
:LABEL=data /mnt/data ext4 defaults,noatime,X-mount.mkdir=0755 0 2
:notebook: Normally you would have to create the folder, but the option X-mount.mkdir=0755
creates the mountpoint /mnt/data
automatically.
cp --verbose --update --archive /home /mnt/data/home
du --human-readable --summarize /home /mnt/data/home
mv /home /home.old
$ cat /etc/fstab
# System mountpoints
UUID=XXXX-XXXX /boot/efi vfat umask=0077 0 2
UUID=XXXXXX-XXXXXX / ext4 defaults,noatime 0 1
# External Data Disk
LABEL=data /mnt/data ext4 defaults,noatime,x-mount.mkdir=0755 0 2
# Bindings of the external Disk
/mnt/data/home /home none defaults,bind,x-gvfs-hide,x-mount.mkdir=0755 0 0
$ cat /proc/self/mountstats | grep "/home \|/ "
device /dev/sda2 mounted on / with fstype ext4
device /dev/sdb1 mounted on /home with fstype ext4
:notebook: The device name can be different. Important is that it is not on the same device as the root /
Now you can remove the folder /home.old
This will delete the page "Flexible and easy outsourcing of data with bind (btrfs subvolume like)"
. Please be certain.