Cum verificam spatiul hard disk-ului din terminal

23 May 2013

Putem gasi pe internet o multime de programe pentru Linux care permit verficarea spatiului utilizat pe hard disk. Cu toatea acestea, Linux are un utilitar foarte puternic numit “df”, care vine de la “disk filesystem”.

Mai concret, “df” este un program dezvoltat pentru linia de comanda, si este folosit pentru a obtine o statistica completa despre spatiul disponibil si ocupat al hard disk-ului.

Tinand minte aceasta comanda, verificarea spatiului de pe hard va deveni o chestie banala. Trebuie doar sa deschideti terminalul si sa tastati comanda “df” urmata de cativa parametri.

Pentru a intelege si mai bine utilizarea instrumentului “df”, am sa va prezint o lista care va cuprinde cateva comenzi in terminal.

1. cum verificam spatiul folosit pe disc de fisierele sistemului

Comanda “df” afiseaza informatii despre numele dispozitivului, blocuri, spatiul total, spatiul folosit, spatiul disponibil si punctele de montare in sistemul de fisiere.

rac@rac-Extensa-5620:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 68767676 25058400 40209328 39% /
none 4 0 4 0% /sys/fs/cgroup
udev 2010520 4 2010516 1% /dev
tmpfs 404008 856 403152 1% /run
none 5120 0 5120 0% /run/lock
none 2020032 1108 2018924 1% /run/shm
none 102400 36 102364 1% /run/user
/dev/sda5 169387040 69906532 90869488 44% /media/rac/

2. afiseaza informatii pentru spatiul utilizat de toate fisierele sistemului

La fel ca mai sus, dar mai ofera cateva informatii despre sistemele de fisiere fictive, impreuna cu tot sistemul de utilizare al discului si memoria utilizata de acestea.

rac@rac-Extensa-5620:~$ df -a
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 68767676 25058356 40209372 39% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
none 4 0 4 0% /sys/fs/cgroup
none 0 0 0 - /sys/fs/fuse/connections
none 0 0 0 - /sys/kernel/debug
none 0 0 0 - /sys/kernel/security
udev 2010520 4 2010516 1% /dev
devpts 0 0 0 - /dev/pts
tmpfs 404008 856 403152 1% /run
none 5120 0 5120 0% /run/lock
none 2020032 1108 2018924 1% /run/shm
none 102400 36 102364 1% /run/user
gvfsd-fuse 0 0 0 - /run/user/rac/gvfs
/dev/sda5 169387040 69906532 90869488 44% /media/rac/

3. afisarea spatiului utilizat pe hard disk in format inteles de catre oameni

Comenzile de mai sus afiseaza informatiile in bytes, ceea ce e este mai greu de inteles de catre cineva. De data aceasta, “df -h” afiseaza spatiul de pe hard disk , si il face foarte usor de citit si inteles de catre oameni.

rac@rac-Extensa-5620:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 66G 24G 39G 39% /
none 4,0K 0 4,0K 0% /sys/fs/cgroup
udev 2,0G 4,0K 2,0G 1% /dev
tmpfs 395M 856K 394M 1% /run
none 5,0M 0 5,0M 0% /run/lock
none 2,0G 1,1M 2,0G 1% /run/shm
none 100M 36K 100M 1% /run/user
/dev/sda5 162G 67G 87G 44% /media/rac/

4. afisare informatii despre /home

Pentru a afisa informatii doar despre sistemul de fisiere /home, intr-un format usor de citit si inteles de catre oameni.

rac@rac-Extensa-5620:~$ df -hT /home
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext4 66G 24G 39G 39% /

5. afisare informatii despre sistemul de fisiere in bytes

rac@rac-Extensa-5620:~$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 68767676 25058552 40209176 39% /
none 4 0 4 0% /sys/fs/cgroup
udev 2010520 4 2010516 1% /dev
tmpfs 404008 856 403152 1% /run
none 5120 0 5120 0% /run/lock
none 2020032 1108 2018924 1% /run/shm
none 102400 36 102364 1% /run/user
/dev/sda5 169387040 69906532 90869488 44% /media/rac/

6. afisarea informatiilor despre sistemul de fisire in MB

rac@rac-Extensa-5620:~$ df -m
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/sda1 67156 24472 39267 39% /
none 1 0 1 0% /sys/fs/cgroup
udev 1964 1 1964 1% /dev
tmpfs 395 1 394 1% /run
none 5 0 5 0% /run/lock
none 1973 2 1972 1% /run/shm
none 100 1 100 1% /run/user
/dev/sda5 165418 68269 88740 44% /media/rac/

7. afisarea informatiilor despre sistemul de fisire in Gb

rac@rac-Extensa-5620:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 66G 24G 39G 39% /
none 4,0K 0 4,0K 0% /sys/fs/cgroup
udev 2,0G 4,0K 2,0G 1% /dev
tmpfs 395M 856K 394M 1% /run
none 5,0M 0 5,0M 0% /run/lock
none 2,0G 1,1M 2,0G 1% /run/shm
none 100M 36K 100M 1% /run/user
/dev/sda5 162G 67G 87G 44% /media/rac/

8. afisarea structurii datelor pentru sistemul de fisiere

Folosind “-i”, vom afisa informatiile despre numarul structurilor de date folosite si procentajul acestora in sistemul de fisiere. [adsense float=”center”]

rac@rac-Extensa-5620:~$ df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 4382720 306956 4075764 8% /
none 505008 1 505007 1% /sys/fs/cgroup
udev 502630 525 502105 1% /dev
tmpfs 505008 477 504531 1% /run
none 505008 3 505005 1% /run/lock
none 505008 8 505000 1% /run/shm
none 505008 21 504987 1% /run/user
/dev/sda5 10764288 22250 10742038 1% /media/rac/

9. afisarea tipului sistemului de fisiere

rac@rac-Extensa-5620:~$ df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda1 ext4 68767676 25058920 40208808 39% /
none tmpfs 4 0 4 0% /sys/fs/cgroup
udev devtmpfs 2010520 4 2010516 1% /dev
tmpfs tmpfs 404008 856 403152 1% /run
none tmpfs 5120 0 5120 0% /run/lock
none tmpfs 2020032 1108 2018924 1% /run/shm
none tmpfs 102400 36 102364 1% /run/user
/dev/sda5 ext4 169387040 69906532 90869488 44% /media/rac/

OBS: se va utiliza “T”, nu “t”.

10. include un anumit tip de sisteme de fisiere

rac@rac-Extensa-5620:~$ df -t ext4
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 68767676 25058896 40208832 39% /
/dev/sda5 169387040 69906532 90869488 44% /media/rac/

11. Exclude un anumit tip de sistem de fisiere

rac@rac-Extensa-5620:~$ df -x ext4
Filesystem 1K-blocks Used Available Use% Mounted on
none 4 0 4 0% /sys/fs/cgroup
udev 2010520 4 2010516 1% /dev
tmpfs 404008 856 403152 1% /run
none 5120 0 5120 0% /run/lock
none 2020032 1108 2018924 1% /run/shm
none 102400 36 102364 1% /run/user

12. afisare informatii despre comanda “df”

Folosind “–help”, se va afisa o lista de optiuni disponibile care sunt folosite cu comanda “df”.

rac@rac-Extensa-5620:~$ df --help
Usage: df [OPTION]... [FILE]...
Show information about the file system on which each FILE resides,
or all file systems by default.
Mandatory arguments to long options are mandatory for short options too.
 -a, --all include dummy file systems
 -B, --block-size=SIZE scale sizes by SIZE before printing them. E.g.,
 '-BM' prints sizes in units of 1,048,576 bytes.
 See SIZE format below.
 --total produce a grand total
 -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
 -H, --si likewise, but use powers of 1000 not 1024
 -i, --inodes list inode information instead of block usage
 -k like --block-size=1K
 -l, --local limit listing to local file systems
 --no-sync do not invoke sync before getting usage info (default)
 -P, --portability use the POSIX output format
 --sync invoke sync before getting usage info
 -t, --type=TYPE limit listing to file systems of type TYPE
 -T, --print-type print file system type
 -x, --exclude-type=TYPE limit listing to file systems not of type TYPE
 -v (ignored)
 --help display this help and exit
 --version output version information and exit
Display values are in units of the first available SIZE from --block-size,
and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).
SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units
are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.