LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-11-2009, 10:54 PM   #1
umwai
Member
 
Registered: May 2008
Location: Sri Lanka
Distribution: Ubuntu
Posts: 57
Blog Entries: 1

Rep: Reputation: 16
Cool How to defragment in linux (Ubuntu)


I wanna know how to defragment my disk partitions in linux (including NTFS) is there a tool for that.
 
Old 03-11-2009, 11:04 PM   #2
ic_torres
Member
 
Registered: Nov 2005
Location: ABAP
Distribution: slackware 12.0, Vector Linux STD 6.0 and 5.8, ZenWalk 4.6.1, OpenBSD 3.9
Posts: 389

Rep: Reputation: 34
Quote:
Originally Posted by umwai View Post
I wanna know how to defragment my disk partitions in linux (including NTFS) is there a tool for that.


try searching in sourceforge.net OR google
 
Old 03-11-2009, 11:10 PM   #3
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,431

Rep: Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471
Don't need it. Because of the way Linux file systems are set up, they don't get fragmented until a drive is almost full. If you just google "why you don't need to defragment linux" you will get 216,000 hits like this one:

http://geekblog.oneandoneis2.org/ind..._defragmenting
 
Old 03-11-2009, 11:32 PM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by yancek View Post
they don't get fragmented until a drive is almost full.
False. They get fragmented (though admittedly not *that much* as in windows). They key point are I/O schedulers, that reorder operations in a smart manner. So the whole point is not the lack of fragmentation, but the smart scheduling of the I/O which prevents all the stress associated typically to fragmented devices making the performance penalty pointless. However this can vary from fs to fs. Reiserfs has known problems with fragmentation, but the rest of the fs's should be fine unless the disk is almost full as you say. Even fat will perform ok on linux, unlike windows xp and previous versions (know nothing about later ones).

Quote:
If you just google "why you don't need to defragment linux" you will get 216,000 hits like this one:
Most of them telling you the wrong argument I assume, like the one you linked. I stumped with that same thread long ago and posted a correction below, signed as "Jesgue" so you can search for that in the thread to see an extended explanation about elevators or i/o schedulers.

Being that said, you usually don't defragment linux. You could always back a partition up, then format it and restore the backup, which is like a poor man's defrag. That's not too appealing, I know. There're some tools around, you can google for them, like in "defrag ext3", "defrag ntfs linux" or whatever fs you need to defrag.

There's also "shake":

http://vleu.net/shake/

Never tried it, don't blame me if it fries all your data and spills ketchup over it.

You could also use ext4 as your filesystem, a defragmenter for ext4 is on the way, and it will also be getting an online defragmenter as well so you don't have to worry about that any more.
 
Old 03-12-2009, 12:18 AM   #5
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
The thought of having to defrag a 1TB drive leaves me cold.
 
Old 03-12-2009, 04:26 AM   #6
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
Originally Posted by ic_torres View Post
try searching in sourceforge.net OR google
Please also note that the answer to this question hasn't changed much in the last couple of weeks and that there are threads on this very forum on the subject. About every couple of weeks. And its getting old.

Thanks
 
Old 03-12-2009, 07:58 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,599
Blog Entries: 4

Rep: Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905
Defragmentation is not a "routine procedure" anymore ... not even for Windows boxes. For one thing, drives are huge, so a contiguous block of space is always easy to come by. Filesystems have improved too. Current Linux (and Windows) filesystems are designed for years of continuous service.
 
Old 03-12-2009, 08:17 AM   #8
akuthia
Member
 
Registered: Oct 2007
Location: triad, nc, usa
Distribution: Ubuntu
Posts: 232

Rep: Reputation: 29
I like sun's answer. whats the point of spending a couple of hours trying to wring a few hundred megs out of a drive (or even a few gigs) when it would honestly be quicker to go to your local electronics retailer, buy a new drive and install. Presto! a significant % reduction in fragmentation.
 
Old 03-12-2009, 08:21 AM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Amen.....

In an era of contracting resources and all manner of issues, it's nice to have "brute force" solutions that are also "green". An extra hard drive for under $100 can solve all manner of problems---eg it is hands-down the most painless way to set up dual-boot.
 
Old 03-12-2009, 10:13 AM   #10
monsm
Member
 
Registered: Feb 2005
Location: London, UK
Distribution: Gentoo
Posts: 568

Rep: Reputation: 37
Quote:
Originally Posted by pixellany View Post
Amen.....

In an era of contracting resources and all manner of issues, it's nice to have "brute force" solutions that are also "green". An extra hard drive for under $100 can solve all manner of problems---eg it is hands-down the most painless way to set up dual-boot.
Completely agree. Just over 80£ here in the UK for 1Tb hd. No more defragging. I remember not long ago you had to pay 1£ pr 1Gb of hd space

Mons
EDIT: Guess the situation might be different in Sri Lanka, but in any case, you won't gain anything much by defragging in Linux.

Last edited by monsm; 03-12-2009 at 10:16 AM.
 
Old 03-12-2009, 10:19 AM   #11
akuthia
Member
 
Registered: Oct 2007
Location: triad, nc, usa
Distribution: Ubuntu
Posts: 232

Rep: Reputation: 29
heck, even if you're running a windows environment, theres a better idea, safer idea, and prolly still, quicker idea to defragging. Back up your data, reformat, and re-install. Gets rid of any nasty bits that might be floating around, and will take just as long as that defrag, and accomplish the same thing (and more by getting rid of whatever junk u didnt back up.)
 
Old 03-12-2009, 10:33 AM   #12
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,431

Rep: Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471Reputation: 2471
i92guboj

Interesting. Learn something every day. I've seen explanations like the one in the link I posted frequently in the past. Good to learn how it really works.
 
Old 04-24-2011, 02:28 PM   #13
patrick_the_fat
LQ Newbie
 
Registered: Apr 2011
Posts: 2

Rep: Reputation: 0
Exclamation

Actually,

I have a modern laptop (but due to its small size, the hard drive is only 80GB).
I no longer have Windows (I quit using it, a long time ago), however the NTFS partition is still there. GParted is not allowing me to resize it, even though it is only half-full, which apparently is due to fragmentation. The partition used to be full. It is now mid-2011. A tool would still be useful. I have to copy everything off (I'm using a thumb drive... I consider this a week-long project), then delete it and resize my Ext4 partition.

I am trying to make a point: do your best to try not to disprove somebody's needs, because somebody else might come along with the same issue. It happens to me again and again in all of the Linux forums. NTFS is supported in Linux and the use of NTFS partitions implies there is a possibility of fragmentation, so developing a defragmentation tool for use in Linux would be a legitimate idea and also not a bad one.

It doesn't matter how "modern" technology is, I'm still using my Tandy 1000, which asks me to set the time and date and insert a floppy disk every time I turn it on.

Last edited by patrick_the_fat; 04-24-2011 at 02:32 PM.
 
Old 04-24-2011, 02:38 PM   #14
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
You have to resize the container first.
post output of
Quote:
fdisk -l
 
Old 04-24-2011, 02:45 PM   #15
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
#13, @patrick_the_fat : Welcome to LQ.

Looks like you no more can start Windows©.
And thus can't disable the pager file, which is the usual stop
for a resize. ( Can be located at say 75 %.)
And fragmentation, may be.

But if you aren't using it, why not back up all data, and then reformat
the whole NTFS partition to a Linux file system + click apply in Gparted.
Now it should then be possible to do a resize.


And : Please do not use any old threads for questions, etc.
Better instead start a new thread.
 
  


Reply

Tags
harddisk


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Disk defragment on linux??? mihalisla Linux - Newbie 12 07-26-2006 01:52 PM
defragment for Linux alaios Linux - General 1 08-16-2005 03:15 AM
defragment linux glock19 Linux - General 11 09-14-2004 06:22 PM
No Defragment for Linux weronpc Linux - Newbie 6 02-11-2004 12:21 PM
Defragment in Linux ras123 Linux - General 5 02-05-2004 04:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:03 AM.

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