Announcement

Collapse
No announcement yet.

A tip about moving large files from one BTRFS subvolume to another on the same file system.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    A tip about moving large files from one BTRFS subvolume to another on the same file system.

    I use multiple subvolumes on my server to store files. 21 to be precise on a 12TB hard drive. Most of you probably don't have that many, but this tip can save a ton of time whenever you need to move large or a large number of files from one subvolume to another. They must be on the same BTRFS file system for this to work.

    BTRFS uses subvolumes to segregate files on a single file system. This is a huge benefit because while the subvolumes and their files remain separate any the free space is available to ALL the subvolumes. The subvolumes act as dividers like file folders in a file cabinet drawer. With other file systems, you have to use separate partitions. Partitions divide the files into separate drawers with individual file systems rather than just separate folders. The key point here is: When using BTRFS subvolumes instead of separate partitions, ALL the files are actually on the same file system.

    Why is this important?

    Dolphin and any tool we use on the Desktop doesn't "know" about BTRFS. To the desktop, it works the same whether it's accessing BTRFS subvolumes or separate partitions. When moving a file from one place to another, Dolphin​ will move all those bytes from one place to the other. Moving large or a large number of files can take a lot of time and keep your drive busy for quite a while.

    Here's an example of how you can use this knowledge to your advantage:

    My BTRFS install has three subvolumes: @ (my Linux install), @home (@my home), and @downloads. I keep downloads in a separate subvolume so I can exclude them from my @home backups.

    I download several large ISO files and decide I want to move them to /boot/grub in my install so I can easily boot to them from grub. If I open Dolphin and move them, it may take 10-15 minutes or more to move them if I'm using a hard drive. So instead, I mount my route BTRFS file system and move them using the command line. This takes longer to type than the file move does!

    On all my BTRFS installs, I make a folder called /subvols and mount my root file system there. This makes it easier to make snapshots and backups. For those new to BTRFS, the "root file system" is where your subvolume reside. By default, the root file system is not mounted and the existence of your subvolumes is hidden from the users. When you mount the root file system you can see and access all the subvolumes for snapshots, backups, and file moving operations like this one.

    SInce my root file system is already mounted at /subvols, I open Konsole and type:

    sudo mv /subvols/@downloads/*.iso /subvols/@/boot/grub

    By the time I hit enter, it's already done.

    I use this technique on my server almost every day.

    Please Read Me
Working...
X