Linux disk and file system management

Source: Internet
Author: User
Tags what file system disk usage

DF

DF (disk free)

function Description:Displays information about the disk.
Syntax:DF [-ahhiklmpt][--block-size=< Chunk Size >][-t < file system Type >][-x < file system type >][--help][--no-sync][--sync][-- version][file or device]
Additional notes:DF Displays the disk's file system and usage scenarios.
Parameters:
-A or--all contains all file systems.
--block-size=< Chunk Size > Displays the number of chunks in the specified chunk size.
-H or--human-readable displays information in a more readable way.
-H or--si is the same as the-h parameter, but is calculated as Bytes instead of the Bytes.
-I or--inodes displays the inode information.
-K or--kilobytes specifies a chunk size of 1024 bytes.
-L or--local displays only the file system on the local side.
-M or--megabytes specifies a chunk size of 1048576 bytes.
--no-sync do not perform the sync instruction until you obtain the disk usage information, which is a preset value.
-P or--portability uses the POSIX output format.
--sync perform the sync instructions before obtaining the disk usage information.
-t< file System type > or--type=< file system type > displays only disk information for the specified file system type.
-T or--print-type displays the file system type.
-x< file System type > or--exclude-type=< file system type > do not display disk information for the specified file system type.
--help display Help.
--version Displays version information.
[File or device] specifies the disk device.

du

Du (disk usage)

function Description:Displays the size of the directory or file.
Syntax:Du [-abcdhhklmssx][-l < symbolic connections >][-x < files >][--block-size][--exclude=< directories or files >][--max-depth=< directory tiers >][--help][--version][directory or file]
Additional notes:DU displays the disk space occupied by the specified directory or file.
Parameters:
-A or-all displays the size of individual files in the directory.
-B or-bytes displays the directory or file size, in bytes.
-C or--total displays the sum of all directories or files in addition to the size of individual directories or files.
-D or--dereference-args displays the source file size for the specified symbolic connection.
-H or--human-readable in k,m,g to improve the readability of the information.
-H or--si is the same as the-h parameter, but the k,m,g is converted to 1000 units.
-K or--kilobytes in bytes units.
-L or--count-links repeatedly compute the files for the hardware connection.
-l< symbol connection > or--dereference< symbol connection > Display option the source file size of the symbol connection specified.
-M or--megabytes in 1MB units.
-S or--summarize displays totals only.
-S or--separate-dirs displays the size of individual directories without the size of their subdirectories.
-X or--one-file-xystem the file system at the beginning of the processing, if any other different file system directories are skipped.
-x< file > or--exclude-from=< file > in < file > specify directory or file.
--exclude=< directory or File > skip the specified directory or file.
--max-depth=< the number of directory layers > directories that exceed the specified number of layers is ignored.
--help display Help.
--version Displays version information.

LN

ln (link)

Function Description: connection file or directory.
Syntax: LN [-bdfinsv][-s < tail backup string >][-v < backup method >][--help][--version][source file or directory] [destination file or directory] or ln [-BDFINSV] [-s < end-of-word backup string;] [-v < backup mode;] [--help] [--version] [Source file or directory ...] [Destination Directory]
Supplemental Note: The ln directive is used to connect files or directories, such as specifying more than two files or directories at the same time, and the final destination is a directory that already exists, and all the previously specified files or directories are copied to the directory. If you specify multiple files or directories at the same time, and the final destination is not an existing directory, an error message appears.
Parameter:
-B or--backup  Delete, overwriting the backup before the destination file.
-D or-F or--directory  to establish a hard connection to the directory.
-F or--force  forcibly establish a connection to a file or directory, regardless of whether the file or directory exists.
-I or--interactive  overwrites existing files before asking the user first.
-N or--no-dereference  treats the destination directory of the symbolic connection as a generic file.
-S or--symbolic  creates a symbolic connection to the source file, not a hard connection.
-s< Tail Backup string > or--suffix=< Tail backup string >  after backing up the destination file with the "-B" parameter, a backup string is added to the end of the backup file, and the default tail-back string is the symbol "~", which you can pass "-s "Parameter to change it.
-V or--verbose  displays the instruction execution process.
-v< Backup method > or--version-control=< backup method >  after backing up the target file with the "-B" parameter, the tail of the backup file is added with a backup string that can be changed not only with the "-S" parameter, when using the The "-V" parameter < backup method > Specify a different backup method will also produce a different tail of the backup string.
--help  online Help. The
--version  displays the version information.

fdisk

Fdisk

Feature Description: disk partition.
syntax:fdisk [-b < partition size >][-uv][Peripheral code] or Fdisk [-l][-b < partition size >][-uv][peripheral device designator ...] or Fdisk [-s < partition number;]
add:fdisk is a disk partition program, it uses the traditional question-and-answer interface, rather than DOS Fdisk-like Cfdisk interactive interface, it is inconvenient to use, but the function is not compromised.
Parameters
-b< Partition Size > Specify the size of each partition.
-l lists the partition table status for the specified peripheral device.
-s< partition number > outputs the specified partition size to the standard output, in chunks.
-U is paired with the "-L" parameter list, which replaces the number of cylinders with the number of partitions to represent the starting address of each partition.
-V Displays version information.

MKFS

MKFS (make file system)

function Description: set up various file systems.
syntax:mkfs [-vv][fs][-f < file system type >][device name] [number of blocks]
Note:MKFS itself does not perform the work of establishing a file system, but instead calls the relevant program to execute it.
Parameters
FS Specifies the parameters when the file system is established.
-t< File System type > Specifies what file system to build.
-V Displays version information with detailed usage methods.
-V shows a brief use of the method.

Mkswap

function Description: set the swap area.
syntax:mkswap [-cf][-v0][-v1][device name or file] [swap size]
Additional Note:Mkswap can set the disk partition or file as the swap area for Linux.
Parameters
-C before establishing the swap area, first check if there is a damaged block.
-F Add this parameter when establishing a swap on a SPARC computer.
-v0 establishes the old swap area, which is a preset value.
-v1 set up a new exchange zone.
[Swap size] Specifies the size of the swap area, in 1024 bytes.

Swapon

function Description: start the system swap area (swap areas).
syntax:swapon [-ahsv][-p < prioritization >][Devices]
Additional notes: The memory management of Linux systems must use swap zones to establish virtual memory.
-A converts all devices that are set to swap in the/etc/fstab file, starting as swap areas.
-h displays Help.
-p< Precedence > Specify the priority order of the swap area.
-S displays the usage status of the swap area.
-V Displays version information.

Swapoff

function Description: turn off the system swap zone (swap area).
syntax:swapoff [Device]
Supplemental Note:Swapoff is actually a symbolic connection to swapon that can be used to turn off the swap area of the system.

MKE2FS

MKE2FS (make ext2 file system)

function Description:Establish the Ext2 file system.
Syntax:MKE2FS [-cfmqrsvv][-b < chunk size >][-f < discontinuous segment size >][-i < bytes >][-n <inode number >][-l < file >][-l < tags >][-m < percent value >][-R=< number of blocks >][device name [number of blocks]
Additional notes:MKE2FS can build a Linux ext2 file system.
Parameters:
-b< Chunk Size > Specify chunk size in bytes.
-C Check if there are any damaged chunks.
-f< Discontinuous Segment Size > Specifies the size of the discontinuous segment, in bytes.
-F enforces mke2fs regardless of the specified device.
-i< bytes > Specifies the scale of "byte/inode".
-n<inode number > Specifies the number of inode to be established.
-l< File > read information about corrupted chunks in file west from the specified file.
-l< label > Set the label name of the file system.
-m< percent value > specifies the ratio of reserved chunks to administrators, which is preset to 5%.
-M Records the last directory that was mounted.
-Q does not display any information when executing.
-r Specifies the version of the Ext2 file system to be established.
-r=< number of blocks > set disk array parameters.
-S writes only Superblock and group descriptors without changing the inode able Inode bitmap and block bitmap.
-V displays detailed information when executing.
-V Displays version information.

fsck

Fsck (file system check)

Feature Description: check the file system and try to fix the error.
syntax:fsck [-aanprrstv][-t < file system type >][file system ...]
Additional note: when the file system error four modernizations, the fsck command can be used to try to repair.
Parameters
-A automatically repairs the file system without asking any questions.
-A according to the contents of the/etc/fstab configuration file, check all the file systems listed in the file.
-N does not execute instructions, only the actions performed by the actual execution are listed.
-p when used with the "-A" parameter, all file systems are checked at the same time.
-R uses interactive mode to ask questions when performing a fix, allowing the user to confirm and decide how to handle it.
-R when used with the "-A" parameter, the file system that is skipped/directory is not checked.
-S executes the check job sequentially instead of concurrently.
-t< File System type > Specifies the type of file system to check.
-T displays header information when the fsck instruction is executed.
-V Displays the instruction execution process.

Badblocks

function Description: Check the damaged block in the disk device.
syntax:badblocks [-svw][-b < chunk size >][-o < output file >][disk device] [number of disk blocks] [start chunk]
Note: when executing the instruction, you must specify the disk device to be inspected and the number of disk blocks for this device.
Parameters
-b< Chunk Size > Specify the chunk size of the disk in bytes.
-o< output File > Writes the result of the check to the specified output file.
-S shows progress while checking.
-V displays detailed information when executed.
-W performs a write test when checking.
[Disk device] Specifies the disk device to check.
[Number of disk blocks] Specifies the total number of blocks for the disk appliance.
[Start Block] Specifies the block from which to start the check.

Mount

Name: mount
Usage rights: User allowed in System Manager or/etc/fstab
How to use:
Mount [-HV]
mount-a [-FFNRSVW] [-t Vfstype]
Mount [-FNRSVW] [-O options [,...]] device | Dir
Mount [-FNRSVW] [-t vfstype] [-O options] Device dir

Description:
Interpret the contents of a file as a file system, and then hang it on top of a directory. When this command executes successfully, until we use Umnount to remove the file system, all files under this command will not be invoked for the time being.
This command can be used to hang up any file system, you can even use the-o loop option to a general file as a hard disk to split the system. This feature is useful for interpreting ramdisk,romdisk or ISO 9660 image files.
Parameters
-V
Show Program version
-H
Show auxiliary messages
-V
Show more messages, usually and-F for debugging.
-A
Hang all the file systems defined in the/etc/fstab.
-F
This command is usually used with-a, which generates a stroke for each mount action. You can speed up the action of hanging when the system needs to hang a large number of NFS file systems.
-F
Usually used in the use of debugging. It makes mount not perform the actual hanging action, but rather simulates the entire hanging process. It is usually used with-V.
-N
In general, Mount hangs on the/etc/mtab to write a piece of information. However, this option can be used to cancel this action if there is no writable file system in the system.
-s-r
equals-o ro
-W
Equals-o RW
-L
Split the hard drive with a specific label on it.
-U
The file system that divides the files into serial numbers is hung. The-L and-u must be meaningful when the/proc/partition file is present.
-T
Specifies the type of the file system, which is usually not required. Mount will automatically select the correct form.
-O Async
Open non-synchronous mode, all the file read and write actions will be performed in the asynchronous mode.
-O Sync
Executes in synchronous mode.
-O Atime
-O Noatime
When Atime is turned on, the "Last Call time" of the archive is updated each time the file is read. When we use the Flash file system, we may turn this option off to reduce the number of writes.
-O Auto
-O Noauto
Turn on/off auto-hang mode.
-O Defaults
Use preset options for RW, suid, dev, exec, auto, Nouser, and async.
-O Dev
-O nodev-o exec
-O noexec
Allows execution of the file to be executed.
-O suid
-O Nosuid
Allows execution of the file under root authority.
-O User
-O Nouser
The user can perform mount/umount actions.
-O remount
Put an already hung file system back in a different way. For example, a system that was originally read-only, is now re-hung in a read-write mode.
-O ro
Hang up in read-only mode.
-O RW
Use the read-write mode to hang up.
-O loop=
Use loop mode to mount a file as a hard disk partition system.
Example
Hang the/dev/hda1 under/mnt.
#mount/dev/hda1/mnt
Hang the/dev/hda1 under/mnt with read-only mode.
#mount-O ro/dev/hda1/mnt
Use the loop mode to hang the image file of the/tmp/image.iso disc under/mnt/cdrom. In this way, the Linux CD ISO file that can be found on the general network can be viewed without being burned into a disc.
#mount-O Loop/tmp/image.iso/mnt/cdrom
Related Commands Umount

Umount

Feature Description: dismount the file system.
syntax:umount [-ahnrvv][-t < file system type >][file system]
Additional Note:Umount can dismount the file system currently hanging in the Linux directory.
Parameters
-a removes all file systems recorded in the/etc/mtab.
-h displays Help.
-N Remove the information from the/etc/mtab file.
-R If it fails to dismount successfully, try to mount the file system again in read-only mode.
-t< file System type > Remove only the file system specified in the option.
-V displays detailed information when executed.
-V Displays version information.
[File system] In addition to directly specifying the file system, you can also use the device name or mount point to represent the file system.

Linux disk and file system management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.