# Desfragment the gentoo partition...

## FBorges22

Greetings

Is there any way to defragment the Gentoo partition? I cannot find any equivalent "defrag" utility for Gentoo...

This utility exists in Gentoo Linux??

Thank you,

FBorges22

----------

## SiberianSniper

Due to the nature of most *nix filesystems, defrag generally isn't needed.  However, sometimes when files in the same directory get further and further apart on the disk after multiple rewrites, this can slow disk access (ex, during emerge --sync).  You may find https://forums.gentoo.org/viewtopic-t-463204.html to be useful, if anything.

----------

## FBorges22

I also heard that "fsck" utility can reduce the disk fragmentation... Is that really true?

----------

## padoor

i have seen fsck only reports percentage fragmentation.

i have got same replies as defrag is not needed from various linux forums.

currently i have 3.5 % fragmentation in my gentoo installation which is only 3 months old in my laptop.

also i have noticed is it has not gone more than 3.5% in 1 year old gentoo in my desktop.

probably defrag is not that seriously required.

 :Smile: 

----------

## FBorges22

My Gentoo is half-year old and is 2.5% fragmented... 

But this number will increase soon for those who do the emerge --sync frequently...

----------

## padoor

i do emerge --sync and emerge -Du world almost every week .

and also do fsck   by running shutdown -F now  once in a while.

i did not find significant increase in fragmentation.from 3.5%

i use ext3 single / partition and a common data vfat partition for gentoo and windows and pclinuxos  --mounted as /pubdata in both.

----------

## mudrii

makefs  portge on separate partition and fragmentation with emerge --synk will be gone

----------

## FBorges22

Have anyone of here tried the "shake" utility mentioned previously?

----------

## SiberianSniper

I've used shake, and it seemed to help a little.  However, a simpler option might be to force a rewrite by tarballing a directory, deleting it, and untarring it again.  Similarly, if portage is really slow, you can just rm -rf /usr/portage and reinstall it from the latest snapshot.

----------

## jlh

As long as your disk isn't almost full, you shouldn't worry about fragmentation.

To fix fragmentation of the portage tree I have it loop-mounted on a 300MB file using a 1K-blocks filesystem (and lots of inodes).  That makes the entire tree to not spread everywhere on the disk even with frequent updates.  (Plus it's a lot more efficient because there's significantly less wasted space that has to be read due to smaller block size.)  Definitely worth trying.

----------

## jsf_x35a

During the 5 years I've been using reiserfs I've only needed to defrag it once. And that was because I was being stupid and decided to copy my 80GB of music on my external to my 60GB internal HDD.  :Razz:   Usually, *nix filesystems don't really begin to fragment unless they're around 90% full. But if you ever come to that point, I suggest using Con Kolivas's defrag script. It's really a braindead defragger that just physically moves the files around so it pretty much works on any fs. It's a shell script that's really easy to understand and works great if your fragmentation is above 10% (which is when you should even consider worrying about fragmentation).

----------

