adrift in the sea of experience

Sunday, January 17, 2010

Building a NAS, part 2: getting BTRFS on Lenny

update: after discovering that BTRFS isn't as mature as I hoped, I switched to ZFS-FUSE. You might want to read my post on setting up ZFS instead.

The debian "lenny" release comes with version 2.6.26-2 of the linux kernel. This kernel does not yet have support for BTRFS, so we'll download, compile and install the latest stable kernel release.
# install some required packages as root
su
aptitude install install bzip2 fakeroot kernel-package libncurses5-dev zlib1g-dev
exit

# download and extract linux kernel
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.3.tar.bz2
tar -xvjf linux-2.6.32.3.tar.bz2
cd linux-2.6.32.3

# copy existing kernel configuration from /boot
cp /boot/config-2.6.26-2-686 .config

# edit kernel configuration (navigate with arrows, toggle options with space)
# - under "File Systems, enable "Btrfs filesystem (EXPERIMENTAL)"
# - under "Virtualization", disable "Linux hypervisor example code"
#
# You can also take this opportunity to optimize the kernel for your CPU
# architecture under "Processor type and features" - "Processor family"
# Examine the output of "cat /proc/cpuinfo" if you're not sure of your CPU.
make menuconfig

# build kernel (this takes a while, especially on old machines)
make-kpkg --rootcmd fakeroot --initrd linux-image linux-headers

# install new kernel packages and reboot
cd ..
su
dpkg -i linux-image-2.6.32.3_2.6.32.3-10.00.Custom_i386.deb
dpkg -i linux-headers-2.6.32.3_2.6.32.3-10.00.Custom_i386.deb
reboot

If everything went well, the system should boot up under the new kernel. If something goes wrong, you still have the option of booting under the old kernel by using the grub menu at startup.

Now we have a kernel with support for the btrfs filesystem, but still no userspace tools to use it. We'll download, compile and install the latest version of those tools:

aptitude install git-core uuid-dev e2fslibs-dev libacl1-dev
git clone git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs-unstable.git
cd btrfs-progs-unstable
make
su
make install
exit


Now we have mkfs.btrfs to create a BTRFS file system, and some other tools to manage such a filesystem. We'll start playing around with those in the next post.

1 comment:

Anonymous said...

[ 1540.489905] btrfs: use compression
[ 1540.489916] BTRFS: couldn't mount because of unsupported optional features (1).

can u give me a solution....