LinuxQuestions.org
Help answer threads with 0 replies.
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 01-01-2009, 04:56 PM   #1
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit LOL), USA
Distribution: Centos 6.7 Under VMware in Win7
Posts: 455

Rep: Reputation: 34
Hard Drive or File System needs to be Defraged


The hard drive I have Suse 11.0 on needs to be defraged.

I have no idea how to go about doing this.

Any suggestions and instructions would be appreciated.

Running Suse 11.0 under VMware.

Thanks
 
Old 01-01-2009, 05:00 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Q: What makes you think your disk needs to be defragmented?

PS:
We really need more context before we can give you an intelligent answer. So I

PPS:
i92guboj and Didier Spaier are both correct - Linux seldom (never?) needs to be "defragmented".

But VMWare running under Windows might. Or Windows itself might. Or you might have a bona fide performance or system integrity issue that you're misinterpreting as "I need to defragment".

Again - please tell us *why* you believe you need to defragment, please tell us the "context" of your question.

Last edited by paulsm4; 01-01-2009 at 05:28 PM.
 
Old 01-01-2009, 05:00 PM   #3
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,069

Rep: Reputation: 383Reputation: 383Reputation: 383Reputation: 383
There are no reliable tools to defrag anything in Linux (though a tools for ext4 is in the way, but I doubt you are using ext4 as your file system).

The easiest way to defrag a volume in linux is to backup the whole disk to another location, either using tar, cp or whatever. Make sure you preserve permissions and that you check the validity of the backup after having made it. Then erase your original volume and restore the backup. That will store everything in consecutive blocks and the fragmentation will be gone.

However, may I ask why do you want to defragment? Tipical linux fs's do not get too fragmented unless they are almost full, and the impact on the performance shouldn't be too big either.
 
Old 01-01-2009, 05:02 PM   #4
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-14.2 on Lenovo Thinkpad W520
Posts: 7,328

Rep: Reputation: 2356Reputation: 2356Reputation: 2356Reputation: 2356Reputation: 2356Reputation: 2356Reputation: 2356Reputation: 2356Reputation: 2356Reputation: 2356Reputation: 2356
Why should it be defragmented ?

Anyway, please provide output of following command, types as root:
Code:
fdisk -l
 
Old 01-01-2009, 06:38 PM   #5
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,289

Rep: Reputation: 126Reputation: 126
Quote:
Originally Posted by swamprat View Post
The hard drive I have Suse 11.0 on needs to be defraged.

I have no idea how to go about doing this.

Any suggestions and instructions would be appreciated.

Running Suse 11.0 under VMware.

Thanks
The fragmentation level of a virtual drive is dependent on the filesystem type of the virtual drive, and possibly on actions of the host's filesystem. I don't know about VMWare, but in VirtualBox, you have two options for creating a guest filesystem: 1) dynamic and 2) static.

In the case of static, any fragmentation is dependent on how fragmented the drive was when the virtual filesystem was created, but will not get worse based on actions of the host filesystem *unless* the host's filesystem is defragmented.

In the case of a dynamic guest, then in addition to the issues for a static filesystem, there is also the possibility of bad placement during normal expansion of the guest filesystem up to its limits.

The problem is that the guest will not know the level of fragmentation that it inherits from the host OS, and it will not be able to know any fragmentation added or subtracted stemming from a host filesystem defragmentation action. I'd just leave it alone unless you can give some solid evidence that you are suffering from guest filesystem fragmentation.
 
Old 01-01-2009, 07:09 PM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,069

Rep: Reputation: 383Reputation: 383Reputation: 383Reputation: 383
I think I have some foggy memory about being able to mark a file so it's not touched by the Windows defragmenter (maybe marking it as system file or whatever, I don't really remember). If that's truly possible, you only need to find a way to create a file that uses contiguous blocks (don't ask me how, maybe your VM software can do that for you).

Once you take care of this, you should only have to worry about the fragmentation on the guest SO, inside the VM disk image.
 
Old 01-01-2009, 10:44 PM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: Slackware®
Posts: 12,679
Blog Entries: 27

Rep: Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016
Hi,

Most 'VM' use containers therefore the file will not be touched by the M$ Win host defragment problem when using GNU/Linux as the client. These containers can be dynamic or fixed length that you would setup during the initial 'VM' install.

Code:
excerpt from 'VirtualBox UserManual.PDF';

By default, VirtualBox uses its own container format for guest hard disks – Virtual Disk
Image (VDI) files.
The VDI files reside on the host system and are seen by the guest systems as hard
disks of a certain geometry. When creating an image, its size has to be specified, which
determines this fixed geometry. It is therefore not possible to change the size of the virtual hard disk later.

...

• If you create a fixed-size image of e.g. 10 GB, a VDI file of roughly the same
size will be created on your host system. Note that the creation of a fixed-size
image can take a long time depending on the size of the image and the write
performance of your hard disk.
• For more flexible storage management, use a dynamically expanding image.
This will initially be very small and not occupy any space for unused virtual disk
sectors, but the image file will grow every time a disk sector is written to for the
first time. While this format takes less space initially, the fact that VirtualBox
needs to constantly expand the image file consumes additional computing resources,
so until the disk has fully expanded, write operations are slower than
with fixed size disks. However, after a dynamic disk has fully expanded, the
performance penalty for read and write operations is negligible.
For either of the above two image types (that is, irrespective of whether an image
is fixed-size or dynamically expanding), you can also specify whether write operations
affect the image directly.
The dynamic would be the one possible mode that could be effected by some form of broken or interleave storage problem for the container. But the fragmentation will not be a problem with fixed length.
 
Old 01-04-2009, 03:59 PM   #8
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit LOL), USA
Distribution: Centos 6.7 Under VMware in Win7
Posts: 455

Original Poster
Rep: Reputation: 34
Thanks all,

Well, its VMware running under Windoz XP.

VMware was the element which notified that a defrag was needed.

I shut down the Linux guest and VMware and did a Windows defrag but it seems that Windows defrag didn't touch the Linux area on the HD.

I like the option suggested by i92guboj. If really needed I'll take this one. I don't know how VMware thought or knew that a defrag was needed.
 
Old 01-04-2009, 09:41 PM   #9
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
swamprat -

There are multiple levels of "defrag". The Windows defrag is under "My Computer, Management, Storage, Disk Fragmenter". It's definitely a good thing to do ... but it won't necessarily help VMWare

Another level is VMWare defrag. With VMWare Workstation, you can find it under:
a) <Select> a VM
b) Settings
c) [Hardware]
e) <Select> a hard disk
f) [Defragment]

There is *not* a defragmentation utility at the final (Linux) level. It's simply not needed.

Your .. PSM
 
Old 01-04-2009, 09:46 PM   #10
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
Now that would be a good reason to use xfs. It is the only linux file system that can be defragmented AFAIK. Not that I have ever seen any need to use it.

Last edited by jay73; 01-04-2009 at 09:47 PM.
 
Old 01-04-2009, 09:53 PM   #11
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,289

Rep: Reputation: 126Reputation: 126
Quote:
Originally Posted by jay73 View Post
Now that would be a good reason to use xfs. It is the only linux file system that can be defragmented AFAIK. Not that I have ever seen any need to use it.
Perhaps, but what would you be accomplishing at the Guest level other than a somewhat random reordering of your filesystem WRT the hardware. Remember, the Guest OS does not have access to the actual hardware. So the Guest filesystem must assume that the Host OS has a reasonable ordering of its filesystem. Of course, it's possible that VMWare gets as many contiguous blocks as possible when it sets up a virtual FS for the Guest.
 
Old 01-04-2009, 09:59 PM   #12
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
Well, speaking from my experience installing a copy of XP in vmware, it was 40% fragmented righter after installing. I reduced fragmentation to virtually zero by running the XP defragmentation tool. IOW, it should not be taken for granted that the fragmentation is situated at a lower level than that of the virtualized file system.
 
Old 01-04-2009, 10:07 PM   #13
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,289

Rep: Reputation: 126Reputation: 126
Quote:
Originally Posted by jay73 View Post
Well, speaking from my experience installing a copy of XP in vmware, it was 40% fragmented righter after installing.
What did you use to measure this fragmentation level of 40%, and how did you know that the Guest OS was fragmented 40% WRT the hardware. Or was this 40% measured by the Host OS, and did VMWare take this into account when creating the Guest FS? If it did, did you wind up with a worse-ordered Guest FS after you defragged it? Remember, the Guest OS has its own ideas of what the correct ordering for a file is, and those are layered over whatever the Host gives it to work with. Any relationship between virtual location and physical location are probably coincidental.
 
Old 01-05-2009, 01:48 PM   #14
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,289

Rep: Reputation: 126Reputation: 126
I've had some more thoughts about this, and I'm starting to change my mind. Given that VMWare (or Virtual Box) will not be deleting records from a virtual FS, perhaps there won't be the usual fragmentation problems associated with file aging.
 
Old 01-06-2009, 07:19 AM   #15
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: Slackware®
Posts: 12,679
Blog Entries: 27

Rep: Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016Reputation: 2016
Hi,
Quote:
Originally Posted by Quakeboy02 View Post
I've had some more thoughts about this, and I'm starting to change my mind. Given that VMWare (or Virtual Box) will not be deleting records from a virtual FS, perhaps there won't be the usual fragmentation problems associated with file aging.
The documentation shows that the host does provide the space to the client via a container. Fragmentation would be due to the records controlled by the OS. If the host just provides a container then no fragmentation will be effected by that host but by the efficiency of the client OS.

So if the GNU/Linux is the host providing a container of 10GB to a M$ WinXP, the fragmentation will be accorded by the WinXP OS not GNU/Linux. This would also be true if the host was WinXP with a GNU/Linux client. The container for the GNU/Linux filesystem would perform R/W via the VM host hardware within the container for the GNU/Linux filesystem.
 
  


Reply


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
Hard drive file system problem, I think...please HELP QUICKLY rivalmist Fedora 7 01-23-2009 08:26 AM
External hard drive file system? DaBlade Linux - Hardware 7 10-14-2008 03:59 AM
What hard drive file system should be used for network drive? Zinake Linux - Server 5 01-23-2008 06:58 AM
How do I clone my hard drive when file-system is encrypted? gopips39 Linux - Security 2 08-17-2007 05:23 AM
Reiser file system / Hard Disk/ Hard Drive Problems Oxyacetylene Linux - Software 4 10-10-2005 02:24 PM


All times are GMT -5. The time now is 07:19 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration