Combining several sections into one without loss of information

    Task


    It is necessary to combine several existing sections into one without loss of information. This can happen if LVM was not involved in advance, and 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 cascading-integrated mounts for Linux file systems. In addition to the functionality inherited from UnionFS, RW branches and write balancing are implemented here, which is ideal for solving the task.

    It should be noted that aufs2 is not included in the mainline kernel. But she is:
    • Debian Lenny ( unfortunately no longer in Testing and Sid );
    • in Ubuntu ( since the LiveCD Ubuntu is built using this FS );
    • in Zen-kernel and Liquorix .

    You can also patch and build the kernel yourself using the standalone version of aufs2. For Debianites, I recommend, if you don’t want to bother with compiling the kernel, use ready-made Liquorix packages by connecting the repository as indicated on the project page .

    If you figured out the kernel, then you need to take care of userspace utilities. Debian has 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 get them from the aufs official site .

    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, you must run the following command:

    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: ... - a list of so-called branches, i.e. mounted partitions, which will be merged into one;
    • create = mfs - the main parameter indicating that the branch that has more free space will be selected for recording. Without specifying this parameter, the “puff” of sections will not work as intended;
    • sum - indicates that in utilities such as df or pydf, the total size of the partitions and the free space on them for the combined partition will be displayed.

    In / etc / fstab, this entry should look like this:

    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. Debian has a ready-made package that 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 to be located partially on one, partially on another partition. I also note that after unmounting the puff, all files will be accessed through the mount points. Part of the files will be on one partition, part - on another.

    conclusions



    If a quick and easy solution is needed, then most users will need mhddfs. 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.

    Also popular now: