Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] how filesystem works?



Moin,

On Fri, 30 Mar 2007 09:04:35 +0200
Michal Hajek <hajek1@example.com> wrote:

> * Sigurd Urdahl (sigurdur@example.com) [070329 14:53]:
> > [...different kernel images...]
> > because they might very well reside on different parts of the disk.
> > The old kernel might be within the first 1023 blocks, while the new
> > one could be somewhere above that.
> 
> well, this makes a perfect sense to me. I would like to verify that, but
> I do not know how. Any ideas? 

Maybe debugfs can do that, i dont have the manpage at hand.
If not, lde (linux disk editor can do it for sure).
Ofcourse, both tools are for ext2/3 only.
Reiserfs, jfs, xfs,... need other tools.

> > If your BIOS allows you to I believe you could redefine the disk 
> > geometry to have less cylinders. From the top of my head I don't 
> > remember how you best could do that, but if you're lucky it's an option 
> > in your bios for changing the geometry.
> 
> Sounds a bit scary, but I am an adventurer :) Anyway, before this, the other
> option is more appealing to me for the moment:

Read the large disk howto[1]

> > Another way of doing it is getting the new kernel moved to a location 
> > earlier on the disk, but that is probably not a trivial operation..
> 
> Why is that? Why simply
> 1. find files at the beginning of disk
> 2. move these files to the end of disk
> 3. move kernel image to the beginning of disk
> 
> won't work? Is that because I cannot tell to which place on disk the file
> will be copied? Or even it is not easy to tell where the file *is*? 
> This should not be a principal problem, or should it?

Because on unix everything is abstracted in a way that the
upper level has no need to know what's going on below. And
to enforce that people don't try to assume anything about the
lower levels, everything from below but the abstract interface
is hidden. Ie, in this particular case you will not be able
to figure out with "normal" tools where files are located on
the disk (or even whether they are on disk) and definitly
not be able to move them around on the disk itself.

 
> What is the heuristic of mv command? More explicitedly: What if I
> "defrag" filesystem (which is ext3 in my case)

There is no defrag for unix file systems. Unix filesystems are
so called self defragmenting. Ok, the term is IMHO missued here,
(it should be "fragmentation avoiding") but it shows the visible
effect: no defragmentation needed.
Thus, unlike some FS that came centuries later than UFS (the very
first unix filesystem) based crowd, no defrag is needed.
(I'm particularly astonished, how well microsoft was able to screw
up HPFS that it again needs a defragmentation utility... not to
speak about its slowness)

> and than do [1-3] with
> assumption, that kernel image will be moved closer to the beginning of
> disk as a result of mv heuristic?

No, mv doesn't know anything about the filesystem. Only that it's moving
files around. And mind you as long as you move the file within the same
partition, you will not move the data around but only the reference to
the data.

> I do this more because I would like to understand how these things work
> more than an actual problem. 

If you want to know more about how filesystems work, start googling
for ext2. IIRC the wikipedia page was quite usefull for a start.
A must read about ext2/3 is [2], it gives a nice overview of how
ext2 as an example of an UFS derivate works.
[3] is a bit BeOS/BeFS centric, but gives a nice overview of the
tradeoffs that has to be made while designing an FS and about the
structure most of todays FS use.

While we are teaching unix internal basics, have a look at [4]
if you can find it (there are still some copies circulating,
also any good library should have it). It explains how the
"grand grand father" of linux was designed. Although most of
it does not apply anymore to modern unices, it does explain
why certain things are today how they are.


HTH and happy reading

			Attila Kinali

[1] http://tldp.org/HOWTO/Large-Disk-HOWTO.html
[2] http://web.mit.edu/tytso/www/linux/ext2intro.html
[3] http://www.nobius.org/~dbg/practical-file-system-design.pdf
[4] M. Bach. The Design of the UNIX Operating System. Prentice Hall, 1986.
-- 
Praised are the Fountains of Shelieth, the silver harp of the waters,
But blest in my name forever this stream that stanched my thirst!
                         -- Deed of Morred


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links