On Thu, 5 Dec 2002, John P. Looney wrote:
> It's because the file is likely just less than 2.0k. Linux uses an
> inode every 4k - so the smallest amount of space a file can take up
> is 4k. On windows, it's 512 bytes.
>> You lose a good bit if you have loads of small files on Linux. But
> the filesystem works a little faster, and disk space is cheap.
> Reiser gets around this by cramming loads of small files into the
> same 4k block if it can.
>> You can format an ext3 filesystem with 1k/2k/4k or even 32k
> inodes, but the problem is going to be that for small inodes, you
> need more of them (and they use up disk space, never mind the fact
> that they also are a finite resource).
inodes are a fixed size - 1 block.
ext2/3 blocksize can be anything from 1KB to PAGESIZE (in multiples
of 2 - ie 1KB, 2KB, 4KB, etc.). i386 PAGESIZE is 4KB, some platforms
have larger values, eg Alpha is 8KB. For performance, blocksize ==
PAGESIZE is best (by far). However, as you state, a file can never be
smaller than the blocksize.
Re inodes: (i think you've simply made a thinko above -
s/blocks/inodes/?).
You need inodes to store fs meta-information, eg
filenames/directories and what blocks they refer to, a file or
directory will use at least one inode. Each inode uses up a block.
When you format an ext2 fs (and most traditional nix fses?) you can
decide how many blocks should be marked as inodes. The number of
inodes determines how many files you can store on an FS. Eg, if you
will be storing lots of files, you need enough inodes. If you wont be
putting lots of files on an FS, you can go for fewer inodes and hence
have more blocks available as allocateable disk space. In general its
rather annoying to run out of inodes, as you cant create new files
(and possibly expand files/add entries to large directories), even if
there is plenty of 'space' free. So err on the side of too many
inodes :).
Ie the compromises are:
1. Blocksize: the smallest unit of storage on the fs. go for PAGESIZE
(4KB on i386) - best performance - unless you know you will be using
it for small files only. (-b option to mke2fs).
2. Inode count/ratio: the number of blocks to use as inodes. An FS on
which you will be storing small number of large files (eg your mp3
collection) might benefit from a lower inode/ratio. Conversely, an fs
on which you will be storing many many files (eg news) needs a higher
proportion of inodes. If you dont know, go for a high ratio. (see -i
and -N options, or even handier the -T {news,largefile,largefile4}
options).
> john
regards,
--
Paul Jakma paul at clubi.iepaul at jakma.org Key ID: 64A2FF6A
warning: do not ever send email to spam at dishone.st
Fortune:
UNIX enhancements aren't.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!