1829313 Members
2259 Online
109989 Solutions
New Discussion

Disk space questions

 
R.O.
Esteemed Contributor

Disk space questions

Hi,

In a linux system, how can i know the free space in a disk? (not with df, wich tells me the free space in the mounted FS).
I need to add some swap space but i don´t know what amount of free space i have. I have RH 7.2.

Th
"When you look into an abyss, the abyss also looks into you"
5 REPLIES 5
Sunil Sharma_1
Honored Contributor

Re: Disk space questions

Hi,
You can use fdisk command to find out this.
and if you are using LVM you can use vgdisplay -v command.

Sunil
*** Dream as if you'll live forever. Live as if you'll die today ***
Mark Grant
Honored Contributor

Re: Disk space questions

As mentioned above, "fdisk" and "vgdisplay" will help you out here but if you are stuck for space you could consider using file based swap, check out the "mkswap" command.
Never preceed any demonstration with anything more predictive than "watch this"
Alexander Chuzhoy
Honored Contributor

Re: Disk space questions

there's also utility called hdparm
issue:
hdparm -g /dev/hda
to see the geometry of your IDE primary master hard drive.
each sector is 512 bytes
so so multiply the amount of sectors with 512, ans then divide it by 1000000 to see the approximate amount of MB.
regards
Huc_1
Honored Contributor

Re: Disk space questions

Good question that got me going !
so I checked on my laptop
# fdisk -s /dev/hda
17716608
#fdisk -lu /dev/hda
Disk /dev/hda: 18.1 GB, 18141806592 bytes
255 heads, 63 sectors/track, 2205 cylinders, total 35433216 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 63 208844 104391 83 Linux
/dev/hda2 208845 34507619 17149387+ 83 Linux
/dev/hda3 34507620 35423324 457852+ 82 Linux swap
# let a=17716608
# let b=104391+17149387+457852
# let c=$a-$b
# echo $c
4978
Problem is 4978 blocks of 512 bytes is 2489 Kbytes
There are 62 unallocated sectors as /dev/hda1 start at 63
what are those 62 sectors ? ... to mark physical errors on disk ?
2489 Kbytes is not much so nothing to worry about and "all" my laptop is used.
I am missing something ?
J-P

Smile I will feel the difference
Dave Falloon
Trusted Contributor

Re: Disk space questions

JP,
I have noticed the same thing but you didn't have to go through all that work to find it, you could have run fdisk on your disk and once inside verify the partition table with 'v' and it will tell you the unallocated sectors. Everytime I have done this on a machine with a fully partitioned disk I end up with the same thing 62 extra sectors left over. So I googled around, and came up with this pdf:

http://www.terabyteunlimited.com/specs/embr2.pdf

I think maybe the left overs are sectors the bios allocated to the MBR on the disk. The pdf says the minimum that the MBR can have is from sector 3-17, so I am thinking that the bios would give up more than that. I am just guessing though, and I am curious to find out the real reason for the left over sectors.

Dave
Clothes make the man, Naked people have little to no effect on society