LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-09-2011, 03:48 PM   #1
sang_froid
Member
 
Registered: Oct 2006
Posts: 179

Rep: Reputation: 15
actual physical disk size


Hi,

I am trying to figure out the "actual" disk size used by my system. When I run the "df -h" command, it outputs as below:

PHP Code:
[root@spain user]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/system-root
                      2.0G 1021M  894M  54
% /
/
dev/sda2             251M   18M  221M   8% /boot
none                  2.0G     0  2.0G   0
% /dev/shm
/dev/mapper/system-home
                     1008M  123M  835M  13
% /home
/dev/mapper/system-usr
                      7.9G  5.0G  2.6G  66
% /usr 
Also, when I try to include swap space and run the command, "grep SwapTotal /proc/meminfo", I get following results:

PHP Code:
SwapTotal:     4194296 kB 
In that case, I think the total physical disk space utilized is 2Gb + 251Mb + 1008Mb + 7.9Gb + 4194296 kB

I am not taking here into consideration the shared memory of 2Gb as it is a sort of virtual shared memory and is not allocated physically. Is that correct ?
 
Old 03-09-2011, 03:55 PM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 334Reputation: 334Reputation: 334Reputation: 334
You are also not taking into account the possibility that some disk space may not be allocated to a partition. Run cfdisk as root to see all of the partitions, their sizes, and unallocated space. The sum of those sizes will be the total disk space.
 
Old 03-09-2011, 03:56 PM   #3
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Just run 'fdisk -l /dev/sda' The first line will show you the disk size. For example:

Code:
$ fdisk -l /dev/sda

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa1734966

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63     1044224      522081   fd  Linux raid autodetect
/dev/sda2         1044225   976768064   487861920   fd  Linux raid autodetect
 
Old 03-09-2011, 03:57 PM   #4
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 334Reputation: 334Reputation: 334Reputation: 334
Oooops. Never mind.
 
Old 03-09-2011, 04:02 PM   #5
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191
Quote:
Originally Posted by sang_froid View Post
I am trying to figure out the "actual" disk size used by my system.
The first two replies seem to assume your Linux system is running directly on the hardware, rather than under some kind of virtualization.

Can you set that straight. Is it directly on the hardware or what virtualization system are you using?

If it is virtual, a question like "actual disk size" might not even mean anything.

For non virtual, I would echo Macemoneta's answer, except that you might need to be root to use that command and depending on how you become root, /sbin might not be in your path, so you might need
/sbin/fdisk -l
Unless you specifically want to limit the info you get to sda, there is no need to specify which disk you want the info for. I will default to all disks.

Last edited by johnsfine; 03-09-2011 at 04:10 PM.
 
Old 03-09-2011, 04:09 PM   #6
sang_froid
Member
 
Registered: Oct 2006
Posts: 179

Original Poster
Rep: Reputation: 15
I am not trying to find the size of actual physical disk. I know it can be grabbed with fdisk and dmesg command. ""I know the size of physical disk"".

What I wanted to calculate is how much of my physical disk is being used really.




Quote:
Originally Posted by macemoneta View Post
Just run 'fdisk -l /dev/sda' The first line will show you the disk size. For example:

Code:
$ fdisk -l /dev/sda

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa1734966

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63     1044224      522081   fd  Linux raid autodetect
/dev/sda2         1044225   976768064   487861920   fd  Linux raid autodetect
 
Old 03-09-2011, 04:59 PM   #7
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Quote:
Originally Posted by sang_froid View Post
I am not trying to find the size of actual physical disk. I know it can be grabbed with fdisk and dmesg command. ""I know the size of physical disk"".

What I wanted to calculate is how much of my physical disk is being used really.
OK, how do you define "being used really"? Allocated to filesystems? If so, then the fdisk output tells you that (multiply blocks * units). If you mean allocated to files, the sum of df + swap tells you that, for mounted filesystems.
 
Old 03-09-2011, 07:33 PM   #8
sang_froid
Member
 
Registered: Oct 2006
Posts: 179

Original Poster
Rep: Reputation: 15
That is the point... I meant size allocated to files.. And over here, do I need to count /dev/shm in that case ? I don't think so...just wanted to make it sure...



Quote:
Originally Posted by macemoneta View Post
OK, how do you define "being used really"? Allocated to filesystems? If so, then the fdisk output tells you that (multiply blocks * units). If you mean allocated to files, the sum of df + swap tells you that, for mounted filesystems.
 
Old 03-09-2011, 07:42 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.3
Posts: 17,548

Rep: Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423
/dev/shm = shared (RAM) mem; shouldn't affect disk space

You can also check disk space via du for a different angle.
Note the caveats mentioned here:
http://linux.die.net/man/1/df
http://linux.die.net/man/1/du

and also allow for the fact that a certain amt (5% default) is set aside by the OS during install.
http://linux.die.net/man/8/mkfs.ext3
http://linux.die.net/man/8/tune2fs
 
  


Reply


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
real size of the drive. Actual disk space used. lgtrean Linux - General 9 10-08-2010 05:11 PM
Actual size of hard disk anaigini45 Linux - Hardware 1 01-22-2010 04:32 AM
Determine physical disk size Kristijan Linux - General 4 01-23-2005 05:56 PM
Actual Hard Disk Size on RH7.2 Arot Linux - Software 1 09-01-2003 05:22 PM
redhat 7.3 installer not showing actual disk size ... ashanmugam Linux - Software 1 09-30-2002 05:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:22 PM.

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