Task
It is necessary to combine several existing sections into one without losing information. This can happen if LVM was not involved in advance, but it is necessary to expand the space, for example, for torrents.
Solutions
There are at least two solutions.
aufs2
aufs2 is a file system that implements cascade-joint mount for Linux file systems. In addition to the inherited functionality from UnionFS, RW branches and record balancing are implemented here, which is ideal for solving the set task.
It should be noted that aufs2 is not included in the mainline core. But it is:
- in Debian Lenny ( unfortunately, not in Testing and Sid );
- in Ubuntu ( since the LiveCD of Ubuntu is built using this FS );
- in Zen-kernel and Liquorix .
You can also patch and assemble the kernel yourself using
standalone-version of aufs2. For debianov recommend, if you do not want to mess with the compilation of the kernel, use the ready-made Liquorix packages, connecting the repository as indicated on
the project page .
')
If you have dealt with the kernel, then you need to take care of userspace utilities. In Debian, there are ready-made packages (
despite the lack of support from the kernel ), so you can put them in one command:
sudo aptitude install aufs-tools
If there are no ready-made packages in the distribution, you can take them from the
official website of aufs .
Now to the point. Suppose there are two mounted partitions:
- old with a bunch of torrents: / media / torrents;
- and a new one on a newly purchased hard drive: / media / new_storage.
In order for these two sections to be visible as one, the following command must be executed:
sudo mount -t aufs none /media/storage -o br:/media/torrents=rw:/media/new_storage=rw,create=mfs,sum
Here:
- br: branch1 = rw: branch2 = rw: ... - the list of so-called. branches, i.e. mounted partitions that will be merged into one;
- create = mfs is the main parameter indicating that the branch that has more free space will be selected for recording. Without this parameter, the “puff” from the sections will not work as intended;
- sum indicates that the utilities of type df or pydf will display the total size of the partitions and free space for them for the combined partition.
In / etc / fstab, this entry should look like:
none /media/storage aufs br:/media/torrents=rw:/media/new_storage=rw,create=mfs,sum 0 0
mhddfs
Unlike aufs, mhddfs is a user-space file system that works through fuse. In Debian, there is a ready-made package, which is installed by the command:
sudo aptitude install mhddfs
Mounting is done by the command:
sudo mhddfs /media/torrents,/media/new_storage /media/storage -o default_permissions,allow_other
In / etc / fstab, the corresponding entry is:
mhddfs#/media/torrents,/media/new_storage /media/storage fuse default_permissions,allow_other 0 0
It is worth noting that neither aufs2 nor mhddfs allow one file is partially on one, partly on another section. Also note that after unmounting the puff, all files will be accessed through the original mount points. Some files will be on one partition, some - on the other.
findings
If a quick and easy solution is needed, mhddfs will suffice for most users. But it is worth remembering that aufs2 works at the kernel level, so the performance in this case is higher. In addition, mhddfs loads the processor to a much greater degree, and the write / read speed is slightly lower than in aufs2.
Thanks for attention. Comments, comments and suggestions are welcome.