Boot On BTRFS With Debian
Boot On BTRFS With DebianThis tutorial will explain you how to boot from a BTRFS filesystem with kernel 2.6.31-RC4 and BTRFS 0.19. BTRFS is a new filesystem with some really interesting features like online defragmenting and snapshots. BTRFS is an experimental filesystem, use at your own risk. The kernel used is also experimental. This tutorial worked fine for me but I don't guarantee that this will work for you, and decline all responsibility for any problem you might have.
Pre-requisites :
Debian install media
Step 1: installing DebianBoot onto Debian CDrom, choose install and answer to the questions until you have to partition the hard drive. Then you choose manual. We have to make at least 2 partitions (I advise to do three) in order to be able to boot (I think that GRUB doesn't support BTRFS boot yet so it will have its own partition). The first one will contain the linux kernel and grub, the bootloader, I will explain these terms later in the tutorial. I think that 250MB will perform well for this partition. Type : EXT2 For the other one, you can select to automatically create partitions or make it yourself with mountpoint "/" and type "ext3" You can add a swap file if you want to (if you don't want you'll have some warnings), type is "swap area". Then write the settings to drive and answer the questions (I personnally install nothing except the base system, so I got no "*" at all in the software selection but feel free to install what you want) and say yes when it asks you to get GRUB onto the MBR (master boot record). Debian is now installed.
Step 2 configuring aptitude:Aptitude is a package manager, it means that it can grab and install software for you with just the software name. Log in as root (with the password you set during installation). I'm used to use vim editor to modify my configuration files but you can use another one if you want to. Let's install vim: aptitude install vim We now configure aptitude to grab more up to date software: vim /etc/apt/sources.list Copy a line which looks like that by pressing 2 times "y": deb ftp://ftp.fr.debian.org/debian lenny main The web address will probably change but that's normal. Press "p" two times and then "i" and change lenny into sid on a line and into testing on the other. You should see three lines one ending by "sid main", another by "testing main" and the last by "lenny main". Press "escape" button then type :wq to save and quit. Type: aptitude update If you want to upgrade your system to unstable version of debian type: aptitude dist-upgrade Otherwise just skip and type directly: aptitude install zlib1g-dev zlibc kernel-package btrfs-tools libncurses-dev bzip2 Debian has 3 major branches, the unstable which has performed only few tests but is up to date, testing that performed most of the tests and stable that performed all the tests. If you want to be in unstable (sid), go to step 3, otherwise comment out the line containing "sid" an you'll be in testing. If you want to be in stable comment out testing and sid lines.
Step 3: compiling the kernelThe Linux kernel is the system's heart, without it, you wouldn't be able to do anything. We will have to modify some of the options, but don't worry, you'll be able to boot back on the old kernel if you're in trouble. That's the purpose of the bootloader, GRUB which permits you to select which kernel you want to boot and even if you want boot into Microsoft Windows. Let's change directory: cd /usr/src We must download the kernel, we also need a patch because BTRFS 0.19 only works with an experimental kernel. wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.tar.bz2 Then we must extract them, move the patch to the right place and patch the kernel: tar xvjf linux-2.6.30.tar.bz2 We will now generate a "graphical" interface for the kernel configuration, go to FileSystems and get a " * " in front of BTRFS and BTRFS posix categories. You can tweak the kernel a little more if you know what you do but I won't speak about it here, let's focus on the subject: make menuconfig Then save the config to .config (default name) and exit. We are now ready to launch the compilation, this means we will build something we can install on the machine and also that you can get a coffee because this is going to take a while (20 minutes for recent computers): make-kpkg --initrd kernel_image kernel_headers Then we install the new kernel: cd .. We clean the directory, do not delete the headers: rm -rf linux We now generate a file which will help the kernel to load all the things it needs during the boot which is called initrd and we update the bootloader: mkinitramfs 2.6.31-rc4 -o /boot/initrd.img-2.6.31-rc4 You can now try to reboot, we are done for kernel compilation and installation. If you have trouble go back to step 3. Step 4: preparing the BTRFS boot:We must now prepare the system for the BTRFS first boot. Indeed our system is now able to read BTRFS but the system is not configured to boot on it. We are still able to modify the files now but after the conversion of the FileSystem, we won't be able to modify anything, so we have to do it right now. There are two ways of identifying a filesystem: a UUID (which is a unique alpha-numerical identifier) and an identifier that looks like /dev/sda3. The advantage of the UUID is that it rarely changes even on USB devices but we will convert the FileSystem and the UUID may change, so we can't trust it. However the /dev identifier won't change with our configuration, so we can use it. By default the system uses UUID so we'll change that. Identify our partition "/" fdisk -l Find out which partition number is your "/", this is the partition with biggest size if you made the partition like I said above. On my computer this was /dev/sda3 but it can be something else (probably /dev/sda2) so change the "%" by the right number. It's possible that you haven't /dev/sda but something like /dev/hda or /dev/sdb in this case use what's printed on the screen instead of /dev/sda. vim /boot/grub/menu.lst Type /initrd Then edit (with "i") and change root=uuid=complicated_thing by root=/dev/sda% for the line which as 2.6.31-rc4 in it. Exit and save. The fstab is a file that gives the options you pass to the filesystem to boot, for exemple, you can activate compression under BTRFS or avoid writing on a filesystem. We must replace the UUID of the "/" in it by /dev/sda%: vim /etc/fstab Seek something like UUID=complicated_thing / ext3 errors=remount-ro 0 1 and replace by /dev/sda3 / btrfs errors=remount-ro 0 1 exit and save
Converting the FilesystemThere is a utility in BTRFS that converts EXT3 to BTRFS filesystem, but you can't use it while your system is running, this is called an offline converter. So we'll have to find another way to do it, that's where we use the ubuntu live CD. reboot your system and boot on the Ubuntu LiveCD. Once the CD finished his boot, use keyboard shotcurt "alt+F2", type "gnome-terminal" (or "konsole" if you picked up kubuntu), then log with the root account with: sudo su Perform step2 including "aptitude update". We don't want to install all the stuff we installed on the debian to build the kernel so just type: aptitude install btrfs-tools If everything went well, you are now booting Debian properly on a BTRFS file system. I hope you enoy this tutorial and that it was helpful. Do not hesitate to comment on this tutorial, to help me improve it, and, please, forgive me for my bad English (I'm French).
|



Recent comments
13 hours 30 min ago
18 hours 29 min ago
19 hours 55 min ago
20 hours 48 min ago
22 hours 31 min ago
1 day 2 hours ago
1 day 3 hours ago
1 day 6 hours ago
1 day 19 hours ago
1 day 20 hours ago