HomeHome  PortalPortal  FAQFAQ  SearchSearch  RegisterRegister  Log in  
openFATE - openSUSE feature tracking
Similar topics
Latest topics
» Difference between 42.2 and 42.1
by findoctr Thu Dec 15, 2016 7:53 pm

» openSUSE Leap 42.1 ?
by findoctr Fri Feb 05, 2016 8:09 pm

» Happy Turkey Day
by findoctr Thu Nov 26, 2015 1:45 pm

» Happy 4th of July!
by bozo Sat Jul 04, 2015 12:56 pm

» It's been a while ...
by bozo Mon Feb 23, 2015 8:34 pm

» Mondo chillers
by bozo Wed Feb 18, 2015 5:11 am

IRC Channel
You can also find us on IRC's freenode.net as #suseunbound.

Share | 

 How To: Defrag Hard Disk

Go down 
Old Regular

Posts : 81
Join date : 2010-08-12
Age : 57
Location : ... my home is... here

PostSubject: How To: Defrag Hard Disk   Wed Jun 29, 2011 11:45 am

Don't Take The Following as a Real Expert HOWTO, because I'm no expert UNLESS ENDORSED BY MORE EXPERIENCED USERS HERE

Well... I was thinking... and you know the answer mostlly out there, you don't need to defrag in linux a journalled system, and there doen't exist a real defrag tool for linux.

But according to my humble understanding:
1- Yes Linux does not defragment files,ie: a file is always contiguous
2- A little defragmentation might happen especially when your hard disks gets almost full and after a long period of time.

So, generaly defragmentation is not required.

BUT, still you can get yor contiguous files scattered everywhere across your hard disk, and lots of blank spaces between files if you frequently download /delete files.

So I thought of something I assume will ... ahem... "defrag" your files in the home directory,or whatever by simply doing the following:
1- Copy or move the home directory (or whatever you need to defrag) to another directory / partition / external hard disk... ie somwhere else
2- delete the original folder with all the files on it (eg. home folder... make it blank).
3- restore them back to where you want.

I assume retrieving the files will cause them to be written just next to each other from the begining of the disk without blanks in between,

I assume this will reduce the time needed to access the files as the head won't need to be going from that part to that part on the disk... this will - I think - reduce the need of mechanical movements by the head and the hard disk spinnig to access contiguos files scattered everywhere.

Would this really defrag the user data files?

Please enlighten me.

Am I right?
Back to top Go down

Posts : 402
Join date : 2010-02-23
Location : Way out in the sticks in the Gold Country of California

PostSubject: Re: How To: Defrag Hard Disk   Thu Jun 30, 2011 3:11 pm

I'm no expert either, so this may be a "blind leading the blind" type discussion.

My understanding is, as you've stated, individual files do not become fragmented under Linux. I don't know about related files, but it makes sense that they would not necessarily be adjacent on the disk. So it might be that after a long period of time, especially on a large hard drive, related files could be scattered all over the drive. But as many of those files could be shared libraries, there's no way to have them adjacent to where they are needed for all applications. And with the way Linux works, with different partitions and directories, i.e. an executable in /user, configuration files in /home/user and other places, shared libraries in yet another directory possibly on a separate partition, there's no way to make all the files adjacent.

So while it's possible that in a given situation, a reordering of files on the disk as you've suggested might speed things up a little, I think in general, it's probably not worth the time and effort.

I look forward to hearing from a real expert on this.


"The trouble with quotes on the internet is that you never know if they are genuine." - Abraham Lincoln
Back to top Go down
Old Regular

Posts : 81
Join date : 2010-08-12
Age : 57
Location : ... my home is... here

PostSubject: Re: How To: Defrag Hard Disk   Thu Jun 30, 2011 4:27 pm

Hi Bozo,

My post is about defraging user files mainly in home folder. Yes, as you say there is no way to keep files that are needed to be adjacent next to each other (maybe copying them manually one by one in the required order would do),
But it's all about making all data files at one end together to spead it up a little and reduce slightly access time.

It it's just simple defrag
Back to top Go down
Old Regular

Posts : 41
Join date : 2010-02-25

PostSubject: Re: How To: Defrag Hard Disk   Fri Jul 01, 2011 4:37 am

Yes in theory it will defrag but my understanding is this way is not the way to go ext4 has the ability to do this. (Think e2fsprogs whether suse is compiled with it or you'll have to custom compile I don't know)

I think there will be minimal advantage to any defrag you can tell when you fsck. You will have to take the drive offline to do this but don't think I've ever really seen much more than 7% fragmentation.

If you are seeing a high level of fragmentation I would suspect >10% free space and do a like for copy may well only relieve the situation for a little while. Whilst a copy to a bigger drive or better management of partitioning would probably see a greater improvement.

Note not an expert and have yet to convert to ext4....
Back to top Go down
Old Regular

Posts : 81
Join date : 2010-08-12
Age : 57
Location : ... my home is... here

PostSubject: Re: How To: Defrag Hard Disk   Fri Jul 01, 2011 9:30 am

Hi FeatherMonkey,
How are you doing? It's been so long... hope you can get active more and more.. at least me miss your experience...
And yes, you are right of course, linux does not really need to defrag, but I was just thinking - as I tend to seek perfection - in a simple way to improve files locations "a little" as linux defrags "a little" as well.

So, because it is not a big problem, the solution as well does not do much, but it may help a little especially with music files put in a playlist, DVD movie (containing lots of small files), this might make it easier on the machine especially if it is a laptop running on batteries, it wil reduce mechanical movements a little, and may save a noticeable ammount of battery.

But glad you share my point of view to some extent. Of course I was not talking about defraging system files, I won't take that risk! What a Face

p.s: would you give me opinion on http://suseunbound.canadaboard.net/t141p30-ways-you-waste-your-time#1455
Maybe we all need such things.
Back to top Go down

Posts : 25
Join date : 2010-02-25
Age : 73
Location : Netherlands

PostSubject: Re: How To: Defrag Hard Disk   Sat Jul 02, 2011 3:59 am

I did not read all of the above. But one thing is sure. When you decide to reorganize something you call a "hard disk" in your title for whatever reason, this means that you have to reorganize a file system. It means that it is of no use to do something on directory level (somewhere above I read about doing something to a person's home directory), except when that directory is on a seperate file system (and thus partition or whole disk).

When you offload and restore the files/directories inside a directory you will create them anew on the same almost full file system and thus everything will be fragmented iinto the holes available. most definitely different then it was, but in the same way.
Back to top Go down
Old Regular

Posts : 18
Join date : 2010-02-25
Age : 35
Location : Gloucester

PostSubject: Re: How To: Defrag Hard Disk   Wed Oct 26, 2011 3:24 pm

This discussion is almost pointless to be honest. Because of a few things. Firstly, as noted, Linux file systems are fragmentation resistant. Therefore, they are designed to place files - for the most part - contiguously and i don't think i need to explain that.

Secondly, file performance benefits for small files like mp3 files or DVDs (aren't most of the files on a DVD several hundred MiB's in size?) are not noticeable due to the fact that any Linux file system looks to find free spaces on the drive to fill in an ordered manner. Thus they only place files in noncontiguous blocks when the host partition becomes less than 10% (not sure on the number but it's low) full and there are no free contiguous blocks large enough to fit the file exist.

Finally, due to things like NCQ and hard drive command buffering, the drive and the operating system are working together to achieve the best performance possible for the drive. This is more noticeable with kernels newer than 2.6.38 where work has been done to accommodate internal drive buffers and command sequencing technique's like NCQ better.

The best thing you can do to optimise a Linux file system isn't to defragment it but to optimise how it uses the drive and the file systems extended features like journaling. This can be done by optimising the driver and the file system itself using the appropriate tools.
Back to top Go down
Sponsored content

PostSubject: Re: How To: Defrag Hard Disk   

Back to top Go down
How To: Defrag Hard Disk
Back to top 
Page 1 of 1
 Similar topics
» Temporary FireFox Profile using Selenium WebDriver
» Insert Status Disk and Click OK

Permissions in this forum:You cannot reply to topics in this forum
SUSEUnbound :: Extended Documents and How-tos :: How-tos-
Jump to: