Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-12-2006, 04:02 AM   #1
Registered: Oct 2005
Location: Bangladesh
Posts: 490

Rep: Reputation: 30
Cool 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 ?

Old 06-12-2006, 04:17 AM   #2
Registered: Aug 2005
Location: /home/teebones
Distribution: sometimes this, sometimes that..
Posts: 502

Rep: Reputation: 56
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 ?" ?
Old 06-12-2006, 11:49 PM   #3
Registered: Oct 2005
Location: Bangladesh
Posts: 490

Original Poster
Rep: Reputation: 30
Cool 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 .

Old 06-13-2006, 12:18 AM   #4
Registered: Dec 2004
Location: Malta
Distribution: Debian Sid
Posts: 806

Rep: Reputation: 43
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.
Old 06-13-2006, 01:58 AM   #5
Wim Sturkenboom
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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).
Old 06-13-2006, 03:06 AM   #6
Registered: May 2006
Location: Sydney
Distribution: FC5, FC3, AIX, System V,
Posts: 50

Rep: Reputation: 15
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.
Old 06-13-2006, 03:25 AM   #7
Registered: Jun 2006
Distribution: SuSe
Posts: 66

Rep: Reputation: 15
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!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the folder size? cupoftea Linux - Newbie 1 05-21-2006 10:19 AM
Folder Max Size and Limiting SSH access to home folder. Mefistofeles Linux - General 4 11-26-2005 02:09 PM
Folder size xedios Linux - Software 1 07-05-2004 04:40 AM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 02:26 AM
Folder size imsajjadali Red Hat 3 01-30-2004 08:01 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:25 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration