ReiserFSをつかってみる Edit

ReiserFS(ジャーナリング機能を有し、障害に強いファイルシステム)上にdebian26を構築してみる。

次のような手順で行った。

  • resize2fsとfdiskを使用してパーティション/dev/hda3を縮小。
  • 空いた領域にパーティション/dev/hda4を新規作成。
  • /dev/hda4をReiserFSとして、その上にdebian26を構築。

ReiserFS化関連ツールのインストール Edit

  • LANDISKへtelnetしてrootになる
    手順省略…

  • ルートファイルシステムをrwでリマウント
    # mount -o rw,remount /
    
  • インストール
    reiserfs_tools.tgzは本ページの末尾に添付してます。
    # cd /
    # tar vxfz /mnt/hda3/share/disk/reiserfs_tools.tgz
    ./sbin/
    ./sbin/mkreiserfs
    ./sbin/reiserfsck
    ./sbin/resize_reiserfs
    ./sbin/debugreiserfs
    ./sbin/reiserfstune
    ./sbin/mkfs.reiserfs
    ./sbin/fsck.reiserfs
    ./sbin/resize2fs
    ./lib/
    ./lib/modules/
    ./lib/modules/2.4.21/
    ./lib/modules/2.4.21/kernel/
    ./lib/modules/2.4.21/kernel/fs/
    ./lib/modules/2.4.21/kernel/fs/reiserfs/
    ./lib/modules/2.4.21/kernel/fs/reiserfs/reiserfs.o
    ./mnt/
    ./mnt/hda4/
    #
    # depmod -a
    

ファイルシステムのサイズ変更 Edit

  • 容量確認
    df で /dev/hda3 の容量を確認すると、サイズは 153GB で、そのうち 23GB を使用していることがわかります。
    ファイルの整理やバックアップ等を行い、/dev/hda3の使用サイズを適当に削減してください。
    # df
    Filesystem           1k-blocks      Used Available Use% Mounted on
    rootfs                   69973     58519      7841  88% /
    /dev/root                69973     58519      7841  88% /
    /dev/ram0                 1003       174       778  18% /mnt/ram0
    /dev/hda3            153210596  23558460 126539064  16% /mnt/hda3
    
  • ファイルシステムのサイズ割り当て方針
    /dev/hda3のサイズを50GBに変更して、残り(約100GB)を/dev/hda4に割り当てることにします。
    ファイルシステムのサイズ変更は次のような手順で行います。
    • /dev/hda3をumount
    • e2fsckを行う
    • resize2fsで/dev/hda3ファイルシステムサイズ変更

  • では実際にファイルシステムのサイズ変更を行ってみましょう
    • umount
      ※ mount: /mnt/hda3: device is busyと出た場合は、再立ち上げすると良い。
      (samba等が/mnt/hda3をロックしているのが原因)
      # umount /dev/hda3
      
    • e2fsck
      ファイルの不整合が検出され、キー入力待ち状態になる場合があります。
      大抵の場合、リターン(Yes)を選択すると問題を自動修復してくれます。
      # e2fsck -f /dev/hda3
      e2fsck 1.27 (8-Mar-2002)
      Pass 1: Checking inodes, blocks, and sizes
      Pass 2: Checking directory structure
      Pass 3: Checking directory connectivity
      Pass 4: Checking reference counts
      Pass 5: Checking group summary information
      Free blocks count wrong (32413034, counted=32413393).
      Fix<y>? yes
      
      Free inodes count wrong (18501267, counted=18501226).
      Fix<y>? yes
      
      /dev/hda3: ***** FILE SYSTEM WAS MODIFIED *****
      /dev/hda3: 962966/19464192 files (6.0% non-contiguous), 6500053/38913446 blocks
      
  • resize2fs
    本コマンドを使用してファイルシステムのリサイズ(縮小)を行います。
    (パーティションのリサイズではなく、ファイルシステムのリサイズですので、お間違えなきよう。。。)

    予定しているサイズ(50GB)よりすこし少な目の容量(45GB)を設定するのがミソです。
    (fdiskでパーティションのリサイズを行った後、あらためて、それにジャストフィットするよう
    ファイルシステムのリサイズを行います。ですから、ここでは、少な目の容量を設定します。)
    # resize2fs -p /dev/hda3 45G
    esize2fs 1.35 (28-Feb-2004)
    Resizing the filesystem on /dev/hda3 to 11796480 (4k) blocks.
    Begin pass 2 (max = 671)
    Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Begin pass 3 (max = 1188)
    Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Begin pass 4 (max = 56000)
    Updating inode references     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    The filesystem on /dev/hda3 is now 11796480 blocks long.
    ※1block=4Kbyteだから、だいたい指定通り↑
    

パーティションの設定とReiserFSの作成 Edit

  • fdisk
    fdiskを使用して、/dev/hda3のパーティションサイズを縮小し、空いた領域に、/dev/hda4を新規作成します。
    • 注意すべきこと
      • 下記「注意:必ずそのままリターン」の場所は決して値を設定してはいけません。
        値を設定すると、/dev/hda3の先頭番地が変更されるため、データが完全に失われます。
      • ミスった場合、CTRL-Cでfdiskを中止して再度やり直してください。
        wコマンドで書き込みを行うまで、何度でもやりなおし可能です。
    # fdisk /dev/hda
    
    The number of cylinders for this disk is set to 19457.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
       (e.g., DOS FDISK, OS/2 FDISK)
    
    Command (m for help): p
    
    Disk /dev/hda: 255 heads, 63 sectors, 19457 cylinders
    Units = cylinders of 16065 * 512 bytes
    
       Device Boot    Start       End    Blocks   Id  System
    /dev/hda1             1         9     72261   83  Linux
    /dev/hda2            10        79    562275   82  Linux swap
    /dev/hda3            80     19457 155653785   83  Linux
    
    Command (m for help): d
    Partition number (1-4): 3
    
    Command (m for help): p
    
    Disk /dev/hda: 255 heads, 63 sectors, 19457 cylinders
    Units = cylinders of 16065 * 512 bytes
    
       Device Boot    Start       End    Blocks   Id  System
    /dev/hda1             1         9     72261   83  Linux
    /dev/hda2            10        79    562275   82  Linux swap
    
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 3
    First cylinder (80-19457, default 80): 注意:必ずそのままリターン
    Using default value 80
    Last cylinder or +size or +sizeM or +sizeK (80-19457, default 19457): +50000M
    
    Command (m for help): p
    
    Disk /dev/hda: 255 heads, 63 sectors, 19457 cylinders
    Units = cylinders of 16065 * 512 bytes
    
       Device Boot    Start       End    Blocks   Id  System
    /dev/hda1             1         9     72261   83  Linux
    /dev/hda2            10        79    562275   82  Linux swap
    /dev/hda3            80      6454  51207187+  83  Linux
    
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 4
    First cylinder (6455-19457, default 6455): そのままリターン
    Using default value 6455
    Last cylinder or +size or +sizeM or +sizeK (6455-19457, default 19457): そのままリターン
    Using default value 19457
    
    Command (m for help): p
    
    Disk /dev/hda: 255 heads, 63 sectors, 19457 cylinders
    Units = cylinders of 16065 * 512 bytes
    
       Device Boot    Start       End    Blocks   Id  System
    /dev/hda1             1         9     72261   83  Linux
    /dev/hda2            10        79    562275   82  Linux swap
    /dev/hda3            80      6454  51207187+  83  Linux
    /dev/hda4          6455     19457 104446597+  83  Linux
    
    Command (m for help): w  ← 書き込みを行います。
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Re-read table failed with error 16: Device or resource busy.
    Reboot your system to ensure the partition table is updated.
    
    WARNING: If you have created or modified any DOS 6.x
    partitions, please see the fdisk manual page for additional
    information.
    Syncing disks.
    # 
    
  • 一旦リブートします。
    理由は不明ですが、リブートしないと、mkreiserfsがうまくかからないようです。

  • mkreiserfs
    /dev/hda4をReiserFSに設定します。
    # mkreiserfs /dev/hda4
    mkreiserfs 3.6.19 (2003 www.namesys.com)
    
    A pair of credits:
    BigStorage  (www.bigstorage.com)  contributes to our general fund  every month,
    and has done so for quite a long time.
    
    Hans Reiser was the project initiator,  source of all funding for the first 5.5
    years. He is the architect and official maintainer.
    
    
    Guessing about desired format.. Kernel 2.4.21 is running.
    Format 3.6 with standard journal
    Count of blocks on the device: 26111648
    Number of blocks consumed by mkreiserfs formatting process: 9008
    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: 57a875a4-fe10-4b01-be78-e4ffe814f9c3
    ATTENTION: YOU SHOULD REBOOT AFTER FDISK!
            ALL DATA WILL BE LOST ON '/dev/hda4'!
    Continue (y/n):y
    Initializing journal - 0%....20%....40%....60%....80%....100%
    Syncing..ok
    
    Tell your friends to use a kernel based on 2.4.18 or later, and especially not a
    kernel based on 2.4.9, when you use reiserFS. Have fun.
    
    ReiserFS is successfully created on /dev/hda4.
    
  • /dev/hda3のパーティションサイズ・フィッティング
    /dev/hda3のパーティションサイズと、ファイルシステムサイズのミスマッチを修正します。
    # umount /dev/hda3
    
    # e2fsck -f /dev/hda3
    e2fsck 1.27 (8-Mar-2002)
    Pass 1: Checking inodes, blocks, and sizes
    Pass 2: Checking directory structure
    Pass 3: Checking directory connectivity
    Pass 4: Checking reference counts
    Pass 5: Checking group summary information
    /dev/hda3: 962966/5898240 files (6.0% non-contiguous), 6074348/11796480 blocks
    
    # resize2fs -p /dev/hda3
    resize2fs 1.35 (28-Feb-2004)
    Resizing the filesystem on /dev/hda3 to 12801796 (4k) blocks.
    Begin pass 1 (max = 31)
    Extending the inode table     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    The filesystem on /dev/hda3 is now 12801796 blocks long.
    
    # mount -t ext2 /dev/hda3 /mnt/hda3
    
  • リブート
    念のため。

  • マウント&動作確認
    # mkdir  /mnt/hda4
    # modprobe reiserfs
    # mount -t reiserfs /dev/hda4 /mnt/hda4
    
    # cat /proc/mounts
    rootfs / rootfs rw 0 0
    /dev/root / ext2 ro 0 0
    /proc /proc proc rw 0 0
    none /dev/pts devpts rw 0 0
    /dev/ram0 /mnt/ram0 ext2 rw 0 0
    /dev/hda3 /mnt/hda3 ext2 rw 0 0
    /dev/hda4 /mnt/hda4 reiserfs rw 0 0
    
    # df
    Filesystem           1k-blocks      Used Available Use% Mounted on
    rootfs                   69973     58519      7841  88% /
    /dev/root                69973     58519      7841  88% /
    /dev/ram0                 1003       116       836  12% /mnt/ram0
    /dev/hda3             50403028  23557024  26846004  47% /mnt/hda3
    /dev/hda4            104443400     32840 104410560   0% /mnt/hda4
    

ReiserFS上にdebian26を構築 Edit

  • 基本的には…
    基本的には、「debian26のインストール」の手順通りにインストールを行えば、
    /mnt/hda4上にdebian26環境を構築できます。

    本節では、/dev/hda3上で動作させていたdebian26環境を/dev/hda4上のReiserFS上に移行する方法を記します。

  • Kernelの更新
    ReiserFSを組み込んだカーネル(レビジョンlandisk.0.4 以降のカーネル)を使用する必要があります。
    debian26環境を立ち上げて、apt-getすればOKです。
    ※ ReiserFS対応カーネル(landisk.0.4)を含むbase26-sh4-20050601.tgz を使用しても可!
    landisk:~# apt-get update
    landisk:~# apt-get install kernel-image-2.6.11-sh reiserfsprogs
    
  • あとは、
    • 再起動後、
      LANDISKオリジナル環境上で、/mnt/hda3上のdebian26を/mnt/hda4へコピー。
      (cp -a を使う。)
      なお、share は、リンクした。
      # cp -a 省略  /mnt/hda4
      # mkdir /mnt/hda4/mnt/hda3
      # ln -s /mnt/hda3/share /mnt/hda4/share
      
      # ls -la /mnt/hda4
      total 54
      drwxr-xr-x  21 root     root          504 Jun  2 23:41 .
      drwxr-xr-x   7 root     root         1024 May 31 21:20 ..
      drwxr-xr-x   2 root     root         1976 Jun  1 15:53 bin
      drwxr-xr-x   2 root     root          192 Jun  1 16:23 boot
      drwxr-xr-x   6 root     root        34832 Jun  2 01:17 dev
      drwxr-xr-x  38 root     root         2624 Jun  2 01:17 etc
      drwxrwsr-x   3 root     ftp            72 Jun  1 16:28 home
      drwxr-xr-x   2 root     root           48 Jun  1 15:46 initrd
      drwxr-xr-x   7 root     root         3056 Jun  1 18:20 lib
      drwxr-xr-x   2 root     root           48 Jun  1 15:46 media
      drwxr-xr-x   2 root     root           48 Mar 26 13:09 mnt
      drwxr-xr-x   2 root     root           48 Jun  1 15:46 opt
      drwxr-xr-x   2 root     root           48 Mar 26 13:09 proc
      drwxr-xr-x   2 root     root          240 Jun  1 16:29 root
      drwxr-xr-x   2 root     root         2992 Jun  1 18:20 sbin
      lrwxrwxrwx   1 root     root           15 Jun  1 20:41 share -> /mnt/hda3/share
      drwxr-xr-x   2 root     root           48 Jun  1 15:46 srv
      drwxr-xr-x   2 root     root           48 Apr 22 21:15 sys
      drwxrwxrwt   2 root     root           48 Jun  2 01:06 tmp
      drwxr-xr-x  11 root     root          288 Jun  1 15:46 usr
      drwxr-xr-x  13 root     root          312 Jun  1 15:46 var
      
    • /mnt/hda4/etc/fstab
      を変更して、
      /dev/hda4     /            reiserfs  defaults        0 1
      /dev/hda3     /mnt/hda3    ext2      defaults        0 0
      proc          /proc        proc      defaults        0 0
      /dev/hda2     swap         swap      defaults        0 0
      
  • /mnt/hda3/boot/kernelsw.conf
    を変更して(カーネル本体は、/mnt/hda3/boot下の物を使用する)、
    linear
    boot=/dev/hda
    disk=/dev/hda
    bios=0x80
    timeout=50
    default=linux
    image=/mnt/hda3/boot/vmlinuz-2.6.11-sh
            label=linux
            root=/dev/hda4
            read-only
            offset_address=0x00800000
    append="mem=64M console=ttySC1,9600 root=/dev/hda4 fastboot"
    
    起動すればOKです。
    # cd /mnt/hda3
    # kernelsw.pl boot/kernelsw.conf
    Loading .... done.
    ==============================================
            SH-Linux Kernel Switcher V2.1
    ----------------------------------------------
     image  = /mnt/hda3/boot/vmlinuz-2.6.11-sh (size:1298432,page:318)
     root   = /dev/hda4 (read-only)
     append = "mem=64M console=ttySC1,9600 root=/dev/hda4 fastboot"
     offset_address = 0x00800000
    ----------------------------------------------
     kernel boot parameter details
      0 : 0x1 # read-only root file system
      1 : 0x0 # RAMDISK Flags
      2 : 0x304 # Root device (/dev/hda4)
      3 : 0x1 # Loader type (LILO = 1)
      4 : 0x0 # Initrd start
      5 : 0x0 # Initrd size
      6 : 0x0 # Not defined yet
      7 : 0x0 # Not defined yet
    ==============================================
    #
    # /home/LANDISK/scripts/powerctrl.sh reboot
    

トラブルシューティング Edit

LANDISK-120GBモデル(HDL-120U)では無問題でしたが、 160GBモデル(HDL-160U)では、
次のような問題が発生しました。
うちの160GB品固有の問題なのか、それとも全体的なものなのか不明ですが、
私が行った回避方法を記しておきます。(場当たり的ですが。)

  • ReiserFS上でファイルをmvするとSegmentation faultが発生する
    LANDISK付属カーネル+reiserfsモジュール+LANDISK(160GB)の組み合わせで発生した。
    cp -a とrm で回避した。
    (Kernel 2.6ベースだと本不具合は発生しない。)
  • ブートしない…
    LANDISK(160GB)で発生。パーティションを切り直した後、/dev/hda3上に別途用意してあった
    debian26を起動して、/dev/hda4のReserFS化を行うと、無事にブートした。
    ちなみに不具合時のエラーログはこんな感じ。
    Uncompressing Linux... Ok, booting the kernel.
    Linux version 2.6.11-sh (root@landisk) (gcc version 3.4.4 20050314 
    (prerelease) (Debian 3.4.3-12)) #1 Wed Jun 1 13:11:54 JST 2005
    I-O DATA DEVICE, INC. landisk3 support.
    Built 1 zonelists
    Kernel command line: mem=64M console=ttySC1,9600 root=/dev/hda4 fastboot
    Setting GDB trap vector to 0x80000100
    PID hash table entries: 512 (order: 9, 8192 bytes)
    CPU clock: 266.66MHz
    Bus clock: 133.33MHz
    Module clock: 33.33MHz
    
    …省略…
    
    NET: Registered protocol family 1
    NET: Registered protocol family 17
    eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
    IP-Config: Incomplete network configuration information.
    ReiserFS: hda4: found reiserfs format "3.6" with standard journal
    ReiserFS: hda4: using ordered data mode
    ReiserFS: hda4: journal params: device hda4, size 8192, journal first block
     18, max trans len 1024, max batch 900, max commit age 30, max trans age 30
    ReiserFS: hda4: checking transaction log (hda4)
    ReiserFS: hda4: Using r5 hash to sort names
    VFS: Mounted root (reiserfs filesystem) readonly.
    Freeing unused kernel memory: 80k freed
    /sbin/initKernel panic - not syncing: Attempted to kill init!
     : error while loading shared libraries: /lib/libgcc_s.so.1: invalid ELF header
    だんまり。
    

  • 情報求む
    原因解析をしたく、試してみた方は動作報告/不具合報告をよろしくお願いします。
    (こんな危険なことする人、そんなにいるとも思えないが。。。)

  • >理由は不明ですが ←Calling ioctl() to re-read partition table.Re-read table failed with error 16: Device or resource busy.Reboot your system to ensure the partition table is updated. ちゃんと理由出てるから。/dev/hda2がswapで使われてるから。 -- 名無し? 2005-07-08 (金) 13:16:42
Counter: 4593, today: 1, yesterday: 0

添付ファイル: filereiserfs_tools.tgz 430件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2010-01-04 (月) 23:59:31 (5231d)