LINUX TIPS AND TRICKS --- April 20, 2001

Published by ITworld.com -- changing the way you view IT
http://www.itworld.com/newsletters
________________________________________________________________

Tips on reiserfs
By Nicholas  Petreley

I decided to live dangerously last week and create a couple of 
reiserfs partitions on my primary Linux server. Reiserfs is a 
journaling file system that is purportedly more efficient at 
handling many small files than the de facto standard ext2fs 
file system and just as efficient as ext2fs in other cases.

What I like most about reiserfs is that it recovers from things 
such as power failures extremely fast, since it doesn't have to 
perform the lengthy consistency checks required by ext2fs. Like 
many other journaling file systems (such as the one used in 
Windows 2000, I believe), reiserfs won't necessarily protect 
your data in the event of a power outage. But it will protect 
the consistency of the file system itself.

Now put down that keyboard if you're about to send me a flame 
for not using a UPS. I am using a UPS. In fact, I strongly 
suspect my UPS has actually been the source of some recent 
power outages. My PK Electronics Blackout Buster UPS and 
regulator decided to go funky on me last week. It turned off 
my server twice, and I think it blew up my Viewsonic P815 
monitor with voltage spikes. I suspect the UPS because I've had 
no real power outages, and I've only had problems with the 
equipment plugged into the UPS. I replaced it with a UPS from 
Belkin, and everything has behaved normally since.

Anyway, I reconfigured my server so that all my shared files 
for NFS and Samba are now on their own reiserfs partition. I 
put my CommuniGate pro mail directories on a reiserfs 
partition, too. My /var partition is also a reiserfs partition, 
which means my Squid Web cache now operates on reiserfs. I 
haven't done any benchmarks yet, but the performance of my Web 
cache and proxy seems to have improved dramatically since I put 
all its files on the reiserfs partition. There are supposedly 
Squid cache optimizations in reiserfs, so perhaps that's why 
I'm seeing noticeable results. Regardless, consider me a big 
fan of reiserfs so far.

In fact, I like it so much that I converted a few of my client 
partitions to reiserfs. The only thing I haven't done yet is 
convert a root partition. I tried but have failed so far. The 
partition that I tried to convert is small, but it resides on a 
40 GB hard drive. I noticed afterward in the FAQ that reiserfs 
has problems with IDE drives larger than 32 GB unless you apply 
a patch. Perhaps that is the problem I'm experiencing. I'll 
work on it and get back to you.

The only other problem I've had is bizarre. I run the 
squidGuard redirector along with the Squid Web cache in order 
to block porn sites. (By the way, if you haven't looked at 
squidGuard, now is the time. It is one delightful piece of 
software! See Resources for link.) Due to a bug in one version 
of Squid, I needed Squid to launch the redirector by running a 
script file called /usr/bin/sguard that looks something 
like this:

#!/bin/bash
exec /usr/local/bin/squidGuard -c /etc/squidGuard/squidGuard.conf

Everything worked fine until I converted /usr/local into a 
reiserfs partition. Then Squid stopped launching the squidGuard 
redirector. I made an identical copy of /usr/local on ext2fs 
and tried it again. It worked. I have no idea why I can't 
execute the file from /usr/local/bin if it is a 
reiserfs partition.

I'd like to figure it out or get a word of advice from someone 
who works on reiserfs. But my interim solution was simple. I 
just copied the squidGuard program to the /usr/bin directory 
(which is ext2fs) and changed the script to run it from there. 
That way I get to keep /usr/local as a reiserfs partition and 
still avoid the problem.

Installing reiserfs
Some distributions include reiserfs as a module compiled into 
the kernel. In that case, you just need to make sure you have 
the reiserfs utilities installed and then issue the command 
modprobe reiserfs to load the module. After that, you're ready 
to format a partition as reiserfs and start using it.

If you don't have reiserfs compiled into your kernel or 
available as a module, fear not. It is very easy to build 
reiserfs support into your kernel. Download and install the 
source code for the kernel of your choice (I am using the 
2.2.17 kernel).

Then download the reiserfs patch (see Resources for a link). 
Put the patch in your /usr/src directory or in the directory 
immediately above where you have your kernel source code.

Before you take the next step, make sure that the path to the 
kernel source code is /usr/src/linux. If it isn't, then rename 
the kernel source code directory or create a symbolic link to 
provide that path. For example, the default Debian source code 
directory might be kernel-source-2.2.17. In that case, you want 
to create a symbolic link such as cd /usr/src; ln -s 
kernel-source-2.2.17 linux.

Now apply the patch. Change to the /usr/src directory and use 
the command zcat linux-2.2.17-reiserfs-3.5.27-patch.gz | patch 
-p0 to apply the patch. If you hastily decompressed the file, 
then run the command patch 
-p0linux-2.2.17-reiserfs-3.5.27-patch instead.

Now you need to configure your kernel. There are several ways 
to do that, but I prefer to change to the /usr/src/linux 
directory and run make menuconfig for that step. You'll need 
ncurses development libraries installed for that to work. If 
you're a hard core Linux user or want to become one, just run 
make config instead. You can also run make xconfig if you 
prefer a graphical configuration tool.

You should notice a reiserfs option in the configuration 
process under the topic file systems now. Select it. I have 
reiserfs configured as a loadable module, since that makes it 
easier to fix any potential reiserfs problems in the future 
without having to recompile the whole kernel. There is another 
option to enable reiserfs internal checks. That option is 
really for debugging purposes, so I strongly recommend that you 
do not use it, since it will slow reiserfs' performance.

If this is your first attempt at creating a custom kernel, 
you'll need to step through all the options and make sure your 
kernel supports everything you need for your system. It is way 
beyond the scope of this column to walk you through that 
process. I recommend reading the README file in the 
/usr/src/linux directory for instructions on how to configure 
and install your new kernel.

Finally, you'll need to compile the reiserfs utilities and 
install them. It is a very simple process. Just change to the 
/usr/src/linux/fs/reiserfs/utils directory 
and run make dep; make; make install.

Now create a partition that you want to format as reiserfs. 
Mark the partition as a Linux filesystem, the same way you 
would if you were about to create a standard ext2 filesystem. 
Assuming your new partition is /dev/hdb3, you would then run 
mkreiserfs /dev/hdb3 to format the partition. That process will 
overwrite any data you may have on that partition, so be sure 
you know what you're doing. Now mount the partition and 
get to work!

About the author(s)
-------------------
Nicholas Petreley writes The Penguin Brief for LinuxWorld.com.
________________________________________________________________

ADDITIONAL RESOURCES

Setting up a Linux Web server 
Overcoming obstacles such as a hard-to-reach ISP and brain mush

http://www.itworld.com/jump/lintps_nl/www.itworld.com/Comp/
2384/LWD010402penguin5/

Setting up a Linux Web server, Part 2 
Getting VarLinux.org up while playing musical NIC cards

http://www.itworld.com/jump/lintps_nl/www.itworld.com/Comp/
2362/LWD010406penguin1/

Filesystems evolve 
Rapid changes in technology demand that filesystems keep up

http://www.itworld.com/jump/lintps_nl/www.itworld.com/Comp/
3801/UIR000915connectivity/
________________________________________________________________

COMMUNITY DISCUSSIONS

Linux Software Development
Hone your Linux development skills, share your expertise, and 
put out the occasional call for help in this discussion for 
programmers of all levels. Moderated by Danny Kalev.

http://www.itworld.com/jump/lintps_nl/forums.itworld.com/
webx?14@@.ee6b652/321!skip=257


Version Control
Linux is making its presence felt on the desktop, but is it 
stable and polished enough for prime time? Talk distributions, 
window managers, themes, and desktop politics here.

http://www.itworld.com/jump/lintps_nl/forums.itworld.com/
webx?14@@.ee6b663/471!skip=404

The Penguin Brief
This is the place to discuss the ideas in Nick Petreley's 
always controversial column, The Penguin Brief.

http://www.itworld.com/jump/lintps_nl/forums.itworld.com/
webx?14@@.ee6f3d9/2!skip=
________________________________________________________________

CONTACTS

* For editorial comments, write Andrew Santosusso, Associate 
  Editor, Newsletters at: andrew_santosusso@itworld.com

* For advertising information, write Dan Chupka, Account 
  Executive at: dan_chupka@itworld.com

* For recruitment advertising information, write Jamie Swartz, 
  Eastern Regional Sales Manager at: jamie_swartz@itworld.com 
  or Paul Duthie, Western Regional Sales Manager at: 
  paul_duthie@itworld.com

* For all other inquiries, write Jodie Naze, Product Manager, 
  Newsletters at: jodie_naze@itworld.com
________________________________________________________________

PRIVACY POLICY

http://www.itworld.com/Privacy/

Copyright 2001 ITworld.com, Inc., All Rights Reserved.
http://www.itworld.com
