Synology BTRFS coolness
OK, now that I’m all btrfs on this Synology, there are ton of implications. The big one is that this is a Copy-on-write file system. That means, that, normally when you do something like a massive 1TB file with other files systems like ext4
cp gigantic-mega-video.mkv new-video.mkv
You are actually literally copying. So it will take a long time and you now have used 2TB on your computer. In contrast, the above command with btrfs is instantaneous, because it just creates a point to the same 1TB of data.
The miracle is that if you were to say edit one character in the file, then only that block is changed and the rest of the file stays the same. So it is super fast and efficient.
That’s cool technology, but what it means for doing backups and copies is really incredible. So for instance:
- if you want to take a snapshot of the entire file system, it is a single command and happens instantly. The entire view of all your files stays constant. As the files change, they are automatically added to the later version, but the old version stays the same.
- If you want want to clone a huge directory, it is also instant. Later on, as the clone diverses, only the deltas take up room. If you only change 0.1% of the files, then you are saving 99.9% that is duplicated.
- If you are doing this over a network, then you can synchronize between two machines very quickly, it just sends the deltas over. This is going to be way faster than rsync which is the best way to do this for older file systems.
Now what this means is that if you have a Synology or equivalent machine, you will want to go through the pain of conversion. This is large because there is no utility that does an in-place conversion from ext4 to btrfs, you have to create a new btrfs volume and then do the expensive full copy.
Synology commands primer
Unfortunately, the user interface to do this is all over the place in Synology land, so here’s a decoder ring. The interface for Synology is pretty confusing, I usually just do a search for these application rather than trying to figure out where it is on the desktop on in their application launcher;
- Storage Manager/Volume. To create a btrfs, you go to the
Storage Managerin the control panel, then go to
Volumeand choose create volume and make sure to select
ext4is the default.
- Control Panel/Shared Folders/Create. Now you create a new shared folder also in the Control panel. You are not using the
File Station, all creation happens in the
Shared Folderswidget in the control panel. The shared folder is the smallest unit for doing btrfs things, so you don’t want one monster share, divide your data up into useful chunks.
- Control Panel/Shared Folders/Clone. If you want to create a complete duplicate copy of a shared folder, then just do a clone. This only works on the current volume, but it is really useful when you want to split things in two. Just do a clone and then delete on each side. Literally nothing gets copied.
- Package Center/Snapshot Replication. You need to download an application from the from the Package Center. This is in the main menu at the top or do a search. It is called Snapshot Replication.
- Snapshot Replication/Snapshots. Despite the name, you don’t actually have to do replication, you just go to the snapshot tab and then you can choose scheduling. You can schedule hourly, daily and weekly. I normally turn this on pretty high because there is literally no overhead if things don’t change.
- Snapshot Replication/Replication. Here, you will get a wizard and you can replicate between volumes on the same machine for fast backups and you can also do this over the network for slower but more fault tolerant ones. For the data that is important I normally do all three things, so take a snapshot regular in the working volume, do replication to a backup volume on the same machine say every hour or so. And then daily, you can kick of replication to a remote machine. Pretty cool eh?