IntroductionWouldn't it be great if after you did a apt-get dist-upgrade on your rolling (or semi-rolling) LMDE, and it hosed your install, you could undo it in a matter of seconds?

This article is a How-To to do a fresh LMDE install using the new "experimental" BTRFS and it's "Snapshot" (similar to Windows System Restore) feature. After we install LMDE, we'll also install the apt-btrfs-snapshot scripts from Ubuntu. It will automatically make snapshots when apt installs or uninstalls debs, and makes it easy to restore the file system to an earlier snapshot.

Disclaimer: If you lose all your data, your PC and house catches on fire, and/or your dog passes on... it's not my fault! Use this article at your own risk!

About BTRFSBTRFS is still considered an "experimental" file system, but as of April 2012, the file system design itself, and how it is implemented in the Linux kernel is complete. Work is still being done on the utilities to work with BTRFS, especially a FSCK program. BTRFS has matured enough that it is now an option in the OpenSUSE 12.1 installer and it may become the default file system for Fedora 17. OpenSUSE has even developed Snapper which does exactly what we are doing here... making it easy to rollback your install to a previous snapshot.

As this file system is experimental, please have a backup plan in place. If the file system crashes, and you lose your data, do you have a backup?

Also, from my research it seems that most errors in BTRFS are from power failures. I highly recommend and to reduce the risk of data loss that you have an Uninterruptable Power Supply (UPS) or battery backup for your PC.

BTRFS also supports RAID 0, 1, and 10, as well as shrinkable and growable volumes. Here's some great web sites to find out more about the features of BTRFS:

PrerequisitesLMDE 201204 Cinnamon/Mate or LMDE 201204 XFCE DVDSome or all of the information in this article may or may not apply to other distros.

Linux Kernel 3.2 or newerOlder kernels, especially the one that originally came with Debian Squeeze has issues with BTRFS

GRUB 2 and btrfs-toolsAlready installed on the LMDE Live DVD.

Boot from the Live DVD and let's get started...

1. Partitioning/Make File SystemYou can use GParted included on the DVD to create a new BTRFS file system. If you want to create a BTRFS using RAID, reference the links above, especially BTRFS Fun - Funtoo Linux to find out how to use the btrfs command from the terminal.

2. Create an "@" and "home" subvolumesThe apt-btrfs-snapshot tool that we are going to install at the end of this How-To, expects the root file system to be in a subvolume called "@". To create it from a root terminal (Replace sda1 with the name of your BTRFS partition):

[Optional] You can also create a subvolume that you will mount /home to. You may want to create subvolumes for any directories that you do not want included in the Snapshot and Rollback feature (like MySQL databases, for example) to mount in their respective locations:

My theory is something is happening with GRUB. I was able to fix and boot again by booting with the Live DVD, doing the CHROOT section above, and dpkg-reconfigure grub-pc and grub-install /dev/sda. If anyone else sees this or has any idea what is happening, please share.

I'm confident it is not the filesystem. I ran btrfsck offline from the live DVD shell and it didn't find any errors.

**UPDATE**This would randomly occur on reboots. And if I keep rebooting or power-cycling, it eventually would stop erroring and boot.

I did find this Can 12.04 be installed using Btrfs only? and it mentioned that gzip is the default decompression tool in /etc/initramfs-tools/initramfs.conf in Ubuntu 12.04. I changed the following in /etc/initramfs-tools/initramfs.conf...

COMPRESS=gzip

...and did a dpkg-reconfigure initramfs-tools. So far so good. I'll keep this post "posted" if my system stops booting again!

I followed it and then tweaked my mount settings in fstab based on a few other recommendations.

Interestingly, I borked my grub (and other things) while attempting to use SMXI to install 3.3 liquorix kernel and could not get back into my system at all. I booted from the LMDE Live CD and went into Computer on my desktop. I saw my @ directory and a bunch of snapshot folders on the install SSD. As root, I deleted my @ directory and then renamed my most recent snapshot folder to @.

Rebooted and it was like the Liquorix kernel install failure never happened!

I may be able to stop those time consuming clonezilla sessions now that I've tried btrfs and realized the awesomeness of the snapshot restore feature.

Interesting. By placing /boot into the btrfs volume like suggested in the tutorial, any 'other' kernel I try (want to grab the latest btrfs stuff!), I get a grub error on reboot.Perhaps this is not the ideal install solution for btrfs?

On a side not, I've been able to use a fallback snapshot each time it failed so I'm not so worried, just want to try the btrfs options in the latest kernel

melbo wrote:Interesting. By placing /boot into the btrfs volume like suggested in the tutorial, any 'other' kernel I try (want to grab the latest btrfs stuff!), I get a grub error on reboot.Perhaps this is not the ideal install solution for btrfs?

On a side not, I've been able to use a fallback snapshot each time it failed so I'm not so worried, just want to try the btrfs options in the latest kernel

After you install a new kernel, have you tried to manually run "grub-install /dev/sdx" before you reboot?

You could put /boot on its own ext4 partition, but keep in mind you will probably hose your install if you rollback your root filesystem to a snapshot created before the new kernel install. That's why I included /boot in @ in my tutorial. As long as you don't rollback to before a kernel upgrade, putting /boot in its own partition should be fine.

Thank you for the tip. I have not tried this.I did add Sid sources, upgraded grub to latest (1.99?) and tried again and am now testing 3.4.X with no problems.I think the default grub2 included with LMDE 201204 didn't like the grub probe on compile.

I'll keep playing and report back any problems.

I have used the Live DVD/rename @ from snapshots about 50 times over the past few days... this alone has me sold on btrfs!

melbo wrote:Thank you for the tip. I have not tried this.I did add Sid sources, upgraded grub to latest (1.99?) and tried again and am now testing 3.4.X with no problems.I think the default grub2 included with LMDE 201204 didn't like the grub probe on compile.

I'll keep playing and report back any problems.

I have used the Live DVD/rename @ from snapshots about 50 times over the past few days... this alone has me sold on btrfs!

Can you check and see exactly what package version of grub you upgraded too? I will add that information to this tutorial.

Snapshots are awesome! This past month, I started looking at upgrading to a new distro from Ubuntu 10.10 and when I heard about and saw btrfs, I almost converted to OpenSUSE for btrfs and their snapshot tool, snapper. But I've always used Debian-based distros (since Potato) for my desktop and I just can't wrap my head around the bloat and slowness of YAST.

It was also so easy to setup RAID 1, and love the fact I can add a hard drive and grow my root file system whenever I want. Probably never will, but it sure is nice to have options!

My current grub version is 1.99-17Just upgrade to kernel 3.4 and btrfs 'feels' even faster.

I followed your tutorial using the (optional) /home directory. When viewing my system in various ways, I'm seeing a 2x drive capacity - ie. My / and my /home both display the entire amount of my HDD. I'm sure its just cosmetic but it's not correct.

melbo wrote:I followed your tutorial using the (optional) /home directory. When viewing my system in various ways, I'm seeing a 2x drive capacity - ie. My / and my /home both display the entire amount of my HDD. I'm sure its just cosmetic but it's not correct.

That actually is correct... Setting up your subvolumes on the btrfs partition, both / and /home can use up to the entire partition (or drive) capacity. They are not fixed sizes like partitions. It's a little confusing if you are use to partitions, but this is a very cool feature.

In a related note, there is a bug with XFCE Thunar in LMDE where it will show you have infinite free space.

Hi... I followed this guide, and it worked just great.... now... I upgraded my kernel to the 3.8.4 kernel, and it won't boot... it panics and states that it cannot read from the root device, and is asking to have the correct 'root=' set. This is set in the /etc/default/grub .. the old kernel boots great... now something strange.... if I boot the new kernel in rescue mode, which it does just fine, and when I exit from rescue mode, it automatically goes into multi-user mode, everything comes up just fine.... I'm just not able to boot directly into multi-user mode... any thoughts???

EDITED...

Well, almost... seems that it does not always boot in single user mode.... for a while it did, now I am getting the panic all the time.... strange.....

UPDATE:.....OK, so I worked it out..... what I did was just use a standard plain old btrfs, WITHOUT defining any sub-volumes ... everything works well, although I realize this will not allow the Snapshots to work, but with me that's not an issue, as I use rsnapshot to backup all my data, and can live without the btrfs snapshots....

Yet another UPDATE...

So much with my flirting with a new kernel... this am I boot, and get the same old PANIC where the kernel cannot read the root file system..... go figure.... anyway, the 3.8 kernel does not install completely anyway because of a libc6 dependancy... I'll just live with the original kernel and wait for a new one to come along that is sanctioned by LMDE...