Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-14-2007, 08:06 AM
|
#1
|
LQ Newbie
Registered: Jun 2005
Location: Bangalore , India
Distribution: Fedora Core 4, Suse 10.1
Posts: 27
Rep:
|
purposely create noncontiguous blocks in ext2
hello,
i need to create an ext2 filesystem, in which i can be assured that a file is physically noncontiguous on the ext2 fs.
must be a weird request but i need to do this for a simulation which is related to my study. i can create the file of the required size with some programming, however i am confused of how to assure that it would be noncontiguous.
if i have a file of 2000 bytes and i create an ext2 partition of block size 1024 would i be assured that it is noncontiguous?
do i have to also specify that i need only 1 block group?
if i have 2 block groups of block size 1024 would the 2000 bytes file be noncontiguous?
thanks!
|
|
|
05-14-2007, 08:33 AM
|
#2
|
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019
Rep: 
|
What is it exactly that you are trying to do? Are you trying to emulate disk fragmentation or do you simply want the file to be split up?
|
|
|
05-14-2007, 11:15 PM
|
#3
|
LQ Newbie
Registered: Jun 2005
Location: Bangalore , India
Distribution: Fedora Core 4, Suse 10.1
Posts: 27
Original Poster
Rep:
|
precisely i wish to write a program which reads a file sequentially (and random) in an ext2 filesystem. now i wish to show the effects of fragmentation and non-contiguous allocation in ext2. therefore it would be necessary for my file to be spread in a non-contiguous manner so that ultimately when the program displays the time required for access it would prove that due to non-contiguous allocation, the time required is more.
I need to do this because it would be a comparison with another filesystem which i am working on, which guarantees contiguous allocation-provided the programmer specifies exactly the no of blocks he requires...anyways that is the subject of another topic...right now i need to understand how fragmentation can be achieved
say if i create a really huge file- about 400-500 mb and create it in the / directory. would i be sure of it being noncontiguous?
also is there any command with which i can check the block size, number of block groups on my existing ext2 partition?
thanks!
|
|
|
05-14-2007, 11:19 PM
|
#4
|
LQ Newbie
Registered: Jun 2005
Location: Bangalore , India
Distribution: Fedora Core 4, Suse 10.1
Posts: 27
Original Poster
Rep:
|
@jay73-therefore in a direct sense i could reply to that question by saying- yes i want to split a file up. but of course splitting it at the disk level. not at the users end.
thanks
|
|
|
05-15-2007, 12:16 AM
|
#5
|
Senior Member
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,410
Rep: 
|
Depending on the amount of memory you have, the size of the file, and the design of the process you use to read it, you may not actually notice any difference between a file that is badly split and a file that is on the disk optimally for the filesystem. You might want to experiment with randomly accessing files of different sizes. By randomly, I mean design access methods that access the file sequentially for x blocks then skip a bunch and continue somewhere else. To see any sort of useful results, you will probably want to use a computer with the bare minimum amount of memory necessary to get it to boot. If that's not possible, you may have to resort to something like turning swap off and doing a very large mmap in some process in order to reduce the possibilty that caching will alter your test in such a way that it doesn't show anything useful. OTOH, the whole purpose of the assignment might be to have you demonstrate to your teacher that you understand the power of the disk caching system in the Linux kernel.
|
|
|
05-15-2007, 12:17 AM
|
#6
|
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019
Rep: 
|
I'm afraid you'll find ext2 to be quite resilient when it comes to fragmentation. It may become noticeable, however, when writing to a partition that is barely large enough to hold a new file: if the unused contiguous space is too narrow to store all of the new file in contiguous space, the system will have to look for any "holes" left open by previous writes; fragmentation then becomes inevitable. I imagine this situation could be reproduced by creating a fairly small partition and writing a multitude of files until the available space is (almost) used up. Fragmentation should then increase as the available space runs out, especially when the last files are a of the larger type. Fragmentation rates can be checked using this command:
e2fsck -nv /dev/hda?|grep config
|
|
|
05-15-2007, 06:38 AM
|
#7
|
LQ Newbie
Registered: Jun 2005
Location: Bangalore , India
Distribution: Fedora Core 4, Suse 10.1
Posts: 27
Original Poster
Rep:
|
@jay- thanks for that tip. i think i ll try that out- create a small partition and place a large file on it.
|
|
|
All times are GMT -5. The time now is 08:05 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|