Debian Closure: Enhancing Linux Kernel 3.15.2 With Reiser4 Patch

Linux, Current Trends, Cloud Computing Send feedback »
Debian Closure: Enhancing Linux Kernel 3.15.2 With Reiser4 Patch

NOTE: updated on Jun 28, 2014 to reflect kernel 3.15.2

Although Reiser4 file system support is non-existent in a regular GNU/Linux Debian distribution, I will be describing below how I patched a pristine Linux kernel to support that experimental file system. Additionally, we will be formatting a partition in reiser4 using Debian reiser4progs utilities. Thus, we deduce that it is possible to backup and/or copy the data of an existing root partition into an ephemeral place holder, format the existing partition in reiser4, then copy over our data; it works as long as we have a separate /boot partition &#59;) because GRUB does not currently support booting from reiser4. Notwithstanding, tweaking Grub97 (legacy) it is possible to boot from a reiser4 partition by patching the grub97 source. Lastly, as we are building upon our previous Debian kernel work, we will end up with aufs3 and support in our kernel &#59;D.

supports multiple transaction models.

you probably know, all other file systems implement only a
transaction model. That is, they all are either only journalling
(ext3/4, ReiserFS(v3), XFS, jfs, ...), or only "write-anywhere"
(ZFS, Btrfs, etc)

Starting from reiser4-for-3.14.1, you can choose a transaction model, which is most suitable for your device

Cool! We will be downloading a pristine Linux kernel 3.15.2 from

If you have not, wielding root privilege install you build development packages:


apt-get update
apt-get install build-essential kernel-package wget bzip2 bc git patch fakeroot libncurses5 libncurses5-dev

We create a working directory tlacauhtli (space of place, in Nahuatl) relative to /usr/src/build/, and we proceed to change directory into it:


mkdir --verbose tlacauhtli-3.15.2
cd tlacauhtli-3.15.2

and fetch into our tlacauhtli-3.15.2 directory the desired Linux kernel and signature files:



And then we proceed to verify our kernel:


xz -dc linux-3.15.2.tar.xz gpg --verify linux-3.15.2.tar.sign -

(sample output)

gpg: Signature made Thu 26 Jun 2014 12:18:31 PM PDT using RSA key ID 6092693E
gpg: Good signature from "Greg Kroah-Hartman (Linux kernel stable release signing key) <>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 647F 2865 4894 E3BD 4571 99BE 38DB BDC8 6092 693E

We create -- and change into -- a build directory:


mkdir --verbose build
cd build
tar -xvJPf ../linux-3.15.2.tar.xz

We git clone aufs3 standalone, cd into newly created directory, and git checkout origin -- making sure we reference the kernel minor version number, i.e., 3.15:


git clone git:// aufs3-standalone.git
cd aufs3-standalone.git
git checkout origin/aufs3.15

Note: checking out 'origin/aufs3.15'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b new_branch_name

HEAD is now at 055bc89... aufs3.15 20140623

And create subdirectories to stage our aufs3 patch for our kernel:


mkdir --verbose ../../y
cp -rv Documentation fs include ../y/.
rm -../y/include/uapi/linux/Kbuild

make sure directive 3 above is executed, else you should specify 'no' when prompted, subsequently, by the patch utility whether it should replace Kbuild in your linux kernel tree.

We are ready to create our aufs3 patch for our kernel:


cd ..
diff -rupN xy/ > linux-3.15.2/aufs.patch
cat aufs3-standalone.git/*.patch >> linux-3.15.2/aufs.patch

we change directories to the linux kernel source and apply our newly created aufs.patch:


cd linux-3.15.2
cat aufs.patch patch -p1

Applying Reiser4 patch to our Linux kernel source tree.

We assume that we will be applying our patches from our current linux-3.15.2 directory.

There is a patch set that a SuSE GNU/Linux engineer, Jeff Mahoney, published at the reiser4 mail list. It consists of 29 patches which I saved into a specific directory -- renaming each patch as mahoney_1.patch to mahoney_29.patch -- and subsequently applied with the directives:


for i in $(seq 1 $x); do cat ~/temp/mahoney_$i.patch patch -lp1done

for convenience, I make available Mahoney's archive used in above command as or please make your own from the link mentioned previously.1

for ease of description we assumed above that the patch set is at the ~/temp/ directory but adjust for your unique situation.

Analyzing the patch -lp1 directive in the command above, the option l or --ignore-whitespace is necessary to prevent the following issue issue when applying mahoney_3.patch (i.e., 03/29):

Hunk #80 FAILED at 3145.
Hunk #101 FAILED at 3677.
2 out of 126 hunks FAILED -- saving rejects to file fs/reiserfs/journal.c.rej

For additional details, please type man patch directive at your command prompt.

Below is the sample output from additional issue experienced when applying mahoney_3.patch (i.e., 03/29):

patching file fs/reiserfs/bitmap.c
patching file fs/reiserfs/dir.c
Hunk #4 succeeded at 143 with fuzz 2 (offset 1 line).
Hunk #5 succeeded at 163 (offset 1 line).
Hunk #6 succeeded at 191 (offset 1 line).
Hunk #7 FAILED at 218.
Hunk #8 succeeded at 231 (offset 2 lines).
Hunk #9 succeeded at 274 (offset 2 lines).
1 out of 9 hunks FAILED -- saving rejects to file fs/reiserfs/dir.c.rej
patching file fs/reiserfs/do_balan.c
patching file fs/reiserfs/file.c
patching file fs/reiserfs/fix_node.c
patching file fs/reiserfs/hashes.c
patching file fs/reiserfs/ibalance.c
patching file fs/reiserfs/inode.c
patching file fs/reiserfs/ioctl.c
patching file fs/reiserfs/item_ops.c
patching file fs/reiserfs/journal.c
patching file fs/reiserfs/lbalance.c
patching file fs/reiserfs/namei.c
patching file fs/reiserfs/objectid.c
patching file fs/reiserfs/prints.c
patching file fs/reiserfs/reiserfs.h
Hunk #76 succeeded at 3376 (offset 1 line).
patching file fs/reiserfs/resize.c
patching file fs/reiserfs/stree.c
patching file fs/reiserfs/super.c
Hunk #1 succeeded at 153 (offset -1 lines).
Hunk #2 succeeded at 284 (offset -1 lines).
Hunk #3 succeeded at 307 (offset -1 lines).
Hunk #4 succeeded at 327 (offset -1 lines).
Hunk #5 succeeded at 382 (offset -1 lines).
Hunk #6 succeeded at 541 (offset -1 lines).
Hunk #7 succeeded at 555 (offset -1 lines).
Hunk #8 succeeded at 650 (offset -1 lines).
Hunk #9 succeeded at 805 (offset -1 lines).
Hunk #10 succeeded at 872 (offset -1 lines).
Hunk #11 succeeded at 905 (offset -1 lines).
Hunk #12 succeeded at 938 (offset -1 lines).
Hunk #13 succeeded at 1006 (offset -1 lines).
Hunk #14 succeeded at 1046 (offset -1 lines).
Hunk #15 succeeded at 1069 (offset -1 lines).
Hunk #16 succeeded at 1117 (offset -1 lines).
Hunk #17 succeeded at 1173 (offset -1 lines).
patching file fs/reiserfs/tail_conversion.c
patching file fs/reiserfs/xattr.c
patching file fs/reiserfs/xattr.h
patching file fs/reiserfs/xattr_acl.c

Thus, at fs/reiserfs/dir.c
Mahoney's 03/29 patch does not match comment text string:
// next entry should be looked for with such offset

instead, we have comment text string of the form:
/* deh_offset(deh) may be invalid now. */

Debian Closure: Enhancing Linux Kernel 3.15.2 With Reiser4 Patch

Thus, after close examination, we may conclude that we may disregard this single 'hunks FAILED' and continue with the application of the official reiser4 patch. Or you may wait for Linux kernel 3.16 &amp;#59;&amp;#41; -- as Mahoney states it has incorporated his patch set.

We proceed to download the reiser4 gzip compressed patch from Reiser4 file system for Linux OS SourceForge site. Download the newest version for your kernel major and minor version, i.e., currently kernel major version is 3 and minor version is 14. (Yes, this patch can still be used for our Linux kernel 3.15.2).

For ease of illustrating the procedure, I assume downloaded patch is at ~/temp/ directory location -- but modify directive below to suit your specific circumstances:


gzip -dc ~/temp/reiser4-for-3.14.1.patch.gz patch -p1

The patch should apply without issues into our Linux kernel 3.15.2 source tree. Since I am building upon previously built AUFS3 + cgroups/ enabled kernel built as described in previous post, Debian: (Revisited) Patching Linux Kernel 3.14 To Enable Aufs3.13 Mod and CGROUPS for Docker, I will be importing it's config into my linux-3.15.2 directory prior to building my kernel.


cat /boot/config-`uname -r` >.config
make oldconfig
make xconfig

Searching for text string 'reiser4' we can see in the sample snapshot below that we may enable the reiser4 feature as a (m)odule -- visually shown by a small dot inside the selection box:

Debian Closure: Enhancing Linux Kernel 3.15.2 With Reiser4 Patch

Or we may enable the reiser4 feature by integrating it into the kernel -- visually shown (once we doble-click on the option) by a small check mark inside the selection box:

Debian Closure: Enhancing Linux Kernel 3.15.2 With Reiser4 Patch

Note: if this is the very first time you will be hacking your root partition to reiser4, you may want to use this latter option -- especially if your original root partition is btrfs-formated.

We save our modifications -- if any -- and we Do:


fakeroot make-kpkg clean

Once more, I proceed to build my kernel: Xonecuiltzin6 which &amp;#58;&amp;#121;&amp;#101;&amp;#115;&amp;#58; prefixed with a leading dot, I provide as an argument to --append-to-version in the directive that follows:


time fakeroot make-kpkg --append-to-version=.xonecuiltzin --stem aufs3+cgroup+reiser4x -j8 --initrd kernel_image kernel_headers

Indeed, I provide aufs3+cgroup+reiser4x as an argument to --stem because I want to know the main reason for my kernel customization (where x is reiser4 feature for either module or incorporated into the kernel). Additionally, I provide 8 as an argument to -j. Eight(8) represents the number of threads I wish to launch, hence I make it equal to the number of cores in my machine where I am building the kernel -- for optimum performance during compilation.

Debian Closure: Enhancing Linux Kernel 3.15.2 With Reiser4 Patch

Formatting a Reiser4 Partition Under Debian

In Debian, wielding root privilege, we install administration utilities for the Reiser4 filesystem:


apt-get install reiser4progs

We are now ready to format a disk and/or partition in the Reiser4 filesystem.

NOTE: mkfs.reiser4 of version 1.0.8 by default turns intelligent compression on. To disable compression, override it by the option "create=reg40"

Thus, assuming we want to format an existing partition referenced by /dev/sda11 and...

boot off the Reiser4 partition, i.e., the kernel (usually a file in /boot) is actually located on a Reiser4 partition


mkfs.reiser4 -o create=reg40 /dev/sda11

mkfs.reiser4 1.0.8
Copyright (C) 2001-2005 by Hans Reiser, licensing governed by reiser4progs/COPYING.

Overriding the plugin profile by "create=reg40".
Block size 4096 will be used.
Linux 3.14.4.tezcatlipoca is detected.
Uuid 76fbdf79-19ff-4231-ba02-79f80301aaa4 will be used.
Reiser4 is going to be created on /dev/sda11.
(Yes/No): yes
Creating reiser4 on /dev/sda11 ... done

Debian Closure: Enhancing Linux Kernel 3.15.2 With Reiser4 Patch

...And Patching and Building Legacy Grub97

If on AMD64 architecture, proceed to install ia32-libs support7:


dpkg --add-architecture i386
apt-get install ia32-libs libc6-dev-i386 lib32gcc1 gcc-multilib lib32stdc++6 g++-multilib gcc g++ bcc

Now, since current GRUB does no support booting from a Reiser4 partition, we will be hacking legacy grub97 with a legacy Reiser4 patch. We will need to download the following legacy resources:

  1. grub-0.97.tar.gz
  2. grub_0.97-59.diff
  3. libaal-1.0.5.tar.gz
  4. reiser4progs-1.0.5.tar.gz
  5. Grub-0.97-libaal-1.0.5-reiser4progs-1.0.5.patch

For convenience, I include those resources in a zip archive available as; but feel free to go and fish for them in the wild Internet if you feel adventurous &amp;#58;&amp;#41;&amp;#41;

We setup our environment at the command line.

Since I am in a Debian for AMD64 environment, I do:


export CC="gcc -m32"

and proceed to set my other build environment variables:


export LDFLAGS=-L/opt/grub-r4/lib CPPFLAGS=-I/opt/grub-r4/include

evidently we will need to wield root privilege to write to our target directory: /opt/grub-r4.

In Nahuatl, Mexico's language par excellence, tekitl means work or task; thus we create a relative grub-tekitl working directory:


mkdir --verbose grub-tekitl
cd grub-tekitl

I am assuming that you downloaded my zip archive available as in your home ~/temp/ directory. Use unzip utility to decompress:


unzip ~/temp/

You will find a newly created legacy-grub-reiser4/ directory at your current directory location, i.e., grub-tekitl/legacy-grub-reiser4, with the five(5) file resources you will need to operate further:

  1. grub-0.97.tar.gz
  2. grub_0.97-59.diff
  3. libaal-1.0.5.tar.gz
  4. reiser4progs-1.0.5.tar.gz
  5. Grub-0.97-libaal-1.0.5-reiser4progs-1.0.5.patch

We move legacy-grub-reiser4/* content to our current directory:


mv -iv legacy-grub-reiser4/* .

and untar and extract its *gz files:


for i in *gz; do tar -xvPf $idone

we will find that we have three(3) newly created directories:

  1. libaal-1.0.5/
  2. reiser4progs-1.0.5/
  3. grub-0.97/

Snapshot below is a summary of what we did:

Debian Closure: Enhancing Linux Kernel 3.15.2 With Reiser4 Patch

And we change into libaal-1.0.5/ directory to operate upon


cd libaal-1.0.5
./configure --prefix=/opt/grub-r4
make install

again, the last directive will require you to acquire root or super user privilege. Subsequently analyzing recursively the target directory with:


ls -/opt/grub-r4

Debian Closure: Enhancing Linux Kernel 3.15.2 With Reiser4 Patch

and we continue by changing directory to reiser4progs-1.0.5/ relative to our current location:


cd ../reiser4progs-1.0.5
./configure --prefix=/opt/grub-r4
make install

After executing last directive wielding root or super user privilege, we examine our target directory with a recursive listing, once more:


ls -/opt/grub-r4

Debian Closure: Enhancing Linux Kernel 3.15.2 With Reiser4 Patch

Finally we change to grub-0.97/ directory and apply grub_0.97-59.diff into our grub-97 source tree; we follow by applying the Grub-0.97-libaal-1.0.5-reiser4progs-1.0.5.patch. Subsequently we add a CFLAGS prefix to our configure command directive prior to executing make, as sequence is shown below:


cd ../grub-0.97
cat ../grub_0.97-59.diff patch -p1
cat ../Grub-0.97-libaal-1.0.5-reiser4progs-1.0.5.patch patch -p1
CFLAGS="-Wl,--build-id=none" ./configure --prefix=/opt/usr

The sequence should end without errors.

We list the contents in stage2/ directory which end in *1_5 followed by a du directive to estimate its file space usage


ls stage2/*1_5
du -hs stage2/*1_5

64K stage2/reiser4_stage1_5 must be there:

please see sample screenshot below:

Debian Closure: Enhancing Linux Kernel 3.15.2 With Reiser4 Patch

Notice that the ./configure --prefix= target that we used was /opt/usr. Were we to actually install our build of Reiser4-patched Grub97-59 above, we would have selected as target the /usr directory in our Debian distribution.

Were I, wielding root or super user privilege, proceeded to install legacy Reiser4-patched Grub97-59 at /opt/usr with:


make install
ls -/opt/usr

shown below is what one would expect to install and/or replace if the target had been /usr:

Debian Closure: Enhancing Linux Kernel 3.15.2 With Reiser4 Patch

On the other hand...

If you have a separate partition for /boot (e.g. a (readonly-mounted) ext2 partition at the beginning of your disk) and your root-filesystem is on a ReiserFS/Reiser4 partition, you only need to make sure that ReiserFS/Reiser4 support is enabled in your kernel - but that's true for every filesystem and has nothing to to with the bootloader.

You do not need to build and patch Grub-97; neither may you care about avoiding the default compression during Reiser4 file system creation.

All you would care is about having an intermediate place holder partition to hold your data temporarily, format your partition or disk with Reiser4, and then copy back your data. You may use copy command to and from the target disk or partition:


cp -/mounted/source-dev/* /mounted/target-dev/.

Be forewarned that depending on the quantity of data you are operating upon it may take a (long) while for the operations to complete.

And yes &amp;#58;&amp;#121;&amp;#101;&amp;#115;&amp;#58; you will need to modify your Debian /boot/grub/grub.cfg configuration as well as its /etc/fstab file to reflect its partition(s) UUID change due to creation of Reiser4 file system -- at the very least.

Happy hacking!


1Big thanks to user doiggl for providing me with Mahoney's patch 03/29 which somehow does not show up in ReiserFS Development List archive.
2.Tezcatlipoca Glyph by Princess Shadyk

3.How do I iterate over a range of numbers defined by variables in bash?

4. How to apply a patch/diff and solve "hunk FAILED", "can't find file to patch" and others

5. Reiser4 Howto

6 Xonecuiltzin is another name by which Tezcatlipoca -- and Cuauhtemoc which began my first of these three blog posts -- is known to the Mexicah.

By word of mouth we are told that after the Spanish invaders tortured Cuauhtemoc by severely burning his feet, the last Mexicah Tlatoani ('Speaker' or ruler) 'was never able to walk well'. Having failed to make Cuauhtemoc reveal where Moctezuma's treasure was hidden, his Spanish torturers let him go and as Cuauhtemoc painfully descended a stairway, a Spaniard pushed him. As he collapsed, Cuauhtemoc lost three(3) feathers.

Today, many Mexicah dancers honor him, Cuauhtemoc, a.k.a. Xonecuiltzin (The CrippledEl Chueco) by burning three(3) feathers in copalli, i.e., incense.

7 Debian wiki: Multiarch Implementation.

8. Installing GRUB on a Reiser4 Partition

9. grub configure fails w/ "GRUB requires a working absolute objcopy"

10. "grub" 0.97-59 source package in Debian "oldstable"; alternatively search from fileWatcher - The File Search Engine

11. How to increase the vertical split window size in Vim

DISCLAIMER&amp;#58;&amp;#80; although due diligence has been applied, this resource is made available for testing/evaluation purposes on an AS IS basis. The procedure only reflects my own modifications, my limited testing, and the potential user who executes the procedures assumes all risks.

Please do not hold me or Metztli Information Technology (and/or its associates) responsible if the information provided here does not achieve the desired result. The information is provided AS IS and with the hope that it may be useful to the Internet community --especially those interested in Reiser4 support on Debian.

Notwithstanding, There is no implicit or explicit guarantee that the information presented here is accurate --even though due diligence was exercised during the procedure. Accordingly, if an user(s) decide to implement the procedure or shell commands described here she, he, or them, do so at her, his, or their own risk. You have been forewarned.

Contact / Help. ©2014 by Jose. blog software / web host / advertising.
Design & icons by N.Design Studio. Skin by Tender Feelings / Evo Factory.