I want to check used space for each and every partition in Linux. I am using this command to get size of each partition but not able to get used space or free space.
$ cat /proc/partitions
major minor #blocks name
8 0 16777216 sda
8 1 512000 sda1
8 2 16264192 sda2
253 0 14585856 dm-0
253 1 1675264 dm-1
I am able to get used space using df command, but it shows filesystems and it's not able to get used space for all the partitions like /dev/sda2.
$ df -Tl
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
ext4 14225776 3791704 9704780 29% /
tmpfs tmpfs 961596 72 961524 1% /dev/shm
/dev/sda1 ext4 487652 40187 421865 9% /boot
I want to calculate disk utilization. Is there any way to get used space and total space for each and every partition?
dfexactly? Do you want to see the results for filesystems that are not mounted? Or do you have a filesystem that spawns over multiple devices and you want to check used space for each of them separately (whatever it means)? Or what? – Kamil Maciorowski Sep 04 '17 at 07:00/dev/sda2? Avoid XY problem and improve your question maybe (you may [edit] to add new details). – Kamil Maciorowski Sep 04 '17 at 07:21/dev/sda2is used by LVM to hostdm-0etc. In this context it's 0% free, i.e. you cannot write to it without messing LVM. However you can write to/dev/mapper/VolGroup-lv_rootmounted under/and this data will be stored on/dev/sda2somehow. That's my guess. – Kamil Maciorowski Sep 04 '17 at 08:09pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup lvm2 a--u 15.51g 0
so how can i take used space for /dev/sda2? currently i am taking total space as sda and used space as sda1+sda2. so disk utilization as (sda1+sda2/sda)*100 and i am getting 99.9%.
– Free Aac Sep 04 '17 at 09:02