Visit Our UNIX and Linux User Community


Why does ext3 allocate 8 blocks for files that are few bytes long


 
Thread Tools Search this Thread
Operating Systems Linux Why does ext3 allocate 8 blocks for files that are few bytes long
# 1  
Old 05-25-2009
Why does ext3 allocate 8 blocks for files that are few bytes long

The title is clear: why does ext3 allocate 8 blocks for files that are few bytes long?
If I create a file named "test", put a few chars in it, and then I run:

Code:
stat test

I get that "Blocks: 8"

I searched in the web and found that ext does that, it allocates 8 blocks even if It doesn't need it. Fine by me, but what if, at some moment, I need that space? Will I get it?
If so, how does ext3 manage those semi-allocated blocks?
If not... well then, I think something is wrong here, giving 32KB to any small file as if hdd space were free seems stupid.

Could anyone enlighten me?
# 2  
Old 05-26-2009
This is so that the file can grow without fragmentation. There are parameters you can change, this may be among them. You can always try a different file system, but, always take a backup before any file system operations.

-----Post Update-----

http://linux.die.net/man/8/mke2fs

You should read up on that. You can change, at creation, the block group size or even the reserved count (5% space reserved for root, by default).
# 3  
Old 05-26-2009
Quote:
Originally Posted by Tavo
I searched in the web and found that ext does that, it allocates 8 blocks even if It doesn't need it. Fine by me, but what if, at some moment, I need that space? Will I get it?
If so, how does ext3 manage those semi-allocated blocks?
If not... well then, I think something is wrong here, giving 32KB to any small file as if hdd space were free seems stupid.

Could anyone enlighten me?
I believe that is the "tail", giving the file room to expand without fragmenting. You can turn that off with the 'notail' option to mount.
# 4  
Old 05-26-2009
Yes, I know ext3 does this to prevent fragmentation. But

mark54g, I think that "block group size" you mention is not the same thing as what I am talking about. The block group size is the size of the groups in the partition (ext2/3 is divided internally in block groups) and has nothing to do with ext3 giving me 8 blocks when it should be giving me 1.

Corona688, I searched and all I found about the notail option is that it is only for reiserFS, not for ext3.

Any ideas?
# 5  
Old 06-04-2009
Hmm. Tail-packing is being worked on for ext3 apparently but still an alpha feature.

I do think you can get that extra space if you really need it. But if your filesystem gets to the 99% full point where it needs it then you've got bigger problems. No filesystems deal well with being nearly full.

Previous Thread | Next Thread
Test Your Knowledge in Computers #349
Difficulty: Easy
AWK was originally written in 1977 and distributed with Version 7 Unix.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract sequences of bytes from binary for differents blocks

Hello to all, I would like to search sequences of bytes inside big binary file. The bin file contains blocks of information, each block begins is estructured as follow: 1- Each block begins with the hex 32 (1 byte) and ends with FF. After the FF of the last block, it follows 33. 2- Next... (59 Replies)
Discussion started by: Ophiuchus
59 Replies

2. Shell Programming and Scripting

Divide an EBCDIC files into multiple files based on value at 45-46 bytes

Hi All, I do have an EBCDIC file sent from the z/os , this file has records with different record types in it, the type of record is identified by bytes 45-46 like value 12 has employee record value 14 has salaray record and etc.... we do now want to split the big ebcdic file into multiple... (3 Replies)
Discussion started by: okkadu
3 Replies

3. Shell Programming and Scripting

Shell script - entered input(1-40 bytes) needs to be converted exactly 40 bytes

hello, suppose, entered input is of 1-40 bytes, i need it to be converted to 40 bytes exactly. example: if i have entered my name anywhere between 1-40 i want it to be stored with 40 bytes exactly. enter your name: donald duck (this is of 11 bytes) expected is as below - display 11... (3 Replies)
Discussion started by: shravan.300
3 Replies

4. UNIX for Dummies Questions & Answers

X bytes of 0, Y bytes of random data, Z bytes of 5, T bytes of 1. ??

Hello guys. I really hope someone will help me with this one.. So, I have to write this script who: - creates a file home/student/vmdisk of 10 mb - formats that file to ext3 - mounts that partition to /mnt/partition - creates a file /mnt/partition/data. In this file, there will... (1 Reply)
Discussion started by: razolo13
1 Replies

5. Programming

Copying 1024 bytes data in 3-bytes chunk

Hi, If I want to copy a 1024 byte data stream in to the target location in 3-bytes chunk, I guess I can use the following script. dd bs=1024 count=3 if=/src of=/dest But, I would like to know, how to do it via a C program. I have tried this with memcpy(), that did not help. (3 Replies)
Discussion started by: royalibrahim
3 Replies

6. Shell Programming and Scripting

how to split this file into blocks and then send these blocks as input to the tool called Yices?

Hello, I have a file like this: FILE.TXT: (define argc :: int) (assert ( > argc 1)) (assert ( = argc 1)) <check> # (define c :: float) (assert ( > c 0)) (assert ( = c 0)) <check> # now, i want to separate each block('#' is the delimeter), make them separate files, and then send them as... (5 Replies)
Discussion started by: paramad
5 Replies

7. Shell Programming and Scripting

Error PHP Fatal error: Allowed memory size of 67108864 bytes exhausted(tried to allocate 401 bytes)

While running script I am getting an error like Few lines in data are not being processed. After googling it I came to know that adding such line would give some memory to it ini_set("memory_limit","64M"); my input file size is 1 GB. Is that memory limit is based on RAM we have on... (1 Reply)
Discussion started by: elamurugu
1 Replies

8. UNIX for Dummies Questions & Answers

Convert 512-blocks to 4k blocks

I'm Unix. I'm looking at "df" on Unix now and below is an example. It's lists the filesystems out in 512-blocks, I need this in 4k blocks. Is there a way to do this in Unix or do I manually convert and how? So for container 1 there is 7,340,032 in size in 512-blocks. What would the 4k block be... (2 Replies)
Discussion started by: rockycj
2 Replies

9. UNIX for Dummies Questions & Answers

Files with zero bytes

Hi All, I want to find zero byte files in the given folder for the given day. I know we can use find . -size 0 -mtime 0 But is there an option for file creation.? ls -lart | grep ' 0 Apr 24' will also work. Also is there any alternative using awk ? I want to know how to use awk in... (1 Reply)
Discussion started by: preethgideon
1 Replies

10. Shell Programming and Scripting

Remove first N bytes and last N bytes from a binary file on AIX.

Hi all, Does anybody know or guide me on how to remove the first N bytes and the last N bytes from a binary file? Is there any AWK or SED or any command that I can use to achieve this? Your help is greatly appreciated!! Best Regards, Naveen. (1 Reply)
Discussion started by: naveendronavall
1 Replies

Featured Tech Videos