- Notifications
You must be signed in to change notification settings - Fork0
Offline defragmentation utility for reiserfs (v3.6)
License
FS-make-simple/reiserfs-defrag
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
reiserfs-defrag
is a software that will rearrange data on yourreiserfspartition to make it less fragmented.Offline. You must unmount fs first.
Still considered experimental, although it will do its best to protect data fromcorruption. I do run consistency check often in the development process, butobviously that can't guarantee anything. Do not use it on sensitive data,or backup them at least.
As for now (v0.2.1) it journals meta-data while moving blocks and runs some consistencychecks on metadata. That should prevent data loss even for partially damaged filesystem.Anyway, running fsck before defragmentation is a good idea.
There are two available algorithms:tree-through defragmentation andincremental one.First packs (with no spaces between) all files in a tree order, interleaving data blockswith leaf and internal tree nodes. That will move almost all data blocks, and thereforewill be very slow. But in the end you'll find all files (and directories) in theirideal order and free space consolidated at the end of the filesystem.
Second one calledincremental and selected by default. It makes several passes throughfilesystem's internal tree and tries to defragment all that it considers fragmented.Currently it check for every 2048-block length chuck to be in one piece. Those 2048 blockscontains not only data blocks but metadata blocks too. As a result, file can be splittedto several parts which will be distributed through the partition. That's not user usuallywants to see, but this is current limitation. 8 MiB chucks are large enough. If youhave a 15 ms, 100 MiB/sec disk, every seek takes same time as reading 1.5 MiB, so it'sabout 16% performance penalty. That is acceptable in multitask environment.
You can start reading about ithere.In a couple of words, sometimes fragmentation of filesystem can decrease its performance.
There is one issue about reiserfs specifically. Due to internal structure, eventhe only file on fs will be cut into fragments of size about four megabytes. Datainterleaved with so-called indirect blocks, used by filesystem to map inodeto actual partition blocks. One such block is 4 kiB length so it doesn't introducehard-drive head movement and therefore have almost no impact on read speedperformance. But fragmentation measurements tools, such asfilefrag
frome2fsprogs
and based on it, report file as heavily fragmented although it is not.
Many years I've heard opinions that none of Linux filesystems need defragmentation andone should forget about it. That's not entirely true. Well, design of filesystem spaceallocation prevents fragmentation, but can not eliminate it completely. As you write,update, delete files, filesystem ages and performs worse.
For many years the only solution available was to back up data, recreate filesystem, andcopy data back. I want an alternative, in-place defragmentation.
I declare goals as:
- (g1) program should try its best to prevent data loss;
- (g2) program should use bounded amount of memory no matter of fs size;
- (g3) program working time should no worse than linearly depend of fs size (O(n log n) fine too);
- (g4) program should be able to do incremental (fast) defragmentation;
- (g5) program should be able to move selected files to beginning of partition.
Goals g1 through g5 are now (v0.2.1) considered done.
(You'll need cmake.) To build:
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
Note two dots in cmake parameters. They are point to directory with sourcesand those dots are required.
To install, run as root:
make install
That will placereiserfs-defrag
binary to ${PREFIX}/sbin. It expects path to device orfilesystem image. There are some other options available, see usage (--help) for details.
This piece of software distributed under terms of GPLv3, see COPYING.GPLv3 for full text.
Rinat Ibragimov, ibragimovrinat-at-mail.ru,https://github.com/i-rinat/
About
Offline defragmentation utility for reiserfs (v3.6)
Topics
Resources
License
Stars
Watchers
Forks
Packages0
Languages
- C++98.9%
- Other1.1%