LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-19-2002, 06:53 AM   #1
udayan
Member
 
Registered: Apr 2002
Location: India
Distribution: Linux Redhat 7.0
Posts: 62

Rep: Reputation: 16
Thumbs down Defragmenting files..


Hi,
We were trying to defragment a filesystem (Ext2) from the user mode on Linux RedHat 7.0.
This is what we did for every file(only regular)-
1. From the user mode we opened the hard disk.
2. Read the inode bitmap to find if the inode is allocated.
3. Found the block numbers that were allocated to it by reading the inode bitmap table.
4. Found required number of free data blocks from Block Bitmap.
5. Copied the data from the source block to the required block.
6. Updated the block bitmap table to appropriate flags.
7. Updated the inode table to the required block numbers.


But the point is on rebooting the system is crashing ..

One idea that struck me is when we are switching off the system then the kernel copies the data back from the kernel buffer to the hard disk. Its possible that system crashed due to this reason.

Ne ideas..
thanx..
 
Old 07-19-2002, 07:45 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Have you gone to singleuser mode before running the program which does this? There shouldn't be any other programs which access the filesystem running when you are changing this.

I don't know all the details of how an ext2 filesystem works. But I thought it was possible for an inode to not only point directly to a data block but also to another inode which points to a bunch of blocks. Making it possible to get a tree structure. So you would probably have to do more then you are describing there.

But why would you want to defragment an ext2 filesystem? It's designed to keep fragmentation to a minimum.
 
Old 07-19-2002, 08:15 AM   #3
udayan
Member
 
Registered: Apr 2002
Location: India
Distribution: Linux Redhat 7.0
Posts: 62

Original Poster
Rep: Reputation: 16
Lightbulb

well what we are trying is for files having block size less than 4096 x 12 bytes..

Now what we tried was that we made two partitions and from the active one we defragmented the inactive partition but when we mounted the partition the we got following errors:


EXt2-fs error (device sd(8,17)):ext2_check_block_bitmap: Block bitmap for group number 7 is marked free

EXt2-fs error (device sd(8,17)):ext2_check_inode_bitmap: wrong free inode count in super block, stored = 55360, counted = 69882

EXt2-fs error (device sd(8,17)):ext2_check_inode_bitmap: Block #283 of the inode table in group 0 is marked free.


well we are trying to understand the linux ext2 filesystem completely and trying some experiments on it..
ne ideas.. whats happeneing..
 
  


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
clarification about defragmenting ramdak5000 Linux - Software 2 02-20-2005 12:27 AM
defragmenting ttilt Linux - Software 11 12-28-2003 08:34 AM
Defragmenting in linux? wiggywag Mandriva 7 11-25-2003 12:22 AM
Defragmenting cucolin@ Linux - Software 2 11-25-2003 12:10 AM
defragmenting otaku9876 Linux - Software 4 09-24-2001 03:38 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:47 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