LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   folder size (https://www.linuxquestions.org/questions/linux-newbie-8/folder-size-453926/)

shipon_97 06-12-2006 04:02 AM

folder size
 
Dear ,

When i want to make a new folder like "test"
folder then if i want to know the Folder size then which command need to use , and is this folder size is fixed ? If i want to increase this folder then is it any way to do this ?

Thx......

teebones 06-12-2006 04:17 AM

one could use the du command for this.

What do you mean by "If i want to increase this folder then is it any way to do this ?" ?

shipon_97 06-12-2006 11:49 PM

Folder Size
 
Suppose i make a folder "test2" into my root directory , Then when i run the following command then i found :

#du -h /root/test2 ; it shows :

8.0K /root/test2

I found this size is always fixed . But when i keep a file (which size is 4 MB) into this folder then it is possible to keep this 4MB file into this 8K folder . Now my question, how can it possible ? Normally it is not possible in windows .
I am littlebit confused about this matter . Plz anybody can help me about this matter to remove this confusion .

Thx.........

davcefai 06-13-2006 12:18 AM

Can be bewildering but: A Folder is a File. It holds info on what files are in the folder. The empty folder shows up as 8K. Then as you add files to the folder it reports on the size of the files in the folder.

The size limit is determined by:

1. The Partition size.
2. Any policies on disc space allocation that may be in force.

In other words it's all automatic and there's nothing you need to do.

Wim Sturkenboom 06-13-2006 01:58 AM

I think you confuse folders (directories) and partitions. Create a new folder in windows, right click it in windows explorer and select properties. Under the tab general, you will find size and size on disk (both being zero). This does not imply that you can't add any files in a windows folder.

Further the command du (disk usage) does not give the filesize, but the size-on-disk. The actual size is a lot smaller as can be seen with the command ls -l.
To explain:
Your HD/partition is divided in blocks of i.e. 512 bytes. A file smaller than 512 bytes will still occupy a block. The command ls -l will report e.g. 20 bytes, but du will report 512 bytes. If the file is between 512 and 1024 bytes, ls -l will report e.g. 900 bytes, but du will report 1024 bytes. Etc etc
Under windows, the block size is influenced by the used filesystem (ntfs/fat16/fat32) in combination with the size of the partition. I assume it's similar under Linux (but don't know the finer details).

While writing this story, I found something that I can't explain. On my system, the size-on-disk for an empty directory is 512 bytes and the size-on-disk for a small file is 4K. Maybe someone has an explanantion (probably filesystem implementation).

worzel68 06-13-2006 03:06 AM

Maybe 512 bytes is the allocation to store internal details for a folder in the superblock ( similar idea to file allocation table). Maybe files are always allocated 1 block of disk space.(4K +/- depending on partition size)

Well that's my guesstimate.

LzW-x 06-13-2006 03:25 AM

well, 512 bytes seems to always be the size of 1 disk sector but the cluster size varies depending on the volume size! Clusters (allocation units) are needed because there are limits in what can be address 12, 16, 32, or 48 bit file systems... You can address a single sector if the drive is small enough!

I'm not real technical on these things but I believe that's sort of the idea in windows and probably holds true in linux for some things to.

So windows would tell you an empty folder/file is 0 bytes but that is lie!!! Every directory entry takes up room including empty ones no matter what system! An empty file or folder cannot possibly be smaller than the cluster size on the formatted volume. Regardless of it being empty, it could be taking up 8KB on the drive!

I use to be more technical on these things when it mattered more for drive size... When you have a 32mb hard drive, every kilobyte counts!


All times are GMT -5. The time now is 08:53 PM.