LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 04-29-2007, 09:40 AM   #1
GothManiac
Member
 
Registered: Mar 2007
Posts: 45

Rep: Reputation: 15
Defrag


Is there anyway to defrag Linux? I'm using Suse 10.1. I've heard there is no need to but my hard drive is really thrashing around and it's causing preformance issues.
 
Old 04-29-2007, 10:30 AM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
First, do an fsck (make sure it’s mounted read-only or not mounted at all) on your drive to see the number of non-contiguous blocks.
 
Old 04-30-2007, 04:46 PM   #3
GothManiac
Member
 
Registered: Mar 2007
Posts: 45

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by osor
First, do an fsck (make sure it’s mounted read-only or not mounted at all) on your drive to see the number of non-contiguous blocks.
Not a Linux pro, can you explain to me out to mount a partition as read only?
 
Old 04-30-2007, 05:54 PM   #4
Okie
Senior Member
 
Registered: Mar 2002
Location: Oklahoma
Posts: 1,154

Rep: Reputation: 187Reputation: 187
actually Linux filesystems do not need to be "Defragged" that is just a tool to compensate for a weakness in MS-Windows filesystems...
 
Old 04-30-2007, 05:56 PM   #5
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
"I've heard there is no need to but my hard drive is really thrashing around and it's causing preformance issues."

Are you accessing a FAT/FAT32 filesystem? Are you sure it's not a problem with swapping?
 
Old 04-30-2007, 07:08 PM   #6
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
I too think this is something other than a fragmentation problem (we’re assuming this is ext2 or ext3, right?), but there’s no need not to look and see…
Quote:
Originally Posted by GothManiac
Not a Linux pro, can you explain to me out to mount a partition as read only?
The easiest (and safest) way to do this would actually be from a livecd (where you don’t need the filesystem mounted at all). From, e.g., knoppix, go to a root terminal make sure your host’s normal filesystems (e.g., /dev/hda1, etc.) are not mounted. Then, type in “e2fsck -nf /dev/hda1” (replace hda1 with one of your partitions). Repeat for all the partitions you use. At the end of the report, it gives you something that looks like this (taken from one of my boxen):
Code:
/dev/hda7: 117579/2101152 files (0.4% non-contiguous), 642971/4194965 blocks
The part I emboldened tells you how much “fragmentation” exists. I would wager this is small and you are having problems for some other reason.

P.S., the instructions will be slightly different to determine fragmentation if you are using jfs, xfs, reiserfs, etc.
 
Old 05-01-2007, 10:41 PM   #7
GothManiac
Member
 
Registered: Mar 2007
Posts: 45

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by osor
I too think this is something other than a fragmentation problem (we’re assuming this is ext2 or ext3, right?), but there’s no need not to look and see…
The easiest (and safest) way to do this would actually be from a livecd (where you don’t need the filesystem mounted at all). From, e.g., knoppix, go to a root terminal make sure your host’s normal filesystems (e.g., /dev/hda1, etc.) are not mounted. Then, type in “e2fsck -nf /dev/hda1” (replace hda1 with one of your partitions). Repeat for all the partitions you use. At the end of the report, it gives you something that looks like this (taken from one of my boxen):
Code:
/dev/hda7: 117579/2101152 files (0.4% non-contiguous), 642971/4194965 blocks
The part I emboldened tells you how much “fragmentation” exists. I would wager this is small and you are having problems for some other reason.

P.S., the instructions will be slightly different to determine fragmentation if you are using jfs, xfs, reiserfs, etc.

Yeah, that was my next question I'm using xfs. Is it just xfs instead of ef2s?
 
Old 05-02-2007, 11:03 AM   #8
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by GothManiac
Yeah, that was my next question I'm using xfs. Is it just xfs instead of ef2s?
XFS filesystems have a special tool called for “filesystem reorganizer” or “xfs_fsr” to do “defragmentation” (see man 8 xfs_fsr).

P.S., it would have made this thread a lot shorter, if you said what filesystem you were using in the first place.
 
Old 05-03-2007, 11:24 PM   #9
GothManiac
Member
 
Registered: Mar 2007
Posts: 45

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by osor
XFS filesystems have a special tool called for “filesystem reorganizer” or “xfs_fsr” to do “defragmentation” (see man 8 xfs_fsr).

P.S., it would have made this thread a lot shorter, if you said what filesystem you were using in the first place.
Sorry, didn't even think of file system type until it was mentioned.
Can't find any reference to xfs_fsr in man or man 8.
Updated man and still nothing.
Updated xfs and that got it. I'll give that a try.
It looks like by reading the man page, that xfs runs on mounted directories.

Tried it and it looks like it's running.

Thanks for the help.

Last edited by GothManiac; 05-03-2007 at 11:32 PM.
 
Old 05-03-2007, 11:40 PM   #10
GothManiac
Member
 
Registered: Mar 2007
Posts: 45

Original Poster
Rep: Reputation: 15
Originally Posted by osor
I too think this is something other than a fragmentation problem (we’re assuming this is ext2 or ext3, right?), but there’s no need not to look and see…
The easiest (and safest) way to do this would actually be from a livecd (where you don’t need the filesystem mounted at all). From, e.g., knoppix, go to a root terminal make sure your host’s normal filesystems (e.g., /dev/hda1, etc.) are not mounted. Then, type in “e2fsck -nf /dev/hda1” (replace hda1 with one of your partitions). Repeat for all the partitions you use. At the end of the report, it gives you something that looks like this (taken from one of my boxen):
Code:

/dev/hda7: 117579/2101152 files (0.4% non-contiguous), 642971/4194965 blocks

The part I emboldened tells you how much “fragmentation” exists. I would wager this is small and you are having problems for some other reason.

P.S., the instructions will be slightly different to determine fragmentation if you are using jfs, xfs, reiserfs, etc.

Actually, my home dir is horribly fragged. one file had 28083 extents prior to defrag and 6 after. Guess I should do some maintenance once in a while!
 
Old 05-04-2007, 12:00 AM   #11
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
Quote:
Actually, my home dir is horribly fragged. one file had 28083 extents prior to defrag and 6 after. Guess I should do some maintenance once in a while!
But did it fix your problem?
 
Old 05-04-2007, 11:09 PM   #12
GothManiac
Member
 
Registered: Mar 2007
Posts: 45

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Quakeboy02
But did it fix your problem?
Yup, sure did!

Thanks for the help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Defrag? sleekmason Linux - Software 6 04-06-2006 06:44 PM
Is it necessary to defrag? simsjr Linux - Newbie 7 04-27-2004 02:33 AM
How to defrag arsham Linux - General 2 04-01-2004 12:05 AM
Defrag dunmarie Linux - General 4 10-27-2003 02:42 AM
defrag??? ETeria Linux - Newbie 3 08-24-2003 05:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 10:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration