Ricerca nel sito web

Installa e usa Duf Disk Monitoring Tool su Ubuntu 20.04


Su questa pagina

  1. Prerequisiti
  2. Per iniziare
  3. Installa Duf
  4. Come usare Duf
  5. Conclusione

Duf chiamato anche \Disk Usage Free utility\ è uno strumento gratuito e open-source scritto in Golang. Viene utilizzato per visualizzare l'utilizzo del disco del sistema in un formato tabellare. È un'alternativa al comando df e può essere installato su Linux, BSD, Windows e macOS. Visualizza anche i dettagli sull'utilizzo del disco nell'output JSON.

In questo post, ti mostreremo come monitorare l'utilizzo del disco con l'utilità Duf su Ubuntu 20.04.

Prerequisiti

  • Un server che esegue Ubuntu 20.04.
  • Sul server è configurata una password di root.

Iniziare

Innanzitutto, è sempre consigliabile aggiornare la cache dei pacchetti con l'ultima versione. Puoi farlo con il seguente comando:

apt-get update -y

Al termine, puoi procedere al passaggio successivo.

Installa Duf

Per impostazione predefinita, il pacchetto Duf non è disponibile nel repository predefinito di Ubuntu, quindi dovrai scaricarlo dalla loro pagina di download.

Puoi scaricarlo con il seguente comando:

wget https://github.com/muesli/duf/releases/download/v0.6.2/duf_0.6.2_linux_amd64.deb

Una volta completato il download, installa il file scaricato con il seguente comando:

dpkg -i duf_0.6.2_linux_amd64.deb

Come usare Duf

In questa sezione, ti mostreremo come monitorare l'utilizzo del disco utilizzando l'utilità Duf.

Eseguire l'utilità di comando Duf senza alcuna opzione elencherà tutte le partizioni logiche e i file system:

duf

Dovresti vedere il seguente output:

?????????????????????????????????????????????????????????????????????????????????????????
? 1 local device                                                                        ?
?????????????????????????????????????????????????????????????????????????????????????????
? MOUNTED ON ?  SIZE ? USED ? AVAIL ?              USE%             ? TYPE ? FILESYSTEM ?
?????????????????????????????????????????????????????????????????????????????????????????
? /          ? 49.2G ? 3.2G ? 43.8G ? [#...................]   6.5% ? ext4 ? /dev/sda1  ?
?????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????
? 6 special devices                                                                                 ?
?????????????????????????????????????????????????????????????????????????????????????????????????????
? MOUNTED ON     ?   SIZE ?   USED ?  AVAIL ?              USE%             ? TYPE     ? FILESYSTEM ?
?????????????????????????????????????????????????????????????????????????????????????????????????????
? /dev           ? 980.7M ?     0B ? 980.7M ?                               ? devtmpfs ? udev       ?
? /dev/shm       ? 993.9M ?     0B ? 993.9M ?                               ? tmpfs    ? tmpfs      ?
? /run           ? 198.8M ? 600.0K ? 198.2M ? [....................]   0.3% ? tmpfs    ? tmpfs      ?
? /run/lock      ?   5.0M ?     0B ?   5.0M ?                               ? tmpfs    ? tmpfs      ?
? /run/user/0    ? 198.8M ?     0B ? 198.8M ?                               ? tmpfs    ? tmpfs      ?
? /sys/fs/cgroup ? 993.9M ?     0B ? 993.9M ?                               ? tmpfs    ? tmpfs      ?
?????????????????????????????????????????????????????????????????????????????????????????????????????

Per visualizzare le informazioni sull'utilizzo del disco della directory /etc e /usr, eseguire il seguente comando:

duf /etc /usr

Dovresti vedere il seguente output:

?????????????????????????????????????????????????????????????????????????????????????????
? 2 local devices                                                                       ?
?????????????????????????????????????????????????????????????????????????????????????????
? MOUNTED ON ?  SIZE ? USED ? AVAIL ?              USE%             ? TYPE ? FILESYSTEM ?
?????????????????????????????????????????????????????????????????????????????????????????
? /          ? 49.2G ? 3.2G ? 43.8G ? [#...................]   6.5% ? ext4 ? /dev/sda1  ?
? /          ? 49.2G ? 3.2G ? 43.8G ? [#...................]   6.5% ? ext4 ? /dev/sda1  ?
?????????????????????????????????????????????????????????????????????????????????????????

Per visualizzare le informazioni sui file system pseudo, inaccessibili e duplicati, eseguire il seguente comando:

duf -all

Dovresti vedere il seguente output:

?????????????????????????????????????????????????????????????????????????????????????????
? 1 local device                                                                        ?
?????????????????????????????????????????????????????????????????????????????????????????
? MOUNTED ON ?  SIZE ? USED ? AVAIL ?              USE%             ? TYPE ? FILESYSTEM ?
?????????????????????????????????????????????????????????????????????????????????????????
? /          ? 49.2G ? 3.2G ? 43.8G ? [#...................]   6.5% ? ext4 ? /dev/sda1  ?
?????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
? 33 special devices                                                                                                  ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
? MOUNTED ON                   ?   SIZE ?   USED ?  AVAIL ?              USE%             ? TYPE        ? FILESYSTEM  ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
? /dev                         ? 980.7M ?     0B ? 980.7M ?                               ? devtmpfs    ? udev        ?
? /dev/hugepages               ?     0B ?     0B ?     0B ?                               ? hugetlbfs   ? hugetlbfs   ?
? /dev/mqueue                  ?     0B ?     0B ?     0B ?                               ? mqueue      ? mqueue      ?
? /dev/pts                     ?     0B ?     0B ?     0B ?                               ? devpts      ? devpts      ?
? /dev/shm                     ? 993.9M ?     0B ? 993.9M ?                               ? tmpfs       ? tmpfs       ?
? /proc                        ?     0B ?     0B ?     0B ?                               ? proc        ? proc        ?
? /proc/sys/fs/binfmt_misc     ?     0B ?     0B ?     0B ?                               ? autofs      ? systemd-1   ?
? /proc/sys/fs/binfmt_misc     ?     0B ?     0B ?     0B ?                               ? binfmt_misc ? binfmt_misc ?
? /run                         ? 198.8M ? 600.0K ? 198.2M ? [....................]   0.3% ? tmpfs       ? tmpfs       ?
? /run/lock                    ?   5.0M ?     0B ?   5.0M ?                               ? tmpfs       ? tmpfs       ?
? /run/user/0                  ? 198.8M ?     0B ? 198.8M ?                               ? tmpfs       ? tmpfs       ?
? /sys                         ?     0B ?     0B ?     0B ?                               ? sysfs       ? sysfs       ?
? /sys/fs/bpf                  ?     0B ?     0B ?     0B ?                               ? bpf         ? none        ?
? /sys/fs/cgroup               ? 993.9M ?     0B ? 993.9M ?                               ? tmpfs       ? tmpfs       ?
? /sys/fs/cgroup/blkio         ?     0B ?     0B ?     0B ?                               ? cgroup      ? cgroup      ?
? /sys/fs/cgroup/cpu,cpuacct   ?     0B ?     0B ?     0B ?                               ? cgroup      ? cgroup      ?
? /sys/fs/cgroup/cpuset        ?     0B ?     0B ?     0B ?                               ? cgroup      ? cgroup      ?
? /sys/fs/cgroup/devices       ?     0B ?     0B ?     0B ?                               ? cgroup      ? cgroup      ?
? /sys/fs/cgroup/freezer       ?     0B ?     0B ?     0B ?                               ? cgroup      ? cgroup      ?
? /sys/fs/cgroup/hugetlb       ?     0B ?     0B ?     0B ?                               ? cgroup      ? cgroup      ?
? /sys/fs/cgroup/memory        ?     0B ?     0B ?     0B ?                               ? cgroup      ? cgroup      ?
? /sys/fs/cgroup/net_cls,net_p ?     0B ?     0B ?     0B ?                               ? cgroup      ? cgroup      ?
? rio                          ?        ?        ?        ?                               ?             ?             ?
? /sys/fs/cgroup/perf_event    ?     0B ?     0B ?     0B ?                               ? cgroup      ? cgroup      ?
? /sys/fs/cgroup/pids          ?     0B ?     0B ?     0B ?                               ? cgroup      ? cgroup      ?
? /sys/fs/cgroup/rdma          ?     0B ?     0B ?     0B ?                               ? cgroup      ? cgroup      ?
? /sys/fs/cgroup/systemd       ?     0B ?     0B ?     0B ?                               ? cgroup      ? cgroup      ?
? /sys/fs/cgroup/unified       ?     0B ?     0B ?     0B ?                               ? cgroup2     ? cgroup2     ?
? /sys/fs/fuse/connections     ?     0B ?     0B ?     0B ?                               ? fusectl     ? fusectl     ?
? /sys/fs/pstore               ?     0B ?     0B ?     0B ?                               ? pstore      ? pstore      ?
? /sys/kernel/config           ?     0B ?     0B ?     0B ?                               ? configfs    ? configfs    ?
? /sys/kernel/debug            ?     0B ?     0B ?     0B ?                               ? debugfs     ? debugfs     ?
? /sys/kernel/security         ?     0B ?     0B ?     0B ?                               ? securityfs  ? securityfs  ?
? /sys/kernel/tracing          ?     0B ?     0B ?     0B ?                               ? tracefs     ? tracefs     ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

Per visualizzare l'utilizzo di Inode, eseguire il seguente comando:

duf --inodes

Dovresti vedere il seguente output:

???????????????????????????????????????????????????????????????????????????????????????????????
? 1 local device                                                                              ?
???????????????????????????????????????????????????????????????????????????????????????????????
? MOUNTED ON ?  INODES ?   USED ?   AVAIL ?              USE%             ? TYPE ? FILESYSTEM ?
???????????????????????????????????????????????????????????????????????????????????????????????
? /          ? 3276800 ? 150623 ? 3126177 ? [....................]   4.6% ? ext4 ? /dev/sda1  ?
???????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????
? 6 special devices                                                                               ?
???????????????????????????????????????????????????????????????????????????????????????????????????
? MOUNTED ON     ? INODES ? USED ?  AVAIL ?              USE%             ? TYPE     ? FILESYSTEM ?
???????????????????????????????????????????????????????????????????????????????????????????????????
? /dev           ? 251048 ?  390 ? 250658 ? [....................]   0.2% ? devtmpfs ? udev       ?
? /dev/shm       ? 254428 ?    1 ? 254427 ? [....................]   0.0% ? tmpfs    ? tmpfs      ?
? /run           ? 254428 ?  517 ? 253911 ? [....................]   0.2% ? tmpfs    ? tmpfs      ?
? /run/lock      ? 254428 ?    4 ? 254424 ? [....................]   0.0% ? tmpfs    ? tmpfs      ?
? /run/user/0    ? 254428 ?   12 ? 254416 ? [....................]   0.0% ? tmpfs    ? tmpfs      ?
? /sys/fs/cgroup ? 254428 ?   18 ? 254410 ? [....................]   0.0% ? tmpfs    ? tmpfs      ?
???????????????????????????????????????????????????????????????????????????????????????????????????

Per ordinare l'utilizzo del disco, eseguire il seguente comando:

duf --sort size

Produzione:

?????????????????????????????????????????????????????????????????????????????????????????
? 1 local device                                                                        ?
?????????????????????????????????????????????????????????????????????????????????????????
? MOUNTED ON ?  SIZE ? USED ? AVAIL ?              USE%             ? TYPE ? FILESYSTEM ?
?????????????????????????????????????????????????????????????????????????????????????????
? /          ? 49.2G ? 3.2G ? 43.8G ? [#...................]   6.5% ? ext4 ? /dev/sda1  ?
?????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????
? 6 special devices                                                                                 ?
?????????????????????????????????????????????????????????????????????????????????????????????????????
? MOUNTED ON     ?   SIZE ?   USED ?  AVAIL ?              USE%             ? TYPE     ? FILESYSTEM ?
?????????????????????????????????????????????????????????????????????????????????????????????????????
? /run/lock      ?   5.0M ?     0B ?   5.0M ?                               ? tmpfs    ? tmpfs      ?
? /run/user/0    ? 198.8M ?     0B ? 198.8M ?                               ? tmpfs    ? tmpfs      ?
? /run           ? 198.8M ? 600.0K ? 198.2M ? [....................]   0.3% ? tmpfs    ? tmpfs      ?
? /dev           ? 980.7M ?     0B ? 980.7M ?                               ? devtmpfs ? udev       ?
? /dev/shm       ? 993.9M ?     0B ? 993.9M ?                               ? tmpfs    ? tmpfs      ?
? /sys/fs/cgroup ? 993.9M ?     0B ? 993.9M ?                               ? tmpfs    ? tmpfs

Per visualizzare solo determinate colonne, eseguire il seguente comando:

duf --output mountpoint,size,used,avail,filesystem

Produzione:

??????????????????????????????????????????????????
? 1 local device                                 ?
??????????????????????????????????????????????????
? MOUNTED ON ?  SIZE ? USED ? AVAIL ? FILESYSTEM ?
??????????????????????????????????????????????????
? /          ? 49.2G ? 3.2G ? 43.8G ? /dev/sda1  ?
??????????????????????????????????????????????????
??????????????????????????????????????????????????????????
? 6 special devices                                      ?
??????????????????????????????????????????????????????????
? MOUNTED ON     ?   SIZE ?   USED ?  AVAIL ? FILESYSTEM ?
??????????????????????????????????????????????????????????
? /dev           ? 980.7M ?     0B ? 980.7M ? udev       ?
? /dev/shm       ? 993.9M ?     0B ? 993.9M ? tmpfs      ?
? /run           ? 198.8M ? 600.0K ? 198.2M ? tmpfs      ?
? /run/lock      ?   5.0M ?     0B ?   5.0M ? tmpfs      ?
? /run/user/0    ? 198.8M ?     0B ? 198.8M ? tmpfs      ?
? /sys/fs/cgroup ? 993.9M ?     0B ? 993.9M ? tmpfs      ?
??????????????????????????????????????????????????????????

Per stampare tutte le opzioni disponibili in Duf, esegui il seguente comando:

duf --help

Produzione:

Usage of duf:
  -all
    	include pseudo, duplicate, inaccessible file systems
  -hide string
    	hide specific devices, separated with commas:
    	local, network, fuse, special, loops, binds
  -hide-fs string
    	hide specific filesystems, separated with commas
  -inodes
    	list inode information instead of block usage
  -json
    	output all devices in JSON format
  -only string
    	show only specific devices, separated with commas:
    	local, network, fuse, special, loops, binds
  -only-fs string
    	only specific filesystems, separated with commas
  -output string
    	output fields: mountpoint, size, used, avail, usage, inodes, inodes_used, inodes_avail, inodes_usage, type, filesystem
  -sort string
    	sort output by: mountpoint, size, used, avail, usage, inodes, inodes_used, inodes_avail, inodes_usage, type, filesystem (default "mountpoint")
  -style string
    	style: unicode, ascii (default "unicode")
  -theme string
    	color themes: dark, light (default "dark")
  -version
    	display version
  -warnings
    	output all warnings to STDERR
  -width uint
    	max output width

Conclusione

Nella guida sopra, hai imparato come monitorare l'utilizzo del disco con Duf in Ubuntu 20.04. Spero che questo strumento ti aiuti a monitorare l'utilizzo del disco del tuo sistema in un layout bello e intuitivo.