重建 reiserfs 分区树,没有剩余可用空间

重建 reiserfs 分区树,没有剩余可用空间
$ dd if=/dev/zero of=qqq bs=1M count=40
$ mkfs.reiserfs -f qqq
ReiserFS is successfully created on qqq.
$ mountlo-0.6 qqq ~/mnt/tmp
$ cat /dev/frandom > ~/mnt/tmp/qqq
cat: write error: No space left on device
$ df ~/mnt/tmp/
Filesystem           1K-blocks      Used Available Use% Mounted on
mountlo#qqq              40952     40952         0 100% /home/vi/mnt/tmp
$ killall mountlo-0.6

$ reiserfsck --rebuild-tree qqq
####### Pass 1 #######
Looking for allocable blocks .. finished
0%....20%....40%....60%.Not enough allocable blocks, checking bitmap...there are 1 allocable blocks, btw

out of disk space
Aborted

现在如何恢复文件系统?为了重建树,我需要扩大分区。为了扩大分区,我需要清理分区。为了清理分区,我需要使用 reiserfsck;最后,reiserfsck 提供重建树的功能。

如何将树重建到其他设备(或者只是将所有数据保存到另一个分区)?

答案1

您需要更多空间来处理。对于 qqq 文件,您可以使用 dd 向其添加内容。一旦您有了更多可用空间,请重建文件系统的超级块,这将检测文件系统的块计数是否错误。写入新的超级块后,您可以重建树。假设您的文件仍未挂载:

$ dd if=/dev/zero bs=1M count=10 >> qqq
$ reiserfsck --rebuild-sb qqq
# ... snip
Did you use resizer(y/n)[n]: n
rebuild-sb: wrong block count occured (10240), fixed (12800)
rebuild-sb: wrong tree height occured (65535), zeroed
Reiserfs super block in block 16 on 0x0 of format 3.6 with standard journal
Count of blocks on the device: 12800
# ... snip
Fs state field: 0xfa03:
    FATAL corruptions exist.
     some corruptions exist.
sb_version: 2
inode generation number: 7
UUID: 04993a54-22cc-4bb3-a367-53986e94a6e0
LABEL:
Set flags in SB:
    ATTRIBUTES CLEAN
Is this ok ? (y/n)[n]: y
The fs may still be unconsistent. Run reiserfsck --check.

$ reiserfsck --rebuild-tree qqq
# ... snip
Pass 0:
####### Pass 0 #######
Loading on-disk bitmap .. ok, 12800 blocks marked used
Skipping 8211 blocks (super block, journal, bitmaps) 4589 blocks will be read
0%....20%....40%....60%....80%....100%                        left 0, 4589 /sec
2 directory entries were hashed with "r5" hash.
    "r5" hash is selected
Flushing..finished
    Read blocks (but not data blocks) 4589
            Leaves among those 3
            Objectids found 4

Pass 1 (will try to insert 3 leaves):
####### Pass 1 #######
Looking for allocable blocks .. finished
0%....20%....40%....60%....80%....100%                           left 0, 0 /sec
Flushing..finished
    3 leaves read
            3 inserted
####### Pass 2 #######
Flushing..finished
Pass 3 (semantic):
####### Pass 3 #########
Flushing..finished
    Files found: 1
    Directories found: 3
Pass 3a (looking for lost dir/files):
####### Pass 3a (lost+found pass) #########
Looking for lost directories:
Flushing..finishede 3, 0 /sec 
Pass 4 - finished       done 3, 0 /sec
Flushing..finished
Syncing..finished
###########
reiserfsck finished at Thu Sep  4 13:02:07 2014
###########
$ 

我在旧的 RedHat EL4(修改过的内核以支持 reiserfs)系统上对此进行了测试,最终结果是 qqq 文件可挂载并显示可用空间。

$ sudo mount -o loop -t reiserfs qqq mnt
$ df -h
# ... snip
/home/areid/qqq        50M   40M   10M  81% /home/areid/mnt

相关内容