Δημοσιεύτηκε: 21 Ιούλ 2009, 13:05
Χωρίς να είμαι σίγουρος, έφτιαξα να δείχνει και τα bytes και gigabytes/gibibytes (ή ό,τι διάολο λένε τα GiB
).
Αποτέλεσμα:
Απ'ό,τι φαίνεται δεν είναι σταθερό 5% (Αλλά έχω ext4 σε όλους, εκτός από το /dev/sda3 το οποίο είναι ext3)
ΔΕ ΦΕΡΩ ΕΥΘΥΝΗ ΓΙΑ ΤΗ ΧΡΗΣΗ ΑΥΤΩΝ ΤΩΝ ΕΝΤΟΛΩΝ!
Χρησιμοποιεί το tune2fs που από πολλούς θεωρείται επικίνδυνο. You have been warned.
- Κώδικας: Επιλογή όλων
#!/bin/bash
for device in `ls -1 /dev/[hs]d??`; do
echo "Partition: $device"
sudo tune2fs -l $device > /dev/null
if [ $? = "0" ]; then
reservedblocksize=`sudo tune2fs -l $device | grep "Reserved block count" | tr -s " " | cut -d " " -f 4`
totalblocksize=`sudo tune2fs -l $device | grep "Block count" | tr -s " " | cut -d " " -f 3`
blocksize=`sudo tune2fs -l $device | grep "Block size" | tr -s " " | cut -d " " -f 3`
totalpartsize=`echo "scale=2; $totalblocksize * $blocksize" | bc`
totalpartsizegib=`echo "scale=2; $totalblocksize * $blocksize / 1024 ^ 3" | bc | sed -e 's/^\./0./'`
echo "Reserved blocks: $reservedblocksize"
echo "Total blocks: $totalblocksize"
echo "Total partition size (bytes): $totalpartsize"
echo "Total partition size (GiB): $totalpartsizegib"
convertpercent=`echo "scale=2; $reservedblocksize / $totalblocksize * 100" | bc`
convertsize=`echo "scale=2; $reservedblocksize * $blocksize"|bc`
convertsizegib=`echo "scale=2; $reservedblocksize * $blocksize / 1024 ^ 3" | bc | sed -e 's/^\./0./'`
echo "Reserved percentage: $convertpercent %"
echo "Reserved size (bytes): $convertsize"
echo "Reserved size (GiB): $convertsizegib"
fi
echo
done
Αποτέλεσμα:
έγραψε:Partition: /dev/sda1
Reserved blocks: 196595
Total blocks: 3931900
Total partition size (bytes): 16105062400
Total partition size (GiB): 14.99
Reserved percentage: 5.00 %
Reserved size (bytes): 805253120
Reserved size (GiB): 0.74
Partition: /dev/sda2
tune2fs: Bad magic number in super-block while trying to open /dev/sda2
Couldn't find valid filesystem superblock.
Partition: /dev/sda3
Reserved blocks: 413091
Total blocks: 13769713
Total partition size (bytes): 56400744448
Total partition size (GiB): 52.52
Reserved percentage: 2.00 %
Reserved size (bytes): 1692020736
Reserved size (GiB): 1.57
Partition: /dev/sdb1
tune2fs: Bad magic number in super-block while trying to open /dev/sdb1
Couldn't find valid filesystem superblock.
Partition: /dev/sdb2
Reserved blocks: 1150575
Total blocks: 57528765
Total partition size (bytes): 235637821440
Total partition size (GiB): 219.45
Reserved percentage: 1.00 %
Reserved size (bytes): 4712755200
Reserved size (GiB): 4.38
Partition: /dev/sdc1
Reserved blocks: 1000447
Total blocks: 20008949
Total partition size (bytes): 81956655104
Total partition size (GiB): 76.32
Reserved percentage: 4.00 %
Reserved size (bytes): 4097830912
Reserved size (GiB): 3.81
Απ'ό,τι φαίνεται δεν είναι σταθερό 5% (Αλλά έχω ext4 σε όλους, εκτός από το /dev/sda3 το οποίο είναι ext3)