We have some Linux servers with several disks.
[root@xxxxx~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 558.4G 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 146G 0 part
├─ol-root 252:0 0 70G 0 lvm /
├─ol-swap 252:1 0 16G 0 lvm [SWAP]
├─ol-tmp 252:2 0 20G 0 lvm /tmp
├─ol-var 252:3 0 20G 0 lvm /var
└─ol-home 252:4 0 20G 0 lvm /home
sdb 8:16 0 100G 0 disk
└─360060e80225273005041527300002000 252:5 0 100G 0 mpath
└─360060e80225273005041527300002000p1 252:8 0 100G 0 part
sdc 8:32 0 100G 0 disk
└─360060e80225273005041527300002001 252:6 0 100G 0 mpath
└─360060e80225273005041527300002001p1 252:9 0 100G 0 part
sdd 8:48 0 100G 0 disk
└─360060e80225273005041527300002002 252:28 0 100G 0 mpath
└─360060e80225273005041527300002002p1 252:32 0 100G 0 part
sde 8:64 0 100G 0 disk
└─360060e80225273005041527300002003 252:33 0 100G 0 mpath
└─360060e80225273005041527300002003p1 252:36 0 100G 0 part
sdf 8:80 0 100G 0 disk
└─360060e80225273005041527300002004 252:35 0 100G 0 mpath
└─360060e80225273005041527300002004p1 252:38 0 100G 0 part
sdg 8:96 0 100G 0 disk
└─360060e80225273005041527300002005 252:37 0 100G 0 mpath
└─360060e80225273005041527300002005p1 252:40 0 100G 0 part
sdh 8:112 0 100G 0 disk
└─360060e80225273005041527300002006 252:39 0 100G 0 mpath
└─360060e80225273005041527300002006p1 252:42 0 100G 0 part
sdi 8:128 0 100G 0 disk
└─360060e80225273005041527300002007 252:41 0 100G 0 mpath
└─360060e80225273005041527300002007p1 252:44 0 100G 0 part
sdj 8:144 0 100G 0 disk
└─360060e80225273005041527300002008 252:43 0 100G 0 mpath
└─360060e80225273005041527300002008p1 252:46 0 100G 0 part
sdk 8:160 0 100G 0 disk
└─360060e80225273005041527300002009 252:45 0 100G 0 mpath
└─360060e80225273005041527300002009p1 252:47 0 100G 0 part
sdl 8:176 0 100G 0 disk
└─360060e8022527300504152730000200a 252:7 0 100G 0 mpath
└─360060e8022527300504152730000200a1 252:11 0 100G 0 part
sdm 8:192 0 200G 0 disk
└─360060e8022527300504152730000200b 252:10 0 200G 0 mpath
└─360060e8022527300504152730000200b1 252:13 0 200G 0 part
sdn 8:208 0 200G 0 disk
└─360060e8022527300504152730000200c 252:12 0 200G 0 mpath
└─360060e8022527300504152730000200c1 252:15 0 200G 0 part
sdo 8:224 0 200G 0 disk
└─360060e8022527300504152730000200d 252:14 0 200G 0 mpath
└─360060e8022527300504152730000200d1 252:17 0 200G 0 part
sdp 8:240 0 6G 0 disk
└─360060e8022527300504152730000200e 252:16 0 6G 0 mpath
└─360060e8022527300504152730000200e1 252:19 0 6G 0 part
sdq 65:0 0 6G 0 disk
└─360060e8022527300504152730000200f 252:18 0 6G 0 mpath
└─360060e8022527300504152730000200f1 252:21 0 6G 0 part
sdr 65:16 0 6G 0 disk
└─360060e80225273005041527300002010 252:20 0 6G 0 mpath
└─360060e80225273005041527300002010p1 252:23 0 6G 0 part
sds 65:32 0 120G 0 disk
└─360060e80225273005041527300002013 252:22 0 120G 0 mpath
└─360060e80225273005041527300002013p1 252:25 0 120G 0 part
└─oracle-u01 252:29 0 120G 0 lvm /u01
sdt 65:48 0 10G 0 disk
└─360060e80225273005041527300002014 252:24 0 10G 0 mpath
└─360060e80225273005041527300002014p1 252:27 0 10G 0 part
sdu 65:64 0 100G 0 disk
└─360060e80225273005041527300002015 252:26 0 100G 0 mpath
└─360060e80225273005041527300002015p1 252:31 0 100G 0 part
sdv 65:80 0 100G 0 disk
└─360060e80225273005041527300002016 252:30 0 100G 0 mpath
└─360060e80225273005041527300002016p1 252:34 0 100G 0 part
sdw 65:96 0 100G 0 disk
└─360060e80225273005041527300002000 252:5 0 100G 0 mpath
└─360060e80225273005041527300002000p1 252:8 0 100G 0 part
sdx 65:112 0 100G 0 disk
└─360060e80225273005041527300002001 252:6 0 100G 0 mpath
└─360060e80225273005041527300002001p1 252:9 0 100G 0 part
sdy 65:128 0 100G 0 disk
└─360060e80225273005041527300002002 252:28 0 100G 0 mpath
└─360060e80225273005041527300002002p1 252:32 0 100G 0 part
sdz 65:144 0 100G 0 disk
└─360060e80225273005041527300002003 252:33 0 100G 0 mpath
└─360060e80225273005041527300002003p1 252:36 0 100G 0 part
sdaa 65:160 0 100G 0 disk
└─360060e80225273005041527300002004 252:35 0 100G 0 mpath
└─360060e80225273005041527300002004p1 252:38 0 100G 0 part
sdab 65:176 0 100G 0 disk
└─360060e80225273005041527300002005 252:37 0 100G 0 mpath
└─360060e80225273005041527300002005p1 252:40 0 100G 0 part
sdac 65:192 0 100G 0 disk
└─360060e80225273005041527300002006 252:39 0 100G 0 mpath
└─360060e80225273005041527300002006p1 252:42 0 100G 0 part
sdad 65:208 0 100G 0 disk
└─360060e80225273005041527300002007 252:41 0 100G 0 mpath
└─360060e80225273005041527300002007p1 252:44 0 100G 0 part
sdae 65:224 0 100G 0 disk
└─360060e80225273005041527300002008 252:43 0 100G 0 mpath
└─360060e80225273005041527300002008p1 252:46 0 100G 0 part
sdaf 65:240 0 100G 0 disk
└─360060e80225273005041527300002009 252:45 0 100G 0 mpath
└─360060e80225273005041527300002009p1 252:47 0 100G 0 part
sdag 66:0 0 100G 0 disk
└─360060e8022527300504152730000200a 252:7 0 100G 0 mpath
└─360060e8022527300504152730000200a1 252:11 0 100G 0 part
sdah 66:16 0 200G 0 disk
└─360060e8022527300504152730000200b 252:10 0 200G 0 mpath
└─360060e8022527300504152730000200b1 252:13 0 200G 0 part
sdai 66:32 0 200G 0 disk
└─360060e8022527300504152730000200c 252:12 0 200G 0 mpath
└─360060e8022527300504152730000200c1 252:15 0 200G 0 part
sdaj 66:48 0 200G 0 disk
└─360060e8022527300504152730000200d 252:14 0 200G 0 mpath
└─360060e8022527300504152730000200d1 252:17 0 200G 0 part
sdak 66:64 0 6G 0 disk
└─360060e8022527300504152730000200e 252:16 0 6G 0 mpath
└─360060e8022527300504152730000200e1 252:19 0 6G 0 part
sdal 66:80 0 6G 0 disk
└─360060e8022527300504152730000200f 252:18 0 6G 0 mpath
└─360060e8022527300504152730000200f1 252:21 0 6G 0 part
sdam 66:96 0 6G 0 disk
└─360060e80225273005041527300002010 252:20 0 6G 0 mpath
└─360060e80225273005041527300002010p1 252:23 0 6G 0 part
sdan 66:112 0 120G 0 disk
└─360060e80225273005041527300002013 252:22 0 120G 0 mpath
└─360060e80225273005041527300002013p1 252:25 0 120G 0 part
└─oracle-u01 252:29 0 120G 0 lvm /u01
sdao 66:128 0 10G 0 disk
└─360060e80225273005041527300002014 252:24 0 10G 0 mpath
└─360060e80225273005041527300002014p1 252:27 0 10G 0 part
sdap 66:144 0 100G 0 disk
└─360060e80225273005041527300002015 252:26 0 100G 0 mpath
└─360060e80225273005041527300002015p1 252:31 0 100G 0 part
sdaq 66:160 0 100G 0 disk
└─360060e80225273005041527300002016 252:30 0 100G 0 mpath
└─360060e80225273005041527300002016p1 252:34 0 100G 0 part
sdar 66:176 0 100G 0 disk
└─360060e80225273005041527300002000 252:5 0 100G 0 mpath
└─360060e80225273005041527300002000p1 252:8 0 100G 0 part
sdas 66:192 0 100G 0 disk
└─360060e80225273005041527300002001 252:6 0 100G 0 mpath
└─360060e80225273005041527300002001p1 252:9 0 100G 0 part
sdat 66:208 0 100G 0 disk
└─360060e80225273005041527300002002 252:28 0 100G 0 mpath
└─360060e80225273005041527300002002p1 252:32 0 100G 0 part
sdau 66:224 0 100G 0 disk
└─360060e80225273005041527300002003 252:33 0 100G 0 mpath
└─360060e80225273005041527300002003p1 252:36 0 100G 0 part
sdav 66:240 0 100G 0 disk
└─360060e80225273005041527300002004 252:35 0 100G 0 mpath
└─360060e80225273005041527300002004p1 252:38 0 100G 0 part
sdaw 67:0 0 100G 0 disk
└─360060e80225273005041527300002005 252:37 0 100G 0 mpath
└─360060e80225273005041527300002005p1 252:40 0 100G 0 part
sdax 67:16 0 100G 0 disk
└─360060e80225273005041527300002006 252:39 0 100G 0 mpath
└─360060e80225273005041527300002006p1 252:42 0 100G 0 part
sday 67:32 0 100G 0 disk
└─360060e80225273005041527300002007 252:41 0 100G 0 mpath
└─360060e80225273005041527300002007p1 252:44 0 100G 0 part
sdaz 67:48 0 100G 0 disk
└─360060e80225273005041527300002008 252:43 0 100G 0 mpath
└─360060e80225273005041527300002008p1 252:46 0 100G 0 part
sdba 67:64 0 100G 0 disk
└─360060e80225273005041527300002009 252:45 0 100G 0 mpath
└─360060e80225273005041527300002009p1 252:47 0 100G 0 part
sdbb 67:80 0 100G 0 disk
└─360060e8022527300504152730000200a 252:7 0 100G 0 mpath
└─360060e8022527300504152730000200a1 252:11 0 100G 0 part
sdbc 67:96 0 200G 0 disk
└─360060e8022527300504152730000200b 252:10 0 200G 0 mpath
└─360060e8022527300504152730000200b1 252:13 0 200G 0 part
sdbd 67:112 0 200G 0 disk
└─360060e8022527300504152730000200c 252:12 0 200G 0 mpath
└─360060e8022527300504152730000200c1 252:15 0 200G 0 part
sdbe 67:128 0 200G 0 disk
└─360060e8022527300504152730000200d 252:14 0 200G 0 mpath
└─360060e8022527300504152730000200d1 252:17 0 200G 0 part
sdbf 67:144 0 6G 0 disk
└─360060e8022527300504152730000200e 252:16 0 6G 0 mpath
└─360060e8022527300504152730000200e1 252:19 0 6G 0 part
sdbg 67:160 0 6G 0 disk
└─360060e8022527300504152730000200f 252:18 0 6G 0 mpath
└─360060e8022527300504152730000200f1 252:21 0 6G 0 part
sdbh 67:176 0 6G 0 disk
└─360060e80225273005041527300002010 252:20 0 6G 0 mpath
└─360060e80225273005041527300002010p1 252:23 0 6G 0 part
sdbi 67:192 0 120G 0 disk
└─360060e80225273005041527300002013 252:22 0 120G 0 mpath
└─360060e80225273005041527300002013p1 252:25 0 120G 0 part
└─oracle-u01 252:29 0 120G 0 lvm /u01
sdbj 67:208 0 10G 0 disk
└─360060e80225273005041527300002014 252:24 0 10G 0 mpath
└─360060e80225273005041527300002014p1 252:27 0 10G 0 part
sdbk 67:224 0 100G 0 disk
└─360060e80225273005041527300002015 252:26 0 100G 0 mpath
└─360060e80225273005041527300002015p1 252:31 0 100G 0 part
sdbl 67:240 0 100G 0 disk
└─360060e80225273005041527300002016 252:30 0 100G 0 mpath
└─360060e80225273005041527300002016p1 252:34 0 100G 0 part
sdbm 68:0 0 100G 0 disk
└─360060e80225273005041527300002000 252:5 0 100G 0 mpath
└─360060e80225273005041527300002000p1 252:8 0 100G 0 part
sdbn 68:16 0 100G 0 disk
└─360060e80225273005041527300002001 252:6 0 100G 0 mpath
└─360060e80225273005041527300002001p1 252:9 0 100G 0 part
sdbo 68:32 0 100G 0 disk
└─360060e80225273005041527300002002 252:28 0 100G 0 mpath
└─360060e80225273005041527300002002p1 252:32 0 100G 0 part
sdbp 68:48 0 100G 0 disk
└─360060e80225273005041527300002003 252:33 0 100G 0 mpath
└─360060e80225273005041527300002003p1 252:36 0 100G 0 part
sdbq 68:64 0 100G 0 disk
└─360060e80225273005041527300002004 252:35 0 100G 0 mpath
└─360060e80225273005041527300002004p1 252:38 0 100G 0 part
sdbr 68:80 0 100G 0 disk
└─360060e80225273005041527300002005 252:37 0 100G 0 mpath
└─360060e80225273005041527300002005p1 252:40 0 100G 0 part
sdbs 68:96 0 100G 0 disk
└─360060e80225273005041527300002006 252:39 0 100G 0 mpath
└─360060e80225273005041527300002006p1 252:42 0 100G 0 part
sdbt 68:112 0 100G 0 disk
└─360060e80225273005041527300002007 252:41 0 100G 0 mpath
└─360060e80225273005041527300002007p1 252:44 0 100G 0 part
sdbu 68:128 0 100G 0 disk
└─360060e80225273005041527300002008 252:43 0 100G 0 mpath
└─360060e80225273005041527300002008p1 252:46 0 100G 0 part
sdbv 68:144 0 100G 0 disk
└─360060e80225273005041527300002009 252:45 0 100G 0 mpath
└─360060e80225273005041527300002009p1 252:47 0 100G 0 part
sdbw 68:160 0 100G 0 disk
└─360060e8022527300504152730000200a 252:7 0 100G 0 mpath
└─360060e8022527300504152730000200a1 252:11 0 100G 0 part
sdbx 68:176 0 200G 0 disk
└─360060e8022527300504152730000200b 252:10 0 200G 0 mpath
└─360060e8022527300504152730000200b1 252:13 0 200G 0 part
sdby 68:192 0 200G 0 disk
└─360060e8022527300504152730000200c 252:12 0 200G 0 mpath
└─360060e8022527300504152730000200c1 252:15 0 200G 0 part
sdbz 68:208 0 200G 0 disk
└─360060e8022527300504152730000200d 252:14 0 200G 0 mpath
└─360060e8022527300504152730000200d1 252:17 0 200G 0 part
sdca 68:224 0 6G 0 disk
└─360060e8022527300504152730000200e 252:16 0 6G 0 mpath
└─360060e8022527300504152730000200e1 252:19 0 6G 0 part
sdcb 68:240 0 6G 0 disk
└─360060e8022527300504152730000200f 252:18 0 6G 0 mpath
└─360060e8022527300504152730000200f1 252:21 0 6G 0 part
sdcc 69:0 0 6G 0 disk
└─360060e80225273005041527300002010 252:20 0 6G 0 mpath
└─360060e80225273005041527300002010p1 252:23 0 6G 0 part
sdcd 69:16 0 120G 0 disk
└─360060e80225273005041527300002013 252:22 0 120G 0 mpath
└─360060e80225273005041527300002013p1 252:25 0 120G 0 part
└─oracle-u01 252:29 0 120G 0 lvm /u01
sdce 69:32 0 10G 0 disk
└─360060e80225273005041527300002014 252:24 0 10G 0 mpath
└─360060e80225273005041527300002014p1 252:27 0 10G 0 part
sdcf 69:48 0 100G 0 disk
└─360060e80225273005041527300002015 252:26 0 100G 0 mpath
└─360060e80225273005041527300002015p1 252:31 0 100G 0 part
sdcg 69:64 0 100G 0 disk
└─360060e80225273005041527300002016 252:30 0 100G 0 mpath
└─360060e80225273005041527300002016p1 252:34 0 100G 0 part
sdch 69:80 0 400G 0 disk
└─360060e80225273005041527300000007 252:48 0 400G 0 mpath
└─360060e80225273005041527300000007p1 252:51 0 400G 0 part
sdci 69:96 0 400G 0 disk
└─360060e80225273005041527300000008 252:49 0 400G 0 mpath
└─360060e80225273005041527300000008p1 252:50 0 400G 0 part
sdcj 69:112 0 400G 0 disk
└─360060e80225273005041527300000007 252:48 0 400G 0 mpath
└─360060e80225273005041527300000007p1 252:51 0 400G 0 part
sdck 69:128 0 400G 0 disk
└─360060e80225273005041527300000008 252:49 0 400G 0 mpath
└─360060e80225273005041527300000008p1 252:50 0 400G 0 part
sdcl 69:144 0 400G 0 disk
└─360060e80225273005041527300000007 252:48 0 400G 0 mpath
└─360060e80225273005041527300000007p1 252:51 0 400G 0 part
sdcm 69:160 0 400G 0 disk
└─360060e80225273005041527300000008 252:49 0 400G 0 mpath
└─360060e80225273005041527300000008p1 252:50 0 400G 0 part
sdcn 69:176 0 400G 0 disk
└─360060e80225273005041527300000007 252:48 0 400G 0 mpath
└─360060e80225273005041527300000007p1 252:51 0 400G 0 part
sdco 69:192 0 400G 0 disk
└─360060e80225273005041527300000008 252:49 0 400G 0 mpath
└─360060e80225273005041527300000008p1 252:50 0 400G 0 part
asm/acfsvol001-308 250:157697 0 454G 0 disk /ORACLE_BKP
Is there a command to check the total size (sum) of all disks? We only want the disk sizes, excluding the multipath paths and partitions size, to avoid redundancy and wrong size (in this case, only the size of sda, sdb etc..., without the partitions sda1,sda2 etc... and without the paths like 360060e80225273005041527300002000 and 360060e80225273005041527300002000p1 etc...).
For example, in my sever only have 3 disks of 6GBs
[root@xxxxxx~]# multipath -ll|grep '6.0G'
size=6.0G features='0' hwhandler='0' wp=rw
size=6.0G features='0' hwhandler='0' wp=rw
size=6.0G features='0' hwhandler='0' wp=rw
but lsblks
report 6GB 36 times
Update:
I've tried the following script, but the size is wrong
# Lista todos os discos com TYPE "disk" e calcula o armazenamento total
total_storage=$(lsblk -b -o NAME,SIZE,TYPE,MOUNTPOINT | awk '$3 == "disk" {total += $2} END {print total / (1024^3)}')
# Converte o total para T se for maior que 1000G e limita a 3 casas decimais
if (( $(echo "$total_storage > 1000" | bc -l) )); then
total_storage_tb=$(echo "scale=3; $total_storage / 1024" | bc -l)
echo "Armazenamento total de discos: ${total_storage_tb}T"
else
total_storage_gb=$(printf "%.3f" "$total_storage")
echo "Armazenamento total de discos: ${total_storage_gb}G"
fi
the size is wrong
but you don't tell us a) the wrong size generated by your code b) the expected 'correct' size; please update the question with these additional detailslsblk
(sans args) call while the code is running a differentlsblk
call; please update the question to either a) show the output from your actuallsblk -b -o NAME,SIZE,TYPE,MOUNTPOINT
call or b) provide the actual code you're using to parse the sample data set (ie,lsblk
sans all args)lsblk
. Is your sample output complete or do you have duplicates?