Wednesday, September 28, 2011

Reiser file system for linux


2005-11-17: These are just my personal notes on Reiser file system under linux. Sections of this web page:
useful links
loop-mounting ReiserFS on a linux file


Reiser file system links

linkcomments
namesys.com Includes Reiser v4 file system. See also Reiser4 Transaction Design Document. It seems that SuSE linux 9.0 has Reiser version 3.6. This is probably true also for SuSE linux 9.1. (These observations come from the reiserfs kernel module source in each case.)
See also Getting started with Reiser4 (including FTP URLs for kernel and user-space source) and the reiser fs source download.
reiserfs 2005-5-25: Tutorial at linux planet on 2001-1-22.
Reiser structure 2005-5-25: The structure of the Reiser file system by Florian Buchholz. Now this is more like it! This is the kind of detail I was looking for. Unfortunately, it only deals with Reiser version 3.6. See also Florian's Forensics page.


Creating a Reiser file system as a loop-mount file.
To create a 20-MiByte Reiser file system file (on a SuSE 9.0 system), do something like this.
root@shark# dd if=/dev/zero of=reiser1.img count=40960
40960+0 records in
40960+0 records out

root@shark# ls -l reiser1.img
-rw-r--r--    1 root     root     20971520 Nov 17 19:16 reiser1.img

root@shark# losetup /dev/loop3 reiser1.img

root@shark# losetup /dev/loop3
/dev/loop3: [0700]:109 (reiser1.img) offset 0, no encryption

root@shark# mkfs.reiserfs /dev/loop3
mkfs.reiserfs 3.6.9 (2003 www.namesys.com)

A pair of credits:
Vitaly Fertman wrote  fsck for V3 and  maintains the reiserfsprogs package now.
He wrote librepair,  userspace plugins repair code, fsck for V4,  and worked on
developing libreiser4 and userspace plugins with Umka.

Alexander  Lyamin  keeps our hardware  running,  and was very  generous  to our
project in many little ways.

Guessing about desired format.. Kernel 2.4.21-215-default is running.
reiserfs_create_journal: cannot create a journal of 8193 blocks with 18 offset
on 5120 blocks
Hmmm. I guess this means I need a bigger file to mount on. Here's the built-in Reiser 3.6.9 manual.
root@shark# mkfs.reiserfs
Usage: mkfs.reiserfs [options]  device [block-count]

Options:

  -b | --block-size N              size of file-system block, in bytes
  -j | --journal-device FILE       path to separate device to hold journal
  -s | --journal-size N            size of the journal in blocks
  -o | --journal-offset N          offset of the journal from the start of
                                   the separate device, in blocks
  -t | --transaction-max-size N    maximal size of transaction, in blocks
  -h | --hash rupasov|tea|r5       hash function to use by default
  -u | --uuid UUID                 store UUID in the superblock
  -l | --label LABEL               store LABEL in the superblock
  --format 3.5|3.6                 old 3.5 format or newer 3.6
  -f | --force                     specified once, make mkreiserfs the whole
                                   disk, not block device or mounted partition;
                                   specified twice, do not ask for confirmation
  -q | --quiet                     quiet work without messages, progress and
                                   questions. Useful if run in a script. For use
                                   by end users only.
  -d | --debug                     print debugging information during mkreiser
  -V                               print version and exit
Maybe I could reduce the journal size. But instead I'll just make the file bigger. Here we go again...
root@shark# dd if=/dev/zero of=reiser1.img count=204800
204800+0 records in
204800+0 records out

root@shark# ls -l reiser1.img
-rw-r--r--    1 root     root     104857600 Nov 17 19:52 reiser1.img

root@shark# losetup /dev/loop3 reiser1.img

root@shark# losetup /dev/loop3
/dev/loop3: [0700]:109 (reiser1.img) offset 0, no encryption

root@shark# mkfs.reiserfs /dev/loop3
mkfs.reiserfs 3.6.9 (2003 www.namesys.com)

A pair of credits:
Edward Shushkin wrote the encryption and compression  file plugins,  and the V3
journal relocation code.

Vladimir Demidov wrote the parser for sys_reiser4(), the V3 alpha port, part of
the V3  journal  relocation code,  and helped  Hans keep  the business  side of
things running.

Guessing about desired format.. Kernel 2.4.21-215-default is running.
Format 3.6 with standard journal
Count of blocks on the device: 25600
Number of blocks consumed by mkreiserfs formatting process: 8212
Blocksize: 4096
Hash function used to sort names: "r5"
Journal Size 8193 blocks (first block 18)
Journal Max transaction length 1024
inode generation number: 0
UUID: a5387467-085a-4dea-be5a-18eddf521aea
ATTENTION: YOU SHOULD REBOOT AFTER FDISK!
        ALL DATA WILL BE LOST ON '/dev/loop3'!
Continue (y/n):
Now that's more like it! I say y to this:
Continue (y/n):y
Initializing journal - 0%....20%....40%....60%....80%....100%
Syncing..ok
ReiserFS is successfully created on /dev/loop3.
Now continuing...
root@shark# mkdir reiser1

root@shark# ls -ld reiser*
drwxr-xr-x    2 root     root           48 Nov 17 19:55 reiser1
-rw-r--r--    1 root     root     104857600 Nov 17 19:52 reiser1.img

root@shark# mount /dev/loop3 reiser1

root@shark# df reiser1
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/loop3              102392     32840     69552  33% /home2/rsoft/reiser1
Well, what could be simpler!!
Ironically, the file reiser1.img is itself in a file system which is an encrypted loop-mounted Reiser file system.
The next logical step is to work out how to undo the deed.
root@shark# umount reiser1

root@shark# df reiser1
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hdd1            156275512  24241608 132033904  16% /home2

root@shark# losetup /dev/loop3
/dev/loop3: [0700]:109 (reiser1.img) offset 0, no encryption

root@shark# losetup -d /dev/loop3

root@shark# losetup /dev/loop3
loop: can't get info on device /dev/loop3: No such device or address
Alles klar, as they say in the old country!
It's interesting to look into the formatted file.
root@shark# od -ah reiser1.img | head -20
0000000 nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul
        0000 0000 0000 0000 0000 0000 0000 0000
*
0200000 nul   d nul nul   l   C nul nul dc3  sp nul nul dc2 nul nul nul
        6400 0000 43ec 0000 2013 0000 0012 0000
0200020 nul nul nul nul nul  sp nul nul nul eot nul nul  ff   N   -   `
        0000 0000 2000 0000 0400 0000 ce0c 602d
0200040 eot etx nul nul  rs nul nul nul nul nul nul nul nul dle   L etx
        0384 0000 001e 0000 0000 0000 1000 03cc
0200060 stx nul soh nul   R   e   I   s   E   r   2   F   s nul nul nul
        0002 0001 6552 7349 7245 4632 0073 0000
0200100 etx nul nul nul stx nul soh nul stx nul nul nul nul nul nul nul
        0003 0000 0002 0001 0002 0000 0000 0000
0200120 soh nul nul nul   %   8   t   g  bs   Z   M   j   >   Z can   m
        0001 0000 38a5 6774 5a08 ea4d 5abe ed18
0200140   _   R sub   j nul nul nul nul nul nul nul nul nul nul nul nul
        52df ea1a 0000 0000 0000 0000 0000 0000
0200160 nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul
        0000 0000 0000 0000 0000 0000 0000 0000
*
Höchst interessant, as we used to say in the old country!!
So let's try this just once more to make sure it's all okay.
root@shark# losetup /dev/loop3 reiser1.img
root@shark# mount /dev/loop3 reiser1
root@shark# df reiser1
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/loop3              102392     32840     69552  33% /home2/rsoft/reiser1
Alles in Ordnung!


Go to my notes on loop-mounting a Minix file system.
Go to my notes on other linux configuration topics.
Go to my linux kernel links.
Go to linux file systems links.
Go to Alan Kennington's home page.

http://www.topology.org/linux/reiser.html

No comments:

Post a Comment