PCLinuxOS-Forums
News: ...FLASH!!! ...New PCLinuxOS Testing board now open. Register today! Be an active contributor to the PCLinuxOS future! ... Read all about it now, on THIS forum!!!..
 
*
Welcome, Guest. Please login or register. May 27, 2012, 04:51:52 PM


Login with username, password and session length


Pages: [1] 2   Go Down
  Print  
Author Topic: Defragmentation in Linux ?  (Read 1061 times)
Abraxas
Hero Member
*****
Online Online

Posts: 837


PCLinuxOS - Heck Yeah !


« on: September 10, 2011, 01:11:03 PM »

I'm pretty sure PCLinuxOS (Linux, in general) does not need defragmenting. I feel I've read somewhere this is the case. I no longer use any form of Windows, I do use External Hard Drives however, which I feel could benefit from being defragmented. I may be wrong.  Wink

Back when I was in the Windows world people often bickered that Defragging was a waste of time. In fact they bickered about heaps of things. We all make judgements according to our experiences.
I found Defragging useful, the Hard drive seemed to run better, so I did it.
Before installing a PCLinuxOS Distro as Dual Boot with Windows I would Defrag the Hard Drive maybe three times to ensure no stray Win System files were overwritten.
I run USB flash drives with movies on them on my T.V.
I used to defrag them as sometimes they would seize up, which could be a problem with the Flash Drive, but often it fixed the problem.
1.) Is there a Linux defragmentation program ?
2.) How come Linux runs so well without defragmenting, or have I got this wrong ?
Thanks,

francis
Logged

PCLinuxOS KDE 4.6.5 MiniMe -- Taking Control each day - taking some deep breathes too...
I'm GMT+10 hours !
The Chief
Hero Member
*****
Offline Offline

Posts: 1582



« Reply #1 on: September 10, 2011, 01:18:12 PM »

It's not so much Linux as the file systems in use. 

Linux is typically ext3 or 4 (or related) file systems, which are designed not to get fragmented.  If you install and run Linux on an disk formatted for Fat32 or NTFS (entirely possible), it will have very nearly the same fragmentation problems Windows has. 

On the the other hand, if it was possible to install Windows on an ext3 or 4 file system (AFAIK it isn't), it's fragmentation problems would pretty much go away.

Defragger for Linux?  Maybe, but I don't remember hearing of one.
Logged


Retired Senior Chief, Retired Software Engineer, Active GrandPa
T6
Super Villain
******
Online Online

Posts: 17005


i can rest now :D


« Reply #2 on: September 10, 2011, 01:29:48 PM »

"If you install and run Linux on an disk formatted for Fat32 or NTFS"

afik, this can't be done or install windows on ext4

i remember other posts asking this question, someone mentioned that ext4 does get fragmented but this doesn't impact the performance of the os, or at least it never did on pclinux 2007, the almost 3 years i used it with ext3

or pclinux 2010, almost two years using it now with ext4

the files tend to be written on a more ordered way in the hard disk, it is more a be ordered thing that linux does better

if you take time of the boot process now and in two years, the boot process might be the same or smaller, each new kernel tends to improve everything

a usb flash device does get fragmented, to avid fragmentation all you have to do is copy files to a hard disk, format the drive and copy the files back, it is a simple way to defrag those drives
Logged

"It pays to keep an open mind, but not so open your brains fall out."

Carl Sagan
Bald Brick
PCLinuxOS Tester
Hero Member
*******
Offline Offline

Posts: 5150


I'm going South


« Reply #3 on: September 10, 2011, 02:53:44 PM »

francis,

There are defraggers for Linux. A couple of years ago there were links to several of them in a post on this very forum. I can't find that post anymore, but Google might be of assistance here. (Note that normally you can't defrag a Linux partition that is currently in use: you have to run the defragger from a live CD or from an install on another partition.)

On the other hand, there's usually no need to defrag a Linux filesystem until a partition gets very full. On a Windows filesystem files are stacked like containers on a cargo ship without any space between them. On a Linux filesystem you start out with quite a lot of space between the files. So when you replace a file in Windows with a just slightly larger version the file is immediately fragmented: the original slot is too small. In Linux the original slot is usually large enough because of the extra space before and after it. So: no fragmentation before the partition really starts to fill up.

If you save movies on a Windows formatted partition they will stack up very neatly. But if you delete some of the movies and replace them with something else you should defrag the partition even if you are running Linux. Or, preferably, do what T6 recommended: "copy files to a hard disk, format the drive and copy the files back".


Logged

If it ain't broke
hit harder!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D
MtnMan
Sr. Member
****
Offline Offline

Posts: 257

Aged to perfection


« Reply #4 on: September 11, 2011, 06:46:00 AM »

On the other hand, there's usually no need to defrag a Linux filesystem until a partition gets very full. On a Windows filesystem files are stacked like containers on a cargo ship without any space between them. On a Linux filesystem you start out with quite a lot of space between the files. So when you replace a file in Windows with a just slightly larger version the file is immediately fragmented: the original slot is too small. In Linux the original slot is usually large enough because of the extra space before and after it. So: no fragmentation before the partition really starts to fill up.

I like that explanation.  I may be wrong but I think that AHCI Sata drives have Native Command Queuing supported in the Linux kernel which would lessen any effects of fragmentation if it existed.  Since this concept is a carry-over from windows (like anti-virus) I thought this was an interesting read from a windows perspective.

http://winhlp.com/node/82
Logged

I worry that the person who thought up Muzak may be thinking up something else. - Lily Tomlin
Bald Brick
PCLinuxOS Tester
Hero Member
*******
Offline Offline

Posts: 5150


I'm going South


« Reply #5 on: September 11, 2011, 07:57:43 AM »

I did some googling anf found these links.

The first one gives an explanation very similar to what I wrote in my first post. It's five years old so I don't know how relevant it is today. But here it is: http://geekblog.oneandoneis2.org/index.php/2006/08/17/why_doesn_t_linux_need_defragmenting.

The second one is a link to a defragger: http://vleu.net/shake/.

The third one is a link to a defragging script by Con Kolivas: http://ck.kolivas.org/apps/defrag/defrag-0.08/defrag.

Also, do a search for the ext4 defragger e4defrag.
Logged

If it ain't broke
hit harder!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D
T6
Super Villain
******
Online Online

Posts: 17005


i can rest now :D


« Reply #6 on: September 11, 2011, 08:53:38 AM »

ahci, i had to disable everything about it on my netbook so i could install pclinux on it
Logged

"It pays to keep an open mind, but not so open your brains fall out."

Carl Sagan
AS
Global Moderator
Hero Member
*****
Offline Offline

Posts: 4139

Have a nice ... night!


« Reply #7 on: September 11, 2011, 09:27:00 AM »

ahci, i had to disable everything about it on my netbook so i could install pclinux on it

when ? I mean few time ago or several years ago ?
Logged
Abraxas
Hero Member
*****
Online Online

Posts: 837


PCLinuxOS - Heck Yeah !


« Reply #8 on: September 11, 2011, 10:00:56 AM »

Hey thanks The Chief, T6, and Bald Brick ! Some very interesting info.
It's no big deal, just something I'd been wondering about for ages.
I run FS ext4, I think it's default filesystem in Linux these days, not an expert.
Did a complete wipe of the Hard Drive and got rid of Windows back in July,and installed PCLinuxOS 2011.06 'MiniMe' .
I found after dual booting into WinXP after using PCLinuxOS for a few days was quite depressing. Slow,... Double clicking, updating AV software, security updates, and on and on, so after making a huge 'BooBoo' one day ( It's a long story  Wink ) Mr. O-P was kind enough to help me set up the Partitions, etc.

Quote
If you save movies on a Windows formatted partition they will stack up very neatly. But if you delete some of the movies and replace them with something else you should defrag the partition even if you are running Linux. Or, preferably, do what T6 recommended: "copy files to a hard disk, format the drive and copy the files back".
Interesting with Flash drives, I'd tried that once. Copying all files to a directory, formatting the thing, then copying the files back.
Just today was using Bleachbit, or mainly getting familiar with it, and thought it couldn't hurt to use it to erase the files on a USB Flash drive, as a way of Formatting it. Seems to have worked. I had watched the .Avi files I had on it, and had originals backed up. As I said I pop  flash drives into my T.V., if the files are fragmented it isn't much fun. Very rare these days to have any problems though.
Again thankyou for your feedback, just about no maintenance to do except have fun  Cheesy
It has however been a steep learning curve over three years to get to were I'm at, which is still a 'newby'.

Logged

PCLinuxOS KDE 4.6.5 MiniMe -- Taking Control each day - taking some deep breathes too...
I'm GMT+10 hours !
T6
Super Villain
******
Online Online

Posts: 17005


i can rest now :D


« Reply #9 on: September 11, 2011, 10:21:28 AM »

ahci, i had to disable everything about it on my netbook so i could install pclinux on it

when ? I mean few time ago or several years ago ?

september last year
Logged

"It pays to keep an open mind, but not so open your brains fall out."

Carl Sagan
AS
Global Moderator
Hero Member
*****
Offline Offline

Posts: 4139

Have a nice ... night!


« Reply #10 on: September 11, 2011, 10:40:28 AM »

ahci, i had to disable everything about it on my netbook so i could install pclinux on it

when ? I mean few time ago or several years ago ?

september last year

you could try to change it temporarily, boot a recent kernel/liveCD, and watch at dmesg for some hints ... it seem strange to me that AHCI could actually be an issue ...
Logged
Vortеx
Hero Member
*****
Offline Offline

Posts: 2010


Vorteks without the Secretary


« Reply #11 on: September 11, 2011, 10:46:13 AM »

Or, preferably, do what T6 recommended: "copy files to a hard disk, format the drive and copy the files back".
Just deleting all files isn't enough?
Logged
T6
Super Villain
******
Online Online

Posts: 17005


i can rest now :D


« Reply #12 on: September 11, 2011, 11:01:53 AM »

"Just deleting all files isn't enough?"

yes, it should be enough but i have to "fix" partitions and formats made by windows machines so many times that i just do the whole thing, two birds one stone comes to mind

"you could try to change it temporarily, boot a recent kernel/liveCD, and watch at dmesg for some hints ... it seem strange to me that AHCI could actually be an issue"

if i do that, xp could have problems to boot and pclinux is doing fine, that ntbook is dualbooting and that particular change doesn't offer much to me but if i enable it, linux can't see the hard disk immediately
Logged

"It pays to keep an open mind, but not so open your brains fall out."

Carl Sagan
MtnMan
Sr. Member
****
Offline Offline

Posts: 257

Aged to perfection


« Reply #13 on: September 11, 2011, 01:03:31 PM »

Quote
if i do that, xp could have problems to boot and pclinux is doing fine

If the correct driver is not installed or slip streamed when xp is installed it will not boot.  I have installed the driver post xp install but it is complicated and as you indicated maybe not worth the effort.   

Quote
but if i enable it, linux can't see the hard disk immediately

There is a boot delay for BIOS to set up AHCI but I have never had a problem with any Linux install and that delay has nothing to do with Linux - at least on my computer.
Logged

I worry that the person who thought up Muzak may be thinking up something else. - Lily Tomlin
T6
Super Villain
******
Online Online

Posts: 17005


i can rest now :D


« Reply #14 on: September 11, 2011, 02:06:49 PM »

sorry, i must rephrase that, linux installer can't see the hard disk

if i disable ahci linux can see the hard disk

at least that was with 2010.1, haven't tested 2011
Logged

"It pays to keep an open mind, but not so open your brains fall out."

Carl Sagan
Pages: [1] 2   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM