This is an old question, but I wanted to give my answer as well.
Since we're talking about free available space, we should talk about sectors, since no partitioning or sizing of sectors is done.
For us human beings this doesn't make much sense. To have human-readable information we must translate this number into bytes.
So, we have a disk already partitioned and we want to know how much space we may use. I personally don't like the parted
solution because my brain-memory for commands is already taken. There is also cfdisk
, which gives you free space. But I think fdisk is the quickest solution: it's plain and simple, with nothing to install: execute fdisk /dev/sdx
and then enter v into the interactive shell. It will gives you the number of sectors still free.
2004-54-0 [17:03:33][root@minimac:~]$> fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).
..
Command (m for help): v
Remaining 1713 unallocated 512-byte sectors
We still have 1713 sectors at 512 bytes each. So, because you love terminal (in 2012, who knows now?) we do echo $(((1713*512)/1024))k
, which is 1713 sectors multiplied for 512 bytes (divided by 1024 to have KB), which gives 856k.. not even 900 KB.. and I need another disk..
open(2)
-ed butunlink(2)
-ed files still use disk space. – Win