Is there way to find out total allocated space and used space in Linux physical servers

My management is looking allocated and used space to be calculated in physical servers. servers could be application and database servers.
is the way, that I can find out in linux physical servers.
If any one did this exercise, please help me.

There are many ways to calculate disk space?

Why not enjoy searching out 1M+ posts for an answer?

I know to calculate space from mounted file systems, which are mounted and listed by running command "df".
But, I am looking to allocate disks , which shows in fdisk or multipath. might be they are in asm or cluster or not mounted due to xyz reason.

If the disk is not mounted, then you need to use something like fdisk, all system dependent commands.

To accomplish this you are going to have to be very specific about operating systems.

So far, you have only talked in very general terms, and of course it's not really feasible to come up with a solution until you get specific based on OS.

So, let's start with only one type of operating system and create a solution for only one first.

How does that sound?

OS can rhel6 , rhel7 or rhel8

So, these physical disks, you can check the basic information with fdisk;

Device        Start       End   Sectors   Size Type
/dev/sda1      2048      4095      2048     1M BIOS boot
/dev/sda2      4096   1003519    999424   488M Linux RAID
/dev/sda3   1003520  17004543  16001024   7.6G Linux RAID
/dev/sda4  17004544 500117503 483112960 230.4G Linux RAID

But as you can see, there is no filesystem information in that listing, but you can get it, for example with:

fsck -N /dev/sdb1

with returns, for example:

hawk530:~# fsck -N /dev/sdb1
fsck from util-linux 2.27.1
[/sbin/fsck.ext2 (1) -- /dev/sdb1] fsck.ext2 /dev/sdb1 

We can also use lsblk to get general information, but not what is used / free by the filesystem:

#  lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda       8:0    0 238.5G  0 disk  
├─sda1    8:1    0     1M  0 part  
├─sda2    8:2    0   488M  0 part  
│ └─md0   9:0    0 487.7M  0 raid1 /boot
├─sda3    8:3    0   7.6G  0 part  
│ └─md1   9:1    0   7.6G  0 raid1 [SWAP]
└─sda4    8:4    0 230.4G  0 part  
  └─md2   9:2    0 230.2G  0 raid1 /
sdb       8:16   0 238.5G  0 disk  
├─sdb1    8:17   0     1M  0 part  
├─sdb2    8:18   0   488M  0 part  
│ └─md0   9:0    0 487.7M  0 raid1 /boot
├─sdb3    8:19   0   7.6G  0 part  
│ └─md1   9:1    0   7.6G  0 raid1 [SWAP]
└─sdb4    8:20   0 230.4G  0 part  
  └─md2   9:2    0 230.2G  0 raid1 /

and you can use the proc file, for example:

# cat /proc/partitions
major minor  #blocks  name

   8        0  250059096 sda
   8        1       1024 sda1
   8        2     499712 sda2
   8        3    8000512 sda3
   8        4  241556480 sda4
   8       16  250059096 sdb
   8       17       1024 sdb1
   8       18     499712 sdb2
   8       19    8000512 sdb3
   8       20  241556480 sdb4
   9        1    7996416 md1
   9        2  241425408 md2
   9        0     499392 md0

But as you can see, none of these will show the filesystem usage details, because the disks are not mounted.

Maybe you can look into this and see if you can make it work for you somehow?

lsblk -i -o
1 Like