how to verify the disk size ( the disk that OS is installed on )

we have redhat 7.2

I will give example

# disk_os_size=` lsblk | grep sda `
sda                8:0    0   150G  0 disk
├─sda1             8:1    0   500M  0 part /boot
└─sda2             8:2    0 149.5G  0 part

# disk_os_size=` lsblk | grep sda | awk '{print $4}' `
# echo $disk_os_size
150G 500M 149.5G

so in that case the results are not good, because we get also the OS partitions

and what we want is only the size of the disk of the OS that should be 150G

disk_os_size=$(lsblk /dev/sda -o SIZE -n|head -1)

How about df -h / or findmnt -D / or findmnt -P / | sed -nr -e 's~.* SOURCE="([^"]*)" .*~\1~p' | xargs lsblk.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.