This chapter describes how to manage disk use. The following task map points to the management tasks you can perform on disks.
|
The command you use to obtain information about the use of disk space on your system depends on the file system. The following sections show how to use the appropriate command for the file system to display data about disk use.
To display information about how ZFS disk space is used, use the zpool command.
# zpool list root-pool
where root-pool is the name of the root pool on the system. The following example provides information about rpool, which has 10.0 Gbytes allocated and 580 Gbytes free.
# zpool list rpool NAME SIZE ALLOC FREE CAP HEALTH ALTROOT rpool 68G 10.0G 58.0G 14% ONLINE -
Use the –r option to compare available space with actually used space in the root pool.
# zfs list -r rpool NAME USED AVAIL REFER MOUNTPOINT rpool 10.2G 56.8G 106K /rpool rpool/ROOT 5.04G 56.8G 31K legacy rpool/ROOT/solaris 5.04G 56.8G 5.04G / rpool/dump 1.00G 56.8G 1.00G - rpool/export 63K 56.8G 32K /export rpool/export/home 31K 56.8G 31K /export/home rpool/swap 4.13G 56.9G 4.00G -
The zpool list and zfs list commands provide more targeted information than the legacy df and du commands for determining your available ZFS storage pool and file system space. With the legacy commands, you cannot easily discern between pool and file system space, nor do the legacy commands account for space that is consumed by descendent file systems or snapshots.
To display information about how UFS disk space is used, use the df command.
$ df / (/dev/dsk/c0t0d0s0 ): 101294 blocks 105480 files /devices (/devices ): 0 blocks 0 files /system/contract (ctfs ): 0 blocks 2147483578 files /proc (proc ): 0 blocks 1871 files /etc/mnttab (mnttab ): 0 blocks 0 files /etc/svc/volatile (swap ): 992704 blocks 16964 files /system/object (objfs ): 0 blocks 2147483530 files
To find out how disk space is used per user, use the quot command.
# quot /ufsfs /dev/rdsk/c3t3d0s0: 21048 root 350 amy 250 rory
To check the size of files and sort them, use the ls command. To find files that exceed a size limit, use the find command. For more information, see the ls(1) and find(1) man pages.
The ls commands displays a list of files in a specific directory. The following ls options are useful for obtaining information about file sizes on the system:
–l – Displays a list of files and directories in long format and shows the sizes in bytes.
–h – Scales file sizes and directory sizes into KB, MB, GB, or TB when the file or directory size is larger than 1024 bytes.
–s – Displays a list of files and directories and shows the sizes in blocks.
For more information, see thels(1) man page.
The following example shows that the acct and sulog files are the two largest files in the /var/adm directory.
$ cd /var/adm $ ls -lh total 78 -rw------- 1 root root 36K Nov 26 15:45 acct -rw------- 1 uucp bin 0 Nov 26 09:25 aculog -rw-r--r-- 1 root root 20K Nov 26 13:55 messages -rw------- 1 root root 22K Nov 26 10:30 sulog
The following example uses the –sh option to indicate the blocks that are used by the files in the first column of the output.
$ ls -sh 25 -rw-r--r-- 1 root root 20K Nov 26 13:55 messages 7 -rw------- 1 root root 36K Nov 26 15:45 acct 24 -rw------- 1 root root 22K Nov 26 10:30 sulog
You can combine the ls command with the sort command to display a directory's files in an ascending or descending order according to a criterion such as file size. For more information, see the sort(1) man page.
The find command enables you to search for files that fit a specific search criteria. For example, to find files that exceed a specific file size, you would use the following command syntax:
$ find directory -size +nnn
where directory specifies the directory that you want to search and –size + nnn provides the desired size in 512-byte blocks.
The following example shows how to find files larger than 400 blocks in the current working directory. The –print option displays the output of the find command.
$ find . -size +400 -print ./Howto/howto.doc ./Howto/howto.doc.backup ./Howto/howtotest.doc ./Routine/routineBackupconcepts.doc ./Routine/routineIntro.doc
To display the size of directories and subdirectories, use the du command and options. Additionally, you can display the amount of disk space used by user accounts on local UFS file systems by using the quot command. For more information, see the du(1) and quot(8) man pages.
The du command has the following syntax:
$ du [options] [directory1 directory2 ...]
The du command options are:
–a – Displays the size of each file and subdirectory, and the total number of blocks that are contained in the specified directory.
–s – Displays the total number of blocks that are contained in the specified directory.
–H – Displays the size of each directory in 1000-byte blocks.
The following example shows the size of /var/adm and its subdirectories.
$ du /var/adm 2 /var/adm/acct/nite 2 /var/adm/acct/sum 8 /var/adm/acct 2 /var/adm/sa 2 /var/adm/sm.bin 258 /var/adm
To compare the sizes of different directories, specify those directories in the command. The following example compares the sizes of the /var/adm and /var/spool/lp directories.
$ du /var/adm /var/spool/lp 2 /var/adm/acct/nite 2 /var/adm/acct/sum 8 /var/adm/acct 2 /var/adm/sa 2 /var/adm/sm.bin 258 /var/adm 4 /var/spool/lp/admins 2 /var/spool/lp/requests/printing.... 4 /var/spool/lp/requests 4 /var/spool/lp/system 2 /var/spool/lp/fifos 24 /var/spool/lp
The following example shows directory sizes in 1024-byte blocks.
$ du -h /usr/share/audio 796K /usr/share/audio/samples/au 797K /usr/share/audio/samples 798K /usr/share/audio