I see a lot of new users that come here for advice when installing for the first time. Sometimes someone will suggest that they use BTRFS instead of EXT4 (the default). I usually don't. I'm a huge fan of and experienced user of BTRFS, but I feel new Linux users are struggling with enough without having one more new thing to learn. However, I think I might have been wrong about that. In many ways BTRFS is actually much easier than using EXT4 and has some benefits that can save your rear-end. If new users need anything, it's as many lifelines as they can get.
Before I explain how you might use BRTFS, let me explain two important reasons why;
Partitioning: Common advice is to have a separate partition for /home. This is a great idea for several reasons. However, partitioning is not something most Windows users have ever done, and it's inherently dangerous. The less time you spend mucking about with your partition table the better. BTRFS allows you to have your home separate from your install without having a separate partition. Everything on a single partition but still separate. BTRFS does this with virtual containers referred to as "subvolumes". Subvolumes act like partitions - they're mountable and they contain files - but unlike partition-based file systems you can move them, copy them, and they expand and contract automatically as needed.
Disasters: Sometimes, not as often as the old days but still sometimes, a package update goes sideways and your OS is unbootable. This happened to me today. Sometimes you, the user, will make a fatal mistake. It happens to experienced and new users. How do you recover from this? All too often, you end up having to re-install. This means all your tweaks, setups, configurations, are lost. With BTRFS and subvolumes, you can easily and simply take a "snapshot" of your home or your install subvolumes. A snapshot is exactly what it sounds like - a image of your subvolume frozen in time. With a recent snapshot of your install, you need only replace your broken or damaged subvolume with the snapshot and reboot. In that case, you would only lose the tweaks, setups, configurations that occurred between the snapshot and the disaster. In my case, my computer takes a snapshot everyday so this morning - when I broke it - within a couple of minutes I was right back to where I had been just 20 minutes before. A lifesaver if there ever was one.
How do you use BTRFS?
Initially, it's as simple as choosing BTRFS instead of EXT4 when you install. The Kubuntu installer will automatically create two subvolumes for you, one for the install and one for home. Use a single partition. It's preferred and easier than trying to create and use multiple partitions.
Once you're up and running, from there it's learning how to use the advanced features the BTRFS offers you. I've touched on only two, subvolumes and snapshots, but there are many more. A couple of examples: I use BTRFS to make backups and have multiple different Linux installs on the same partition. BTRFS can use multiple devices - more than one partition or hard drive - as single file system and multiple devices can be configured as RAID or JBOD.
Here's what I did wrong this morning and how BTRFS saved me:
I have set up my system to take a snapshot every day at 3am. This morning about 8am I booted up and within a half hour did some package updates and installed a new kernel version. When I rebooted into the new kernel, the system locked up with a "kernel panic". No big deal, I rebooted and selected the previous kernel. I decided that maybe rebuilding the initramfs would allow the new kernel to boot, so I issued the process to rebuild the initramfs - but when I did, I selected ALL kernels instead of just the one that wasn't working. As soon as I hit the enter key I knew I had potentially made a mistake, but it was too late. I let the rebuild process continue and crossed my fingers. When I rebooted, the new kernel still panic. Second reboot - the previous kernel panicked. Third reboot - the only other kernel panicked. I broke them all. Now what do I do?
Had I been using EXT4, I might have been finished - a new installation may have been my only course of action. But I'm not using EXT4, I'm using BTRFS and I had a very recent snapshot. I booted into one of my other installs (you could boot to a liveUSB if you only had one install), navigated to the location my now broken install and it's snapshots reside, renamed the broken subvolume and then gave the snapshot the name the install subvolume previously had, and rebooted. That was it. The entire fix consisted of these actions: Boot, Mount, Rename 2 files, Reboot. That's it. In about 3 minutes I was back in business. I then re-did the package updates and installed the new kernel again. This time I'll try and not break ALL the kernels again.
Consider using BTRFS for your next install.
Before I explain how you might use BRTFS, let me explain two important reasons why;
Partitioning: Common advice is to have a separate partition for /home. This is a great idea for several reasons. However, partitioning is not something most Windows users have ever done, and it's inherently dangerous. The less time you spend mucking about with your partition table the better. BTRFS allows you to have your home separate from your install without having a separate partition. Everything on a single partition but still separate. BTRFS does this with virtual containers referred to as "subvolumes". Subvolumes act like partitions - they're mountable and they contain files - but unlike partition-based file systems you can move them, copy them, and they expand and contract automatically as needed.
Disasters: Sometimes, not as often as the old days but still sometimes, a package update goes sideways and your OS is unbootable. This happened to me today. Sometimes you, the user, will make a fatal mistake. It happens to experienced and new users. How do you recover from this? All too often, you end up having to re-install. This means all your tweaks, setups, configurations, are lost. With BTRFS and subvolumes, you can easily and simply take a "snapshot" of your home or your install subvolumes. A snapshot is exactly what it sounds like - a image of your subvolume frozen in time. With a recent snapshot of your install, you need only replace your broken or damaged subvolume with the snapshot and reboot. In that case, you would only lose the tweaks, setups, configurations that occurred between the snapshot and the disaster. In my case, my computer takes a snapshot everyday so this morning - when I broke it - within a couple of minutes I was right back to where I had been just 20 minutes before. A lifesaver if there ever was one.
How do you use BTRFS?
Initially, it's as simple as choosing BTRFS instead of EXT4 when you install. The Kubuntu installer will automatically create two subvolumes for you, one for the install and one for home. Use a single partition. It's preferred and easier than trying to create and use multiple partitions.
Once you're up and running, from there it's learning how to use the advanced features the BTRFS offers you. I've touched on only two, subvolumes and snapshots, but there are many more. A couple of examples: I use BTRFS to make backups and have multiple different Linux installs on the same partition. BTRFS can use multiple devices - more than one partition or hard drive - as single file system and multiple devices can be configured as RAID or JBOD.
Here's what I did wrong this morning and how BTRFS saved me:
I have set up my system to take a snapshot every day at 3am. This morning about 8am I booted up and within a half hour did some package updates and installed a new kernel version. When I rebooted into the new kernel, the system locked up with a "kernel panic". No big deal, I rebooted and selected the previous kernel. I decided that maybe rebuilding the initramfs would allow the new kernel to boot, so I issued the process to rebuild the initramfs - but when I did, I selected ALL kernels instead of just the one that wasn't working. As soon as I hit the enter key I knew I had potentially made a mistake, but it was too late. I let the rebuild process continue and crossed my fingers. When I rebooted, the new kernel still panic. Second reboot - the previous kernel panicked. Third reboot - the only other kernel panicked. I broke them all. Now what do I do?
Had I been using EXT4, I might have been finished - a new installation may have been my only course of action. But I'm not using EXT4, I'm using BTRFS and I had a very recent snapshot. I booted into one of my other installs (you could boot to a liveUSB if you only had one install), navigated to the location my now broken install and it's snapshots reside, renamed the broken subvolume and then gave the snapshot the name the install subvolume previously had, and rebooted. That was it. The entire fix consisted of these actions: Boot, Mount, Rename 2 files, Reboot. That's it. In about 3 minutes I was back in business. I then re-did the package updates and installed the new kernel again. This time I'll try and not break ALL the kernels again.
Consider using BTRFS for your next install.
Comment