LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   actual physical disk size (https://www.linuxquestions.org/questions/linux-server-73/actual-physical-disk-size-867552/)

sang_froid 03-09-2011 03:48 PM

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 ?

stress_junkie 03-09-2011 03:55 PM

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.

macemoneta 03-09-2011 03:56 PM

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


stress_junkie 03-09-2011 03:57 PM

Oooops. Never mind. :redface:

johnsfine 03-09-2011 04:02 PM

Quote:

Originally Posted by sang_froid (Post 4284715)
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.

sang_froid 03-09-2011 04:09 PM

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 (Post 4284722)
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



macemoneta 03-09-2011 04:59 PM

Quote:

Originally Posted by sang_froid (Post 4284742)
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.

sang_froid 03-09-2011 07:33 PM

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 (Post 4284794)
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.


chrism01 03-09-2011 07:42 PM

/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


All times are GMT -5. The time now is 10:33 AM.