Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a partition /dev/sda1.
Disk utility shows, it has capacity of 154 GB.
df -h shows

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             123G  104G   14G  89% /
devtmpfs             1006M  280K 1006M   1% /dev
none                 1007M  276K 1006M   1% /dev/shm
none                 1007M  216K 1006M   1% /var/run
none                 1007M     0 1007M   0% /var/lock
none                 1007M     0 1007M   0% /lib/init/rw

Why are the results different? Where are the missing 31 GB?

Thank you

share|improve this question
3  
Please post the output of fdisk -l /dev/sda (run as root). –  Gilles Apr 6 '11 at 20:01
1  
What filesystem are you using? If it's ext2/3/4 then you can use tune2fs -l /dev/sda1 to examine it. Look at block count and block size and multiply them to get the filesystem size. Also, fdisk -s /dev/sda1 to get the partition size in 1k-blocks. Multiply that by 1024 to get the size in bytes. That number should only be slightly larger than the filesystem. On my 40GB ext4 partition, it's 3072 bytes larger. If your filesystem is oddly smaller, you can try resizing it. For ext2/3/4, use resize2fs /dev/sda1. You can do this while using the computer normally. –  penguin359 Apr 6 '11 at 20:06
    
@Gilles sudo fdisk -l /dev/sda shows (I'm posting only the sda1 partition, because others don't interest us). Device Boot Start End Blocks Id System /dev/sda1 1 18706 150253568 83 Linux –  xralf Apr 7 '11 at 11:48
    
@penguin359 I have ext4 filesystem. block count = 32668162, block size = 4096, 32668162 * 4096 = 133808791552, fdisk -s /dev/sda1 * 1024 = 153859653632. It seems to be oddly smaller. Can I resize it without loss of data? What caused that it is smaller? –  xralf Apr 7 '11 at 12:12
    
@xralf: resizing should be safe, I've never lost data doing it. It might be slightly safer to do it to an unmounted partition, with eg a live cd. But still, get yourself a backup first. Always get a backup before doing major sys admin stuff. –  Faheem Mitha Apr 7 '11 at 18:11

4 Answers 4

up vote 4 down vote accepted

One reason the partition capacities can differ is that some space is reserved for root, in the event the partitions become full. If there is no space reserved for root, and the partitions become full, the system cannot function. However, this difference is usually of the order of 1%, so that does not explain the difference in your case. From the man page for df

If an argument is the absolute file name of a disk device node containing a mounted file system, df shows the space available on that file system rather than on the file system containing the device node (which is always the root file system).

So df is really showing the size of your filesystem, which is usually the size of the device, but this may not be true in your case. Does your filesystem extend over the whole of your partition?

Does

resize2fs /dev/sda1

make any difference? This command tries to increase your filesystem to cover the entire partition. But make sure you have a backup if you try this.

share|improve this answer
    
>>Does your filesystem extend over the whole partition? I think so. It's ext4.<br> What should I backup? I don't have any secondary disk to make larger backup. –  xralf Apr 7 '11 at 12:16
    
@xralf: (Ok, this is off-topic in terms of this question, but...) If don't have a backup, set one up immediately. The only alternative of a good backup (and it is not a good alternative) is systematic use of a distributed version control system, and pushing it to some remote location. But of course, you can't put everything under version control eg. media. Please excuse if I am being a busybody. –  Faheem Mitha Apr 7 '11 at 18:07
    
@xralf: I would post your output results in the question itself, it is easier to see, and read. –  Faheem Mitha Apr 7 '11 at 18:09
    
resize2fs is quite safe operation, there is no need to backup for it (if you have stable power and you use stable software). BTW, default reserved block count is 5% for ext* filesystems. –  rvs Apr 7 '11 at 18:11
    
@rvs: disagree re backup. You are right about the 5% at least on Debian. I was misremembering. But I don't know if that is standard across all distributions. –  Faheem Mitha Apr 7 '11 at 18:14

Probably they are used by inodes. Some amount may be used up by MBR.

share|improve this answer
    
The MBR does not appear as it is in cylinder 0 (not even in the first partition, which often starts at sector 2048). However, there are copies of the superblock. Still, it's the inodes. See also: unix.stackexchange.com/questions/13547/… and the commands "lsblk /dev/sdX" and "dumpe2fs -h /dev/sdX" –  David Tonhofer Jun 22 at 9:22

sda1 isn't your whole disk but its first primary partition. You might have created other unmounted partitions that do not show up in df output or simply have sda1 not filling all usable space for some reason or having the filesystem not using all available space in its partition.

fdisk -l will tell you what your partition table looks like.

share|improve this answer
    
Of course. We're talking only about /dev/sda1 partition, not the whole disk. –  xralf Apr 7 '11 at 12:21
    
That wasn't obvious from your question as you refer to a disk utility without showing its output. You should edit it to make that clear. Telling how did you create the / file system would be useful too. –  jlliagre Apr 7 '11 at 14:12
    
The relevant part of the output of disk utility is "capacity of sda1 partition = 154 GB". –  xralf Apr 7 '11 at 18:13
    
Please edit your original question to make that clear. –  jlliagre Apr 7 '11 at 20:45

The main difference is because some things say 1 kilobyte is 1000 bytes, and others say 1 kilobyte is 1024 bytes.

Gnome Disk Utility shows the capacity using 1 kilobyte = 1000 bytes, because disk manufacturers describe disk sizes this way. This means your disk capacity is close to 154,000,000,000 bytes.

On the other hand, most operating systems say 1 kilobyte = 1024 bytes. All the tools like df and fdisk use this convention. So 154,000,000,000 bytes / 1024 / 1024 / 1024 = 143.4 GB.

As jlliagre rightly points out (and Gilles implies when asking for your fdisk output), disk utility is telling you the size of your whole hard disk. But /dev/sda1 is a single partition on your hard disk. For example, your hard disk probably has some other partitions on it such as a 4-8 GB partition for swap (also known as virtual memory), and a boot partition which is usually around 100 MB.

You didn't post the output of fdisk -l /dev/sda, so let's assume your swap partition is 8 GB. Now we're down to 135 GB.

Then, there are some other things that contribute to the difference.

For example, the file system uses some of the disk partition for metadata. Metadata is things like file names, file permissions, which parts of the partition belong to which files, and which parts of the partition are free. On my system, about 2% of the partition is used for this. Assuming yours is similar, it would bring the free space down to about 132 GB.

The file system can also reserve some space that can only be used by the root user. On my system, it's 5% of the partition, so in your case, it would mean a total capacity of about 125 GB.

The exact numbers depend on whether you are using ext2, ext3, ext4, fat, ntfs, btrfs, etc, and what settings were used when formatting the partition.

If you are using ext2 or ext3, sudo tune2fs -l /dev/sda1 can help understand where the space is going.

share|improve this answer
    
Disk utility shows exactly capacity 154 GB (153,859,653,632 bytes). –  xralf Apr 7 '11 at 12:18
    
>> sudo tune2fs -l /dev/sda1 << Which parameters tell me where the space is going? –  xralf Apr 7 '11 at 12:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.