Hot answers tagged disk-usage
32
The block size of the file system must be 4 kB. When data is written to a file that is contained in a file system the operating system must allocate blocks of storage to contain the data that will be written to the file.
Typically, when a file system is created the storage contained in that file system is segmented into blocks of a fixed size. This ...
26
du == Disk Usage. It walks through directory tree and counts the sum size of all files therein. It may not output exact information due to the possibility of unreadable files, hardlinks in directory tree, etc. It will show information about the specific directory requested. Think, "How much disk space is being used by these files?"
df == Disk Free. Looks at ...
23
Symbolic links do take room, of course, but just the room it takes to store the name and target plus a few bytes for other metadata. The space taken by a symbolic link does not depend on the space taken by the target (after all, the target is not even required to exist).
Plain du reports the space taken by a directory tree on the disk. du -L reports the ...
19
Saving space for important root processes (and possible rescue actions) is one reason.
But there's another. Ext3 is pretty good at avoiding filesystem fragmentation, but once you get above about 95% full, that behavior falls off the cliff, and suddenly filesystem performance becomes a mess. So leaving 5% reserved gives you a buffer against this.
Ext4 ...
18
It will happen if you have sparse files:
$ mkdir test; cd test
$ truncate -s 1000000000 file-with-zeroes
$ ls -l
total 0
-rw-r--r-- 1 gim gim 1000000000 03-08 22:18 file-with-zeroes
A sparse file is a file which has not been populated with filesystem blocks (or only partially). When you read a non-populated zone of a sparse file you will obtain zeros. ...
17
You can use du -sh * | sort -h. This tells sort that the input is the human-readable format.
This feature was added recently to GNU Core Utilities 7.5 in Aug 2009, so many distributions do not yet have it.
15
The --inodes option to df will tell you how many inodes are reserved for use. For example:
$ df --inodes / /home
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 3981312 641704 3339608 17% /
/dev/sda8 30588928 332207 30256721 2% /home
$ sudo find / -xdev -print | wc -l
642070
$ sudo find /home -print | wc ...
14
Based on your issues in installing ncdu my recommendation would be to use du and sort on together.
For instance:
du /home | sort -rn (will search all files/directories under /home and sort them by largest to smallest.
du -h /home | sort -rh (same but will show it in MB/KB/etc) - Note this requires coreutils 7.5 or newer (sort --version to check)
You can ...
13
If you want a command-line tool, I prefer ncdu, an ncurses version of du. It scans the disk (or a given folder) and then shows the top-level space usages; you can select a given directory to get the corresponding summary for that directory, and go back without needing to reanalyze:
If you're ok with a GUI program, Filelight is the closest thing to ...
11
There are programs like Bootchart that can be used to show what programs you ran during startup - you can probably keep it going after boot to see what's been invoked during a session.
A better solution may be to use remastering tools.
There are remastering tools for Fedora, Ubuntu, and others; you can use these to customize a distribution.
You might want ...
11
You fail to mention your operating system, but on linux, this works:
$ df /path/to/some/file/or/directory
Filesystem 1k-blks Used Avail Cap Mounted
/dev/harddisk_partition 8388348 5187768 3200580 62% /home/username
^^^^^^^^^^^^^^^^^^
10
Do the “Used” and “Available” columns of df output add up to the figure in the total column? (The output of df reflects the data from the underlying statvfs system call, so you'll find the same numbers in any other application.)
If not (which is probably the case), that's because by default, on an ext2/ext3/ext4 filesystem, 5% of the space is reserved to ...
10
All file systems have a cluster or block size, or the smallest amount of disk space that can be allocated to hold a file. Even if the actual file size is smaller than the cluster/block size, it will still consume one cluster, or 4K on your file system. The cluster size depends on the file system, and the file system options.
If it contains zero bytes, as ...
9
Try using the -k flag to count 1K blocks intead of using human-readable. Then, you have a common unit and can easily do a numeric sort.
du -ck | sort -n
You don't explictly require human units, but if you did, then there are a bunch of ways to do it. Many seem to use the 1K block technique above, and then make a second call to du.
...
9
find -maxdepth 1 -type d | while read -r dir; do printf "%s:\t" "$dir"; find "$dir" | wc -l; done
Thanks to Gilles and xenoterracide for safety/compatability fixes.
The first part: find -maxdepth 1 -type d will return a list of all directories in the current working directory. This is piped to...
The second part: while read -r dir; do begins a while loop ...
9
Let's see. The device size is 1,465,138,583½ kB = 1,500,301,909,504 B. The filesystem consists of 366,284,288 blocks of 4096 B each, which is 1,500,300,443,648 B. I don't know what the remaining 1,465,856 B (1.4 MB) are used for (additional copies of the superblock? I know there are a few kB of space at the beginning for the bootloader.).
The filesystem ...
9
Normally, du shows information about disk usage (which is where its name comes from). Keep in mind that
disk usage != sum of file sizes
Because each file takes up a number of blocks on the filesystem (see man mkfs.ext2 for example). This means that only in a very rare situation a disk usage of a file equals its actual size - for that, the size must be ...
8
What you are seeing when you rerun a du command is the effect of disk buffering. Once you read a block its disk buffer is kept in the buffer cache until that block is needed. For du you need to read the directory and the inode for each file in the directory. The du results are not cached in this case, but can be derived with far less disk IO.
While it ...
8
If you can't kill your application, you can truncate instead of deleting the log file to reclaim the space. If the file was not open in append mode (with O_APPEND), then the file will appear as big as before the next time the application writes to it (though with the leading part sparse and looking as if it contained NUL bytes), but the space will have been ...
7
I realize this is going to sound both simplistic and absurd, but if you have
control over the apps in question (maybe in a test environment) you could
mount ONLY that directory on a partition of its own, then iostat, etc. would
tell you only about it, and nothing else on that spot.
If there are physical drives involved you could fake it up with a loopback
...
7
This page gives some insight on why they have different values, however it seems to suggest that your du size should be the smaller of the two.
df uses total allocated blocks, while du only looks at files themselves, excluding metadata such as inodes, which still require blocks on the disk. Additionally, if a file is deleted while an application has it ...
7
Ok, that's a weird one… not enough space to remove a file!
This turns out to be a relatively common issue with ZFS, though it could potentially arise on any filesystem that has snapshots.
The explanation is that the file you're trying to delete still exists on a snapshot. So when you delete it, the contents keep existing (in the snapshot only); and the ...
7
Parsing the output of ls is always problematic. You should always use a different tool if you mean to process the output automatically.
In your particular case, your command was failing -- not because of some missing or incompatible argument to ls -- but because of the glob you were sending it. You were asking ls to list all results including hidden ones ...
6
du summarizes the disk usage directory by directory. In your example, since the current directory has no subdirectory, the output is a single line.
If you pass the name of a file on the command line, its size is reported. If you pass the names of multiple files, this is equivalent¹ to running du multiple times; hence du .* is equivalent to du .; du ..; du ...
6
First of all, the difference in available space you are seeing doesn't mean at all that there is space "wasted"; it is not wasted because it is of fundamental importance for the filesystem to function. You should not compare Ext4 and NTFS in this way without a very big "but" specifying all the design and structural differences between filesystems, and also ...
6
Only for tree 1.6 and above
You might want to look at:
man tree
--du For each directory report its size as the accumulation of sizes of all its files and sub-directories (and
their files, and so on). The total amount of used space is also given in the final report (like the 'du -c'
command.) This option requires ...
6
Possible reasons for the differing output from du -s:
Different file system block sizes, resulting in some files taking more space at one end or the other.
Some of the files may be sparse. You aren't using the --sparse option, so those would be filled in on the destination. If you were using that option it would be possible that some files which weren't ...
6
The disk quota is a limit on the disk space that a user can occupy. It has nothing to do with free space on disk. Look at the manual page for quota(1). So when trying to sync (write out data held in memory destined to files on disk) it finds that you aren't allowed to write that much data.
And BTW, there is no "space in folders" in Unix/Linux. A directory ...
5
The default of 5% is meant for system partitions. For example, if your disk space fills up, the system logs (/var/log) and root's mailbox (/var/mail/root) can still receive important information. For a /home or general data storage partition, there's no need to leave any space for root. For special needs, you can change the user that gets the emergency ...
5
With the blocks reserved your users, and services that are running as specific users rather than running as root, can not fill a filesystsem and potentially break other things that need to write to said filesystem - though services running as root still can still make it completely full of course.
It also give you some space to work with when users complain ...
Only top voted, non community-wiki answers of a minimum length are eligible
