检查磁盘空间使用量
Linux 磁盘管理好坏直接关系到整个系统的性能问题。
Linux 磁盘管理常用三个命令为 df、du 和 fdisk。
- df(英文全称:disk free):列出文件系统的整体磁盘使用量
- du(英文全称:disk used):检查磁盘空间使用量
- fdisk:用于磁盘分区
df
df命令参数功能:检查文件系统的磁盘空间占用情况。可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信息。
语法:
df [-ahikHTm] [目录或文件名]
选项与参数:
-
-h:以人类可读的方式显示输出结果(例如,使用 KB、MB、GB 等单位)。 -
-T:显示文件系统的类型。 -
-t <文件系统类型>:只显示指定类型的文件系统。 -
-i:显示 inode 使用情况。 -
-H:该参数是-h的变体,但是使用 1000 字节作为基本单位而不是 1024 字节。这意味着它会以 SI(国际单位制)单位(例如 MB、GB)而不是二进制单位(例如 MiB、GiB)来显示磁盘使用情况。 -
-k:这个选项会以 KB 作为单位显示磁盘空间使用情况。 -
-a:该参数将显示所有的文件系统,包括虚拟文件系统,例如proc、sysfs等。如果没有使用该选项,默认情况下,df命令不会显示虚拟文件系统。
实例 1
将系统内所有的文件系统列出来!
[root@www ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/hdc2 9920624 3823112 5585444 41% / /dev/hdc3 4956316 141376 4559108 4% /home /dev/hdc1 101086 11126 84741 12% /boot tmpfs 371332 0 371332 0% /dev/shm
在 Linux 底下如果 df 没有加任何选项,那么默认会将系统内所有的 (不含特殊内存内的文件系统与 swap) 都以 1 Kbytes 的容量来列出来!
实例 2
将容量结果以易读的容量格式显示出来
[root@www ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/hdc2 9.5G 3.7G 5.4G 41% / /dev/hdc3 4.8G 139M 4.4G 4% /home /dev/hdc1 99M 11M 83M 12% /boot tmpfs 363M 0 363M 0% /dev/shm
实例 3
将系统内的所有特殊文件格式及名称都列出来
[root@www ~]# df -aT Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/hdc2 ext3 9920624 3823112 5585444 41% / proc proc 0 0 0 - /proc sysfs sysfs 0 0 0 - /sys devpts devpts 0 0 0 - /dev/pts /dev/hdc3 ext3 4956316 141376 4559108 4% /home /dev/hdc1 ext3 101086 11126 84741 12% /boot tmpfs tmpfs 371332 0 371332 0% /dev/shm none binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc sunrpc rpc_pipefs 0 0 0 - /var/lib/nfs/rpc_pipefs
实例 4
将 /etc 底下的可用的磁盘容量以易读的容量格式显示
[root@www ~]# df -h /etc Filesystem Size Used Avail Use% Mounted on /dev/hdc2 9.5G 3.7G 5.4G 41% /
du
Linux du 命令也是查看使用空间的,但是与 df 命令不同的是 Linux du 命令是对文件和目录磁盘使用的空间的查看,还是和df命令有一些区别的,这里介绍 Linux du 命令。
语法:
du [-ahskm] 文件或目录名称
选项与参数:
- -a :列出所有的文件与目录容量,因为默认仅统计目录底下的文件量而已。
- -h :以人们较易读的容量格式 (G/M) 显示;
- -s :仅显示指定目录或文件的总大小,而不显示其子目录的大小。
- -S :包括子目录下的总计,与 -s 有点差别。
- -k :以 KBytes 列出容量显示;
- -m :以 MBytes 列出容量显示;
实例 1
只列出当前目录下的所有文件夹容量(包括隐藏文件夹):
[root@www ~]# du 8 ./test4 <==每个目录都会列出来 8 ./test2 ....中间省略.... 12 ./.gconfd <==包括隐藏文件的目录 220 . <==这个目录(.)所占用的总量
直接输入 du 没有加任何选项时,则 du 会分析当前所在目录里的子目录所占用的硬盘空间。
实例 2
将文件的容量也列出来
[root@www ~]# du -a 12 ./install.log.syslog <==有文件的列表了 8 ./.bash_logout 8 ./test4 8 ./test2 ....中间省略.... 12 ./.gconfd 220 .
实例 3
检查根目录底下每个目录所占用的容量
[root@www ~]# du -sm /* 7 /bin 6 /boot .....中间省略.... 0 /proc .....中间省略.... 1 /tmp 3859 /usr <==系统初期最大就是他了啦! 77 /var
通配符 * 来代表每个目录。
与 df 不一样的是,du 这个命令其实会直接到文件系统内去搜寻所有的文件数据。
fdisk
fdisk 是 Linux 的磁盘分区表操作工具。
语法:
fdisk [-l] 装置名称
选项与参数:
- -l :输出后面接的装置所有的分区内容。若仅有 fdisk -l 时, 则系统将会把整个系统内能够搜寻到的装置的分区均列出来。
实例 1
列出所有分区信息
[root@AY120919111755c246621 tmp]# fdisk -l
Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 2550 20480000 83 Linux
/dev/xvda2 2550 2611 490496 82 Linux swap / Solaris
Disk /dev/xvdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x56f40944
Device Boot Start End Blocks Id System
/dev/xvdb2 1 2610 20964793+ 83 Linux
实例 2
找出你系统中的根目录所在磁盘,并查阅该硬盘内的相关信息
[root@www ~]# df / <==注意:重点在找出磁盘文件名而已 Filesystem 1K-blocks Used Available Use% Mounted on /dev/hdc2 9920624 3823168 5585388 41% / [root@www ~]# fdisk /dev/hdc <==仔细看,不要加上数字喔! The number of cylinders for this disk is set to 5005. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): <==等待你的输入!
输入 m 后,就会看到底下这些命令介绍
Command (m for help): m <== 输入 m 后,就会看到底下这些命令介绍 Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition <==删除一个partition l list known partition types m print this menu n add a new partition <==新增一个partition o create a new empty DOS partition table p print the partition table <==在屏幕上显示分割表 q quit without saving changes <==不储存离开fdisk程序 s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit <==将刚刚的动作写入分割表 x extra functionality (experts only)
离开 fdisk 时按下 q,那么所有的动作都不会生效!相反的, 按下w就是动作生效的意思。
Command (m for help): p <== 这里可以输出目前磁盘的状态 Disk /dev/hdc: 41.1 GB, 41174138880 bytes <==这个磁盘的文件名与容量 255 heads, 63 sectors/track, 5005 cylinders <==磁头、扇区与磁柱大小 Units = cylinders of 16065 * 512 = 8225280 bytes <==每个磁柱的大小 https://avg.163.com/topic/detail/10014913 https://avg.163.com/topic/detail/10014911 https://avg.163.com/topic/detail/10014912 https://avg.163.com/topic/detail/10014909 https://avg.163.com/topic/detail/10014910 https://avg.163.com/topic/detail/10014907 https://avg.163.com/topic/detail/10014908 https://avg.163.com/topic/detail/10014906 https://avg.163.com/topic/detail/10014905 https://avg.163.com/topic/detail/10014904 https://avg.163.com/topic/detail/10014903 https://avg.163.com/topic/detail/10014901 https://avg.163.com/topic/detail/10014902 https://avg.163.com/topic/detail/10014899 https://avg.163.com/topic/detail/10014900 https://avg.163.com/topic/detail/10014898 https://avg.163.com/topic/detail/10014897 https://avg.163.com/topic/detail/10014896 https://avg.163.com/topic/detail/10014895 https://avg.163.com/topic/detail/10014854 https://avg.163.com/topic/detail/10014894 https://avg.163.com/topic/detail/10014893 https://avg.163.com/topic/detail/10014892 https://avg.163.com/topic/detail/10014891 https://avg.163.com/topic/detail/10014889 https://avg.163.com/topic/detail/10014888 https://avg.163.com/topic/detail/10014887 https://avg.163.com/topic/detail/10014886 https://avg.163.com/topic/detail/10014885 https://avg.163.com/topic/detail/10014884 https://avg.163.com/topic/detail/10014882 https://avg.163.com/topic/detail/10014881 https://avg.163.com/topic/detail/10014880 https://avg.163.com/topic/detail/10014879 https://avg.163.com/topic/detail/10014878 https://avg.163.com/topic/detail/10014877 https://avg.163.com/topic/detail/10014876 https://avg.163.com/topic/detail/10014875 https://avg.163.com/topic/detail/10014874 https://avg.163.com/topic/detail/10014873 https://avg.163.com/topic/detail/10014872 https://avg.163.com/topic/detail/10014871 https://avg.163.com/topic/detail/10014870 https://avg.163.com/topic/detail/10014869 https://avg.163.com/topic/detail/10014868 https://avg.163.com/topic/detail/10014867 https://avg.163.com/topic/detail/10014832 https://avg.163.com/topic/detail/10014866 https://avg.163.com/topic/detail/10014865 https://avg.163.com/topic/detail/10014864 https://avg.163.com/topic/detail/10014863 https://avg.163.com/topic/detail/10014862 https://avg.163.com/topic/detail/10014861 https://avg.163.com/topic/detail/10014860 https://avg.163.com/topic/detail/10014859 https://avg.163.com/topic/detail/10014858 https://avg.163.com/topic/detail/10014857 https://avg.163.com/topic/detail/10014856 https://avg.163.com/topic/detail/10014855 https://avg.163.com/topic/detail/10014854 https://avg.163.com/topic/detail/10014853 https://avg.163.com/topic/detail/10014852 https://avg.163.com/topic/detail/10014851 https://avg.163.com/topic/detail/10014849 https://avg.163.com/topic/detail/10014850 https://avg.163.com/topic/detail/10014848 https://avg.163.com/topic/detail/10014846 https://avg.163.com/topic/detail/10014847 https://avg.163.com/topic/detail/10014845 https://avg.163.com/topic/detail/10014843 https://avg.163.com/topic/detail/10014844 https://avg.163.com/topic/detail/10014842 https://avg.163.com/topic/detail/10014841 https://avg.163.com/topic/detail/10014840 https://avg.163.com/topic/detail/10014839 https://avg.163.com/topic/detail/10014838 https://avg.163.com/topic/detail/10014801 https://avg.163.com/topic/detail/10014837 https://avg.163.com/topic/detail/10014836 https://avg.163.com/topic/detail/10014834 https://avg.163.com/topic/detail/10014833 https://avg.163.com/topic/detail/10014828 https://avg.163.com/topic/detail/10014830 https://avg.163.com/topic/detail/10014831 https://avg.163.com/topic/detail/10014832 https://avg.163.com/topic/detail/10014829 https://avg.163.com/topic/detail/10014827 https://avg.163.com/topic/detail/10014826 https://avg.163.com/topic/detail/10014757 https://avg.163.com/topic/detail/10014824 https://avg.163.com/topic/detail/10014825 https://avg.163.com/topic/detail/10014822 https://avg.163.com/topic/detail/10014823 https://avg.163.com/topic/detail/10014821 https://avg.163.com/topic/detail/10014820 https://avg.163.com/topic/detail/10014819 https://avg.163.com/topic/detail/10014818 https://avg.163.com/topic/detail/10014817 https://avg.163.com/topic/detail/10014816 https://avg.163.com/topic/detail/10014814 https://avg.163.com/topic/detail/10014815 https://avg.163.com/topic/detail/10014813 https://avg.163.com/topic/detail/10014812 https://avg.163.com/topic/detail/10014810 https://avg.163.com/topic/detail/10014809 https://avg.163.com/topic/detail/10014808 https://avg.163.com/topic/detail/10014807 https://avg.163.com/topic/detail/10014806 https://avg.163.com/topic/detail/10014805 https://avg.163.com/topic/detail/10014804 https://avg.163.com/topic/detail/10014803 https://avg.163.com/topic/detail/10014784 https://avg.163.com/topic/detail/10014802 https://avg.163.com/topic/detail/10014801 https://avg.163.com/topic/detail/10014799 https://avg.163.com/topic/detail/10014800 https://avg.163.com/topic/detail/10014774 https://avg.163.com/topic/detail/10014798 https://avg.163.com/topic/detail/10014757 https://avg.163.com/topic/detail/10014797 https://avg.163.com/topic/detail/10014796 https://avg.163.com/topic/detail/10014795 https://avg.163.com/topic/detail/10014794 https://avg.163.com/topic/detail/10014793 https://avg.163.com/topic/detail/10014791 https://avg.163.com/topic/detail/10014792 https://avg.163.com/topic/detail/10014790 https://avg.163.com/topic/detail/10014789 https://avg.163.com/topic/detail/10014788 https://avg.163.com/topic/detail/10014787 https://avg.163.com/topic/detail/10014780 https://avg.163.com/topic/detail/10014781 https://avg.163.com/topic/detail/10014785 https://avg.163.com/topic/detail/10014786 https://avg.163.com/topic/detail/10014784 https://avg.163.com/topic/detail/10014782 https://avg.163.com/topic/detail/10014739 https://avg.163.com/topic/detail/10014772 https://avg.163.com/topic/detail/10014779 https://avg.163.com/topic/detail/10014778 https://avg.163.com/topic/detail/10014776 https://avg.163.com/topic/detail/10014777 https://avg.163.com/topic/detail/10014775 https://avg.163.com/topic/detail/10014774 https://avg.163.com/topic/detail/10014773 https://avg.163.com/topic/detail/10014772 https://avg.163.com/topic/detail/10014771 https://avg.163.com/topic/detail/10014770 https://avg.163.com/topic/detail/10014769 https://avg.163.com/topic/detail/10014766 https://avg.163.com/topic/detail/10014768 https://avg.163.com/topic/detail/10014767 https://avg.163.com/topic/detail/10014764 https://avg.163.com/topic/detail/10014765 https://avg.163.com/topic/detail/10014763 https://avg.163.com/topic/detail/10014762 https://avg.163.com/topic/detail/10014761 https://avg.163.com/topic/detail/10014759 https://avg.163.com/topic/detail/10014760 https://avg.163.com/topic/detail/10014757 https://avg.163.com/topic/detail/10014758 https://avg.163.com/topic/detail/10014740 https://avg.163.com/topic/detail/10014756 https://avg.163.com/topic/detail/10014753 https://avg.163.com/topic/detail/10014754 https://avg.163.com/topic/detail/10014755 https://avg.163.com/topic/detail/10014744 https://avg.163.com/topic/detail/10014752 https://avg.163.com/topic/detail/10014751 https://avg.163.com/topic/detail/10014749 https://avg.163.com/topic/detail/10014745 https://avg.163.com/topic/detail/10014747 https://avg.163.com/topic/detail/10014746 https://avg.163.com/topic/detail/10014743 https://avg.163.com/topic/detail/10014742 https://avg.163.com/topic/detail/10014741 https://avg.163.com/topic/detail/10014739 https://avg.163.com/topic/detail/10014738 https://avg.163.com/topic/detail/10014737 https://avg.163.com/topic/detail/10014736 https://avg.163.com/topic/detail/10014734 https://avg.163.com/topic/detail/10014733 https://avg.163.com/topic/detail/10014732 https://avg.163.com/topic/detail/10014731 https://avg.163.com/topic/detail/10014730 https://avg.163.com/topic/detail/10014729 https://avg.163.com/topic/detail/10014728 https://avg.163.com/topic/detail/10014726 https://avg.163.com/topic/detail/10014727 https://avg.163.com/topic/detail/10014725 https://avg.163.com/topic/detail/10014724 https://avg.163.com/topic/detail/10014723 https://avg.163.com/topic/detail/10014722 https://avg.163.com/topic/detail/10014718 https://avg.163.com/topic/detail/10014721 https://avg.163.com/topic/detail/10014720 https://avg.163.com/topic/detail/10014719 https://avg.163.com/topic/detail/10014717 https://avg.163.com/topic/detail/10014716 https://avg.163.com/topic/detail/10014715 https://avg.163.com/topic/detail/10014714 https://avg.163.com/topic/detail/10014711 https://avg.163.com/topic/detail/10014712 https://avg.163.com/topic/detail/10014713 https://avg.163.com/topic/detail/10014710 https://avg.163.com/topic/detail/10014709 https://avg.163.com/topic/detail/10014699 https://avg.163.com/topic/detail/10014707 https://avg.163.com/topic/detail/10014708 https://avg.163.com/topic/detail/10014705 https://avg.163.com/topic/detail/10014701 https://avg.163.com/topic/detail/10014706 https://avg.163.com/topic/detail/10014704 https://avg.163.com/topic/detail/10014702 https://avg.163.com/topic/detail/10014703 https://avg.163.com/topic/detail/10014700 https://avg.163.com/topic/detail/10014661 https://avg.163.com/topic/detail/10014698 https://avg.163.com/topic/detail/10014697 https://avg.163.com/topic/detail/10014658 https://avg.163.com/topic/detail/10014696 https://avg.163.com/topic/detail/10014695 https://avg.163.com/topic/detail/10014694 https://avg.163.com/topic/detail/10014691 https://avg.163.com/topic/detail/10014690 https://avg.163.com/topic/detail/10014689 https://avg.163.com/topic/detail/10014688 https://avg.163.com/topic/detail/10014687 https://avg.163.com/topic/detail/10014686 https://avg.163.com/topic/detail/10014682 https://avg.163.com/topic/detail/10014684 https://avg.163.com/topic/detail/10014681 https://avg.163.com/topic/detail/10014683 https://avg.163.com/topic/detail/10014679 https://avg.163.com/topic/detail/10014677 https://avg.163.com/topic/detail/10014676 https://avg.163.com/topic/detail/10014675 https://avg.163.com/topic/detail/10014674 https://avg.163.com/topic/detail/10014673 https://avg.163.com/topic/detail/10014672 https://avg.163.com/topic/detail/10014671 https://avg.163.com/topic/detail/10014670 https://avg.163.com/topic/detail/10014669 https://avg.163.com/topic/detail/10014668 https://avg.163.com/topic/detail/10014667 https://avg.163.com/topic/detail/10014665 https://avg.163.com/topic/detail/10014666 https://avg.163.com/topic/detail/10014664 https://avg.163.com/topic/detail/10014663 https://avg.163.com/topic/detail/10014662 https://avg.163.com/topic/detail/10014661 https://avg.163.com/topic/detail/10014660 https://avg.163.com/topic/detail/10014659 https://avg.163.com/topic/detail/10014658 https://avg.163.com/topic/detail/10014657 https://avg.163.com/topic/detail/10014656 https://avg.163.com/topic/detail/10014655 https://avg.163.com/topic/detail/10014654 https://avg.163.com/topic/detail/10014653 https://avg.163.com/topic/detail/10014652 https://avg.163.com/topic/detail/10014651 https://avg.163.com/topic/detail/10014650 https://avg.163.com/topic/detail/10014649 https://avg.163.com/topic/detail/10014646 https://avg.163.com/topic/detail/10014648 https://avg.163.com/topic/detail/10014597 https://avg.163.com/topic/detail/10014647 https://avg.163.com/topic/detail/10014645 https://avg.163.com/topic/detail/10014644 https://avg.163.com/topic/detail/10014643 https://avg.163.com/topic/detail/10014642 https://avg.163.com/topic/detail/10014641 https://avg.163.com/topic/detail/10014639 https://avg.163.com/topic/detail/10014638 https://avg.163.com/topic/detail/10014599 https://avg.163.com/topic/detail/10014637 https://avg.163.com/topic/detail/10014636 https://avg.163.com/topic/detail/10014633 https://avg.163.com/topic/detail/10014635 https://avg.163.com/topic/detail/10014634 https://avg.163.com/topic/detail/10014630 https://avg.163.com/topic/detail/10014631 https://avg.163.com/topic/detail/10014629 https://avg.163.com/topic/detail/10014628 https://avg.163.com/topic/detail/10014626 https://avg.163.com/topic/detail/10014625 https://avg.163.com/topic/detail/10014623 https://avg.163.com/topic/detail/10014622 https://avg.163.com/topic/detail/10014620 https://avg.163.com/topic/detail/10014621 https://avg.163.com/topic/detail/10014618 https://avg.163.com/topic/detail/10014619 https://avg.163.com/topic/detail/10014616 https://avg.163.com/topic/detail/10014617 https://avg.163.com/topic/detail/10014615 https://avg.163.com/topic/detail/10014614 https://avg.163.com/topic/detail/10014613 https://avg.163.com/topic/detail/10014612 https://avg.163.com/topic/detail/10014611 https://avg.163.com/topic/detail/10014574 https://avg.163.com/topic/detail/10014610 https://avg.163.com/topic/detail/10014609 https://avg.163.com/topic/detail/10014607 https://avg.163.com/topic/detail/10014608 https://avg.163.com/topic/detail/10014606 https://avg.163.com/topic/detail/10014605 https://avg.163.com/topic/detail/10014604 https://avg.163.com/topic/detail/10014603 https://avg.163.com/topic/detail/10014562 https://avg.163.com/topic/detail/10014602 https://avg.163.com/topic/detail/10014601 https://avg.163.com/topic/detail/10014561 https://avg.163.com/topic/detail/10014600 https://avg.163.com/topic/detail/10014599 https://avg.163.com/topic/detail/10014598 https://avg.163.com/topic/detail/10014597 https://avg.163.com/topic/detail/10014596 https://avg.163.com/topic/detail/10014595 https://avg.163.com/topic/detail/10014594 https://avg.163.com/topic/detail/10014593 https://avg.163.com/topic/detail/10014592 https://avg.163.com/topic/detail/10014553 https://avg.163.com/topic/detail/10014591 https://avg.163.com/topic/detail/10014590 https://avg.163.com/topic/detail/10014589 https://avg.163.com/topic/detail/10014585 https://avg.163.com/topic/detail/10014588 https://avg.163.com/topic/detail/10014587 https://avg.163.com/topic/detail/10014586 https://avg.163.com/topic/detail/10014583 https://avg.163.com/topic/detail/10014584 https://avg.163.com/topic/detail/10014582 https://avg.163.com/topic/detail/10014581 https://avg.163.com/topic/detail/10014580 https://avg.163.com/topic/detail/10014578 https://avg.163.com/topic/detail/10014579 https://avg.163.com/topic/detail/10014577 https://avg.163.com/topic/detail/10014576 https://avg.163.com/topic/detail/10014575 https://avg.163.com/topic/detail/10014574 https://avg.163.com/topic/detail/10014572 https://avg.163.com/topic/detail/10014573 https://avg.163.com/topic/detail/10014571 https://avg.163.com/topic/detail/10014533 https://avg.163.com/topic/detail/10014570 https://avg.163.com/topic/detail/10014569 https://avg.163.com/topic/detail/10014568 https://avg.163.com/topic/detail/10014567 https://avg.163.com/topic/detail/10014566 https://avg.163.com/topic/detail/10014565 https://avg.163.com/topic/detail/10014564 https://avg.163.com/topic/detail/10014563 https://avg.163.com/topic/detail/10014562 https://avg.163.com/topic/detail/10014561 https://avg.163.com/topic/detail/10014560 https://avg.163.com/topic/detail/10014559 https://avg.163.com/topic/detail/10014558 https://avg.163.com/topic/detail/10014557 https://avg.163.com/topic/detail/10014556 https://avg.163.com/topic/detail/10014555 https://avg.163.com/topic/detail/10014554 https://avg.163.com/topic/detail/10014553 https://avg.163.com/topic/detail/10014551 https://avg.163.com/topic/detail/10014552 https://avg.163.com/topic/detail/10014550 https://avg.163.com/topic/detail/10014549 https://avg.163.com/topic/detail/10014548 https://avg.163.com/topic/detail/10014500 https://avg.163.com/topic/detail/10014545 https://avg.163.com/topic/detail/10014547 https://avg.163.com/topic/detail/10014546 https://avg.163.com/topic/detail/10014544 https://avg.163.com/topic/detail/10014543 https://avg.163.com/topic/detail/10014542 https://avg.163.com/topic/detail/10014541 https://avg.163.com/topic/detail/10014539 https://avg.163.com/topic/detail/10014540 https://avg.163.com/topic/detail/10014538 https://avg.163.com/topic/detail/10014537 https://avg.163.com/topic/detail/10014536 https://avg.163.com/topic/detail/10014535 https://avg.163.com/topic/detail/10014534 https://avg.163.com/topic/detail/10014533 https://avg.163.com/topic/detail/10014532 https://avg.163.com/topic/detail/10014531 https://avg.163.com/topic/detail/10014530 https://avg.163.com/topic/detail/10014529 Device Boot Start End Blocks Id System /dev/hdc1 * 1 13 104391 83 Linux /dev/hdc2 14 1288 10241437+ 83 Linux /dev/hdc3 1289 1925 5116702+ 83 Linux /dev/hdc4 1926 5005 24740100 5 Extended /dev/hdc5 1926 2052 1020096 82 Linux swap / Solaris # 装置文件名 启动区否 开始磁柱 结束磁柱 1K大小容量 磁盘分区槽内的系统 Command (m for help): q
想要不储存离开吗?按下 q 就对了!不要随便按 w 啊!
使用 p 可以列出目前这颗磁盘的分割表信息,这个信息的上半部在显示整体磁盘的状态。
磁盘格式化
磁盘分割完毕后自然就是要进行文件系统的格式化,格式化的命令非常的简单,使用 mkfs(make filesystem) 命令。
语法:
mkfs [-t 文件系统格式] 装置文件名
选项与参数:
- -t :可以接文件系统格式,例如 ext3, ext2, vfat 等(系统有支持才会生效)
实例 1
查看 mkfs 支持的文件格式
[root@www ~]# mkfs[tab][tab] mkfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.msdos mkfs.vfat
按下两个[tab],会发现 mkfs 支持的文件格式如上所示。
实例 2
将分区 /dev/hdc6(可指定你自己的分区) 格式化为 ext3 文件系统:
[root@www ~]# mkfs -t ext3 /dev/hdc6
mke2fs 1.39 (29-May-2006)
Filesystem label= <==这里指的是分割槽的名称(label)
OS type: Linux
Block size=4096 (log=2) <==block 的大小配置为 4K
Fragment size=4096 (log=2)
251392 inodes, 502023 blocks <==由此配置决定的inode/block数量
25101 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=515899392
16 block groups
32768 blocks per group, 32768 fragments per group
15712 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done <==有日志记录
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
# 这样就创建起来我们所需要的 Ext3 文件系统了!简单明了!
磁盘检验
fsck(file system check)用来检查和维护不一致的文件系统。
若系统掉电或磁盘发生问题,可利用fsck命令对文件系统进行检查。
语法:
fsck [-t 文件系统] [-ACay] 装置名称
选项与参数:
- -t : 给定档案系统的型式,若在 /etc/fstab 中已有定义或 kernel 本身已支援的则不需加上此参数
- -s : 依序一个一个地执行 fsck 的指令来检查
- -A : 对/etc/fstab 中所有列出来的 分区(partition)做检查
- -C : 显示完整的检查进度
- -d : 打印出 e2fsck 的 debug 结果
- -p : 同时有 -A 条件时,同时有多个 fsck 的检查一起执行
- -R : 同时有 -A 条件时,省略 / 不检查
- -V : 详细显示模式
- -a : 如果检查有错则自动修复
- -r : 如果检查有错则由使用者回答是否修复
- -y : 选项指定检测每个文件是自动输入yes,在不确定那些是不正常的时候,可以执行 # fsck -y 全部检查修复。
实例 1
查看系统有多少文件系统支持的 fsck 命令:
[root@www ~]# fsck[tab][tab] fsck fsck.cramfs fsck.ext2 fsck.ext3 fsck.msdos fsck.vfat
实例 2
强制检测 /dev/hdc6 分区:
[root@www ~]# fsck -C -f -t ext3 /dev/hdc6 fsck 1.39 (29-May-2006) e2fsck 1.39 (29-May-2006) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information









