Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
$ 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

How to recover the filesystem now? In order to rebuild tree I need to enlarge the partition. In order to enlarge partition I need to make it clean. In order to make clean I need to use reiserfsck; and finally reiserfsck offers rebuilding the tree.

How to rebuild tree to other device (or just save all the data to another partition)?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You need some more space to work with. In the case of your qqq file you can append to it with dd. Once you have some more free space to work with rebuild the superblock of the filesystem which will detect the block count of the filesystem is wrong. With the new superblock written you can rebuild the tree. Assuming your file is still unmounted:

$ 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
###########
$ 

I tested this on an old RedHat EL4 (modded kernel to support reiserfs) system and the end result was that the qqq file was mountable and showed the free space.

$ sudo mount -o loop -t reiserfs qqq mnt
$ df -h
# ... snip
/home/areid/qqq        50M   40M   10M  81% /home/areid/mnt
share|improve this answer
    
So --rebuild-sb/--rebuld-tree can also grow filesystems? –  Vi. Sep 4 '14 at 14:08
    
It seems to be the only way to grow it after a failed --rebuild-tree. resize_reiserfs checks that the filesystem is clean and won't go forward when the rebuild tree failed. –  epicDistortion Sep 4 '14 at 16:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.