Edit:
I have several machine and I need to get the total storage size of the main disk.
The problem I have is that on some machine my disk have the name /dev/sda
or /dev/md126p3
.
How could I reliably get the size of my disk on all those system.
Machine 1:
root@maximus:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md126p3 20G 3,6G 15G 20% /
/dev/md126p2 1008M 89M 868M 10% /boot
/dev/md126p1 99M 238K 99M 1% /boot/efi
Machine 2:
root@firefly:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 30G 2,8G 26G 10% /
/dev/sda2 1008M 61M 896M 7% /boot
/dev/sda1 20M 132K 20M 1% /boot/efi
Machine 3:
root@backup:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md0 7,3T 297G 6,6T 5% /
/dev/md1 733M 57M 623M 9% /boot
Machine 4:
root@vmfarm1:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md126p3 18G 8,0G 9,3G 47% /
/dev/md126p2 190M 87M 90M 50% /boot
/dev/md126p1 119M 121K 119M 1% /boot/efi
Machine 5:
root@p12:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/dm-1 6.3T 4.8T 1.3T 80% /
/dev/sda2 237M 60M 166M 27% /boot
Machine 6:
root@accountant:~# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 20G 415M 19G 3% /
/dev/mapper/acc-root 20G 415M 19G 3% /
/dev/md0 1012M 70M 891M 8% /boot
/dev/mapper/acc-home 20G 313M 19G 2% /home
/dev/mapper/acc-opt 20G 6.2G 13G 33% /opt
/dev/mapper/acc-usr 20G 1.2G 18G 7% /usr
/dev/mapper/acc-var 20G 802M 18G 5% /var
/dev/mapper/acc-tmp 20G 172M 19G 1% /tmp
Machine 7:
root@pve:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/dm-0 95G 74G 16G 83% /
/dev/fuse 30M 16K 30M 1% /etc/pve
Machine 8:
root@barclay:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md1p1 2.6T 77G 2.4T 4% /
/dev/md0 186M 36M 141M 21% /boot
Old question:
Using fdisk -l
i am trying to get the full Sectors value.
Using Debian OS.
fdisk -l will show you alot of info. I am in need of figuring out a way to cut a specific word/number out of it.
Basically, i need the biggest "Sectors" count there is.
For my current machine.
Device Start End Sectors Size Type
/dev/sda1 3072 6143 3072 1.5M BIOS boot
/dev/sda2 6144 506879 500736 244.5M Linux filesystem
/dev/sda3 506880 14064672767 14064165888 6.6T Linux filesystem
(This is also different on my other machines)
Then
fdisk -l | grep Linux | tail -1
Gives me /dev/sda3 506880 14064672767 14064165888 6.6T Linux filesystem
Yet this is not the total that i need. I managed to cut this out on one of my machines, but i was not able to find a way to cut/grep out the "4th from the end"
On my test machine, i managed to this.
fdisk -l | grep Linux | cut -d " " -f3 | tail -1 | awk '{$1=$1/(1024^2); print $1;}' | awk '{print int($1+0.5)}' | awk '{ print $1"GB" }'
/
? what if / is part of a 4 disk volume group ? I'll Vote To Close as "too broad". – Archemar Mar 27 '18 at 13:16cat /proc/partitions/
and it be doing what i need. Sadly, some machines have other drives like md also, so yea – TheSebM8 Mar 28 '18 at 06:33