翻译完成

请校对~
This commit is contained in:
tenght 2014-06-22 16:08:14 +08:00
parent d6680f61e8
commit 0c9eb70bed

View File

@ -1,13 +1,14 @@
-------------translating by tenght~
9 commands to check hard disk partitions and disk space on Linux
translated by tenght~
查看Linux硬盘分区和磁盘空间的9个命令
================================================================================
In this post we are taking a look at some commands that can be used to check up the partitions on your system. The commands would check what partitions there are on each disk and other details like the total size, used up space and file system etc.
Commands like fdisk, sfdisk and cfdisk are general partitioning tools that can not only display the partition information, but also modify them.
在这篇文章中,我们将看看用来检查你的系统分区的一些命令,这些命令将检查每个磁盘的分区情况和其他细节,例如总大小,用完的空间和文件系统等。
像fdisksfdisk和cfdisk命令是一般分区工具不仅可以显示分区信息还可以修改。
### 1. fdisk ###
Fdisk is the most commonly used command to check the partitions on a disk. The fdisk command can display the partitions and details like file system type. However it does not report the size of each partitions.
Fdisk是检查磁盘上分区的最常用命令fdisk命令可以显示分区和细节如文件系统类型但是它并不报告每个分区的大小。
$ sudo fdisk -l
@ -36,11 +37,10 @@ Fdisk is the most commonly used command to check the partitions on a disk. The f
Device Boot Start End Blocks Id System
/dev/sdb1 * 2048 7907327 3952640 b W95 FAT32
Each device is reported separately with details about size, seconds, id and individual partitions.
单独显示了每个设备的详细信息大小ID和单个分区。
### 2. sfdisk ###
Sfdisk is another utility with a purpose similar to fdisk, but with more features. It can display the size of each partition in MB.
Sfdisk是另一种跟fdisk目的相似的实用工具但具有更多的功能。它可以以MB为单位显示每个分区的大小。
$ sudo sfdisk -l -uM
@ -75,20 +75,20 @@ Sfdisk is another utility with a purpose similar to fdisk, but with more feature
### 3. cfdisk ###
Cfdisk is a linux partition editor with an interactive user interface based on ncurses. It can be used to list out the existing partitions as well as create or modify them.
Cfdisk是一个基于ncurses提供字符终端处理库包括面板和菜单的带有交互式用户界面的Linux分区编辑器它可以用来列出现有分区以及创建或修改这些分区。
Here is an example of how to use cfdisk to list the partitions.
下面是一个如何使用Cfdisk来列出分区的例子。
![linux cfdisk disk partitions](http://www.binarytides.com/blog/wp-content/uploads/2014/06/linux-cfdisk.png)
Cfdisk works with one partition at a time. So if you need to see the details of a particular disk, then pass the device name to cfdisk.
Cfdisk工作在同一个分区所以如果你需要看某一磁盘的细节可以把设备名传给Cfdisk。
$ sudo cfdisk /dev/sdb
### 4. parted ###
Parted is yet another command line utility to list out partitions and modify them if needed.
Here is an example that lists out the partition details.
Parted是另一个命令行实用程序用来列出分区,如果需要的话,也可进行修改。
下面是一个例子,列出了详细的分区信息。
$ sudo parted -l
Model: ATA ST3500418AS (scsi)
@ -115,9 +115,9 @@ Here is an example that lists out the partition details.
### 5. df ###
Df is not a partitioning utility, but prints out details about only mounted file systems. The list generated by df even includes file systems that are not real disk partitions.
Df是不是一个分区工具但它打印出挂装文件系统的细节Df可以列出甚至不是真实的磁盘分区的文件系统。
Here is a simple example
这里是个简单的例子:
$ df -h
Filesystem Size Used Avail Use% Mounted on
@ -131,16 +131,16 @@ Here is a simple example
/dev/sda8 196G 154G 33G 83% /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1
/dev/sda5 98G 37G 62G 38% /media/4668484A68483B47
Only the file systems that start with a /dev are actual devices or partitions.
文件系统只有以 /dev 开始的,是实际设备或分区。
Use grep to filter out real hard disk partitions/file systems.
使用grep命令来筛选出实际的硬盘分区或文件系统。
$ df -h | grep ^/dev
/dev/sda6 97G 43G 49G 48% /
/dev/sda8 196G 154G 33G 83% /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1
/dev/sda5 98G 37G 62G 38% /media/4668484A68483B47
To display only real disk partitions along with partition type, use df like this
为了只显示真正的磁盘分区与分区类型可以这样使用Df
$ df -h --output=source,fstype,size,used,avail,pcent,target -x tmpfs -x devtmpfs
Filesystem Type Size Used Avail Use% Mounted on
@ -148,11 +148,11 @@ To display only real disk partitions along with partition type, use df like this
/dev/sda8 ext4 196G 154G 33G 83% /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1
/dev/sda5 fuseblk 98G 37G 62G 38% /media/4668484A68483B47
Note that df shows only the mounted file systems or partitions and not all.
请注意Df只显示已挂载的文件系统或分区并不是所有。
### 6. pydf ###
Improved version of df, written in python. Prints out all the hard disk partitions in a easy to read manner.
用Python写的Df的改进版本以一个易于阅读的方式打印出所有磁盘分区。
$ pydf
Filesystem Size Used Avail Use% Mounted on
@ -160,12 +160,13 @@ Improved version of df, written in python. Prints out all the hard disk partitio
/dev/sda8 195G 153G 32G 78.4 [#######..] /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1
/dev/sda5 98G 36G 61G 37.1 [###......] /media/4668484A68483B47
Again, pydf is limited to showing only the mounted file systems.
另外pydf限制为仅显示已挂载的文件系统
### 7. lsblk ###
Lists out all the storage blocks, which includes disk partitions and optical drives. Details include the total size of the partition/block and the mount point if any.
Does not report the used/free disk space on the partitions.
列出了所有的存储块,包括磁盘分区和光盘驱动器。细节包括所有分区/块总大小和挂载点。
不报告分区上的已使用和空闲磁盘空间。
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
@ -180,13 +181,14 @@ Does not report the used/free disk space on the partitions.
└─sdb1 8:17 1 3.8G 0 part
sr0 11:0 1 1024M 0 rom
If there is no MOUNTPOINT, then it means that the file system is not yet mounted. For cd/dvd this means that there is no disk.
Lsblk is capbale of displaying more information about each device like the label and model. Check out the man page for more information
如果没有挂载点这就意味着文件系统未安装对于cd/dvd这意味着没有磁盘。
lsblk能够显示每个设备的更多信息如标签和模型更多请查看信息手册。
### 8. blkid ###
Prints the block device (partitions and storage media) attributes like uuid and file system type. Does not report the space on the partitions.
打印块设备分区和存储介质属性例如UUID和文件系统类型不报告分区空间。
$ sudo blkid
/dev/sda1: UUID="5E38BE8B38BE6227" TYPE="ntfs"
@ -198,7 +200,7 @@ Prints the block device (partitions and storage media) attributes like uuid and
### 9. hwinfo ###
The hwinfo is a general purpose hardware information tool and can be used to print out the disk and partition list. The output however does not print details about each partition like the above commands.
hwinfo是一个通用的硬件信息的工具可以用来打印出磁盘和分区表输出不再像上面的命令那样打印每个分区的详细信息。
$ hwinfo --block --short
disk:
@ -216,17 +218,18 @@ The hwinfo is a general purpose hardware information tool and can be used to pri
/dev/sr0 SONY DVD RW DRU-190A
### Summary ###
### 总结 ###
The output of parted is concise and complete to get an overview of different partitions, file system on them and the total space. Pydf and df are limited to showing only mounted file systems and the same on them.
parted的输出简洁而完整的得到不同分区的概述、上面的文件系统以及总空间。pydf和df被限制为只显示和他们一样的已挂载的文件系统。
Fdisk and Sfdisk show a whole lot of information that can take sometime to interpret whereas, Cfdisk is an interactive partitioning tool that display a single device at a time.
fdisk和sfdisk显示完整的大量的可以花些时间来解释的信息cfdisk是一个互动的分区工具每次显示一个单一的设备。
So try them out, and do not forget to comment below.
来尝试下吧,别忘了在下面评论哟!
--------------------------------------------------------------------------------
via: http://www.binarytides.com/linux-command-check-disk-partitions/
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
译者:[tenght](https://github.com/tenght) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出