📄 linux 查看磁盘分区、文件系统、使用情况的命令和相关工具介绍 linuxsir_org.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0039)http://www.linuxsir.org/main/?q=node/41 -->
<HTML lang=zh-hans xml:lang="zh-hans"
xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Linux 查看磁盘分区、文件系统、使用情况的命令和相关工具介绍 | LinuxSir.Org</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<STYLE type=text/css media=all>@import url( misc/drupal.css );
</STYLE>
<STYLE type=text/css>@import url( http://www.linuxsir.org/main/modules/codefilter/codefilter.css );
</STYLE>
<STYLE type=text/css media=all>@import url( modules/taxonomy_context/taxonomy_context.css );
</STYLE>
<LINK media=screen
href="Linux 查看磁盘分区、文件系统、使用情况的命令和相关工具介绍 LinuxSir_Org.files/menuExpandable3.css"
type=text/css rel=stylesheet>
<SCRIPT
src="Linux 查看磁盘分区、文件系统、使用情况的命令和相关工具介绍 LinuxSir_Org.files/menuExpandable3.js"
type=text/javascript></SCRIPT>
<LINK href="Linux 查看磁盘分区、文件系统、使用情况的命令和相关工具介绍 LinuxSir_Org.files/common.css"
type=text/css rel=stylesheet>
<STYLE type=text/css media=all>@import url( themes/chameleon/marvin/style.css );
</STYLE>
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY>
<DIV id=header><A title=Home href="http://www.linuxsir.org/main/"><IMG alt=Home
src="Linux 查看磁盘分区、文件系统、使用情况的命令和相关工具介绍 LinuxSir_Org.files/logo.jpg"></A></DIV>
<DIV class=navlinks>
<DIV class=primary><A href="http://www.linuxsir.org/main/?q"><FONT
color=white>首页</FONT></A> | <A
href="http://www.linuxsir.org/main/?q=taxonomy/term/34"><FONT
color=white>事件</FONT></A> | <A
href="http://www.linuxsir.org/main/?q=taxonomy/term/1/25/"><FONT
color=white>文档</FONT></A> | <A
href="http://www.linuxsir.org/main/?q=taxonomy/term/35/48/"><FONT
color=white>资源</FONT></A> | <A
href="http://www.linuxsir.org/main/?q=search"><FONT color=white>搜索</FONT></A> |
<A href="http://www.linuxsir.org/bbs"><FONT color=white>论坛</FONT></A> | <A
href="http://www.linuxsir.org/main/?q=taxonomy/term/38"><FONT
color=white>贡献者</FONT></A> | <A
href="http://www.linuxsir.org/main/?q=node/3"><FONT color=white>关于</FONT></A> |
<A href="http://www.linuxsir.org/main/?q=user"><FONT
color=white>注册/登录</FONT></A></DIV></DIV>
<TABLE id=content>
<TBODY>
<TR>
<TD id=sidebar-left>
<DIV class="block block-block" id=block-block-1>
<H2 class=title>子站索引</H2>
<DIV class=content>
<UL>
<LI><A href="http://fedora.linuxsir.org/" target?_blank?>Fedora中文</A>
<LI><A href="http://debian.linuxsir.org/" target?_blank?>Debian中文</A>
<LI><A href="http://lfs.linuxsir.org/" target?_blank?>LFS 中文</A>
<LI><A href="http://slack.linuxsir.org/">Slackware</A>
<LI><A href="http://gentoo.linuxsir.org/">Gentoo中文</A>
<LI><A href="http://arch.linuxsir.org/">Arch 中文</A> </LI></UL></DIV></DIV>
<DIV class="block block-block" id=block-block-3>
<H2 class=title>重要资讯</H2>
<DIV class=content>
<UL>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/36">本站公告</A>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/34">新闻事件</A>
<LI><A href="http://www.linuxsir.org/bbs" target=_blank>本站论坛</A>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/38">贡 献 者</A>
</LI></UL></DIV></DIV>
<DIV class="block block-block" id=block-block-7>
<H2 class=title>项目索引</H2>
<DIV class=content>
<UL>
<LI><A href="http://www.fcitx.org/" target=_blank>小企鹅输入法</A>
<LI><A href="http://lumaqq.linuxsir.org/" target=_blank>LumaQQ</A>
<LI><A href="http://openq.linuxsir.org/" target=_blank>OpenQ</A>
<LI><A href="http://www.relaxbsd.org/" target=_blank>RelaxBSD</A>
</LI></UL></DIV></DIV>
<DIV class="block block-user" id=block-user-1>
<H2 class=title>站点导航</H2>
<DIV class=content>
<DIV class=menu>
<UL>
<LI class=leaf><A title=注册/登录
href="http://www.linuxsir.org/main/?q=user">注册/登录</A>
<LI class=collapsed><A
href="http://www.linuxsir.org/main/?q=aggregator">新闻聚合</A>
</LI></UL></DIV></DIV></DIV>
<DIV class="block block-aggregator" id=block-aggregator-feed-2>
<H2 class=title>LinuxSir.Org 论坛</H2>
<DIV class=content>
<DIV class=item-list>
<UL>
<LI><A
href="http://www.linuxsir.org/bbs/showthread.php?t=267213&goto=newpost">告别LINUX</A>
<LI><A
href="http://www.linuxsir.org/bbs/showthread.php?t=267212&goto=newpost">suse中国社区(论坛)已正式开放</A>
<LI><A
href="http://www.linuxsir.org/bbs/showthread.php?t=267211&goto=newpost">在文本编辑器中显示乱码</A>
<LI><A
href="http://www.linuxsir.org/bbs/showthread.php?t=267210&goto=newpost">archlinux用最新的ntfs-3g驱动读写ntfs分区</A>
<LI><A
href="http://www.linuxsir.org/bbs/showthread.php?t=267209&goto=newpost">实在是不行了~发帖请教一下,关于samba的中文问题~~~</A>
</LI></UL></DIV>
<DIV class=more-link><A title=查看此feed的最新消息
href="http://www.linuxsir.org/main/?q=aggregator/sources/2">更多</A></DIV></DIV></DIV>
<DIV class="block block-user" id=block-user-2>
<H2 class=title>最新注册</H2>
<DIV class=content>
<DIV class=item-list>
<UL>
<LI>iobuf
<LI>snakejohe
<LI>tunnys
<LI>layeyeung
<LI>wuyuworld</LI></UL></DIV></DIV></DIV>
<DIV class="block block-user" id=block-user-3>
<H2 class=title>当前在线</H2>
<DIV class=content>1 用户 和 60 游客 在线
<DIV class=item-list>
<H3>在线用户</H3>
<UL>
<LI>mu_la_flanka</LI></UL></DIV></DIV></DIV></TD>
<TD id=main>
<DIV class=breadcrumb><A href="http://www.linuxsir.org/main/?q=">首页</A> »
<A href="http://www.linuxsir.org/main/?q=taxonomy/term/1">Linux</A></DIV>
<H2>Linux 查看磁盘分区、文件系统、使用情况的命令和相关工具介绍</H2><!-- begin content -->
<DIV class=node>
<DIV class=content>
<P><B>作者:</B>北南南北<BR><B>来自:</B>LinuxSir.Org<BR><B>提要:</B>Linux
磁盘分区表、文件系统的查看、统计的工具很多,有些工具是多功能的,不仅仅是查看磁盘的分区表,而且也能进行磁盘分区的操作;但在本文,我们只讲磁盘分区的查看,以及分区的使用情况的查看;本文只是给新手上路之用;关于分区工具的操作,我将在以后做专门介绍;</P>
<P><B>此文目的:</B>主要是向初学者介绍一下入门必备的一点基础知识,有了基础知识才能进阶;如果把所有的磁盘操作工具都放在一个文档里,大家看了也累;基于这种想法,所以我写文档的时候,就想让新手弟兄一目了解,能轻松点就轻松点;生活、工作和学习无不是如此;</P>
<P><B>操作环境:</B>Fedora core 4.0 i686 & Slackware 10.1</P>
<P><FONT
color=blue><B><BR>+++++++++++++++++++++++++++++++++++++++<BR>正文<BR>+++++++++++++++++++++++++++++++++++++++<BR></B></FONT><BR><B><BR>一、df
命令;<BR></B><BR>df 是来自于coreutils
软件包,系统安装时,就自带的;我们通过这个命令可以查看磁盘的使用情况以及文件系统被挂载的位置;</P>
<P>举例:</P><PRE>[root@localhost beinan]# df -lh
Filesystem 容量 已用 可用 已用% 挂载点
/dev/hda8 11G 6.0G 4.4G 58% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/sda1 56G 22G 35G 39% /mnt/sda1
</PRE>
<P>我们从中可以看到,系统安装在/dev/hda8 ;还有一个56G的磁盘分区/dev/sda1挂载在 /mnt/sda1中;</P>
<P>其它的参数请参考 man df </P>
<P><B><BR>二、fdsik<BR></B><BR>fdisk
是一款强大的磁盘操作工具,来自util-linux软件包,我们在这里只说他如何查看磁盘分区表及分区结构;参数 -l ,通过-l
参数,能获得机器中所有的硬盘的分区情况;<BR>
<DIV class=codeblock><CODE>[root@localhost beinan]# fdisk -l<BR>Disk
/dev/hda: 80.0 GB, 80026361856 bytes<BR>255 heads, 63 sectors/track, 9729
cylinders<BR>Units = cylinders of 16065 * 512 = 8225280
bytes<BR> Device Boot Start End Blocks Id
System<BR>/dev/hda1 * 1 765 6144831 7 HPFS/NTFS<BR>/dev/hda2 766 2805
16386300 c W95 FAT32 (LBA)<BR>/dev/hda3 2806 7751 39728745 5
Extended<BR>/dev/hda5 2806 3825 8193118+ 83 Linux<BR>/dev/hda6 3826 5100
10241406 83 Linux<BR>/dev/hda7 5101 5198 787153+ 82 Linux swap /
Solaris<BR>/dev/hda8 5199 6657 11719386 83 Linux<BR>/dev/hda9 6658 7751
8787523+ 83 Linux</CODE></DIV>
<P></P>
<P>在上面Blocks中,表示的是分区的大小,Blocks的单位是byte
,我们可以换算成M,比如第一个分区/dev/hda1的大小如果换算成M,应该是6144831/1024=6000M,也就是6G左右,其实没有这么麻烦,粗略的看一下把小数点向前移动三位,就知道大约的体积有多大了;<BR>System
表示的文件系统,比如/dev/hda1 是NTFS格式的;/dev/hda2 表示是fat32格式的文件系统;.</P>
<P>在此例中,我们要特别注意的是/dev/hda3分区,这是扩展分区;他下面包含着逻辑分区,其实这个分区相当于一个容器;从属于她的有
hda5,hda6,hda7,hda8,hda9 ;</P>
<P>我们还注意到一点,怎么没有hda4呢?为什么hda4没有包含在扩展分区?一个磁盘最多有四个主分区;
hda1-4算都是主分区;hda4不可能包含在扩展分区里,另外扩展分区也算主分区;在本例中,没有hda4这个分区,当然我们可以把其中的一个分区设置为主分区,只是我当时分区的时候没有这么做而已;</P>
<P>再仔细统计一下,我们看一看这个磁盘是不是还有空间?hda1+hda2+hda3=实际已经分区的体积,所以我们可以这样算
hda1+hda2+hda3=6144831+16386300+39728745 = 62259876
(b),换算成M单位,小数点向前移三位,所以目前已经划分好的分区大约占用体积是62259.876(M),其实最精确的计算62259876/1024=60800.67(M);而这个磁盘大小是80.0
GB
(80026361856byte),其实实际大小也就是78150.744(M);通过我们一系列的计算,我们可以得出这个硬盘目前还有使用的空间;大约还有18G未分区的空间;</P>
<P>fdisk -l 能列出机器中所有磁盘的个数,也能列出所有磁盘分区情况;比如:</P>
<P>
<DIV class=codeblock><CODE>[root@localhost beinan]# fdisk -l<BR>Disk
/dev/hda: 80.0 GB, 80026361856 bytes<BR>255 heads, 63 sectors/track, 9729
cylinders<BR>Units = cylinders of 16065 * 512 = 8225280
bytes<BR> Device Boot Start End Blocks Id
System<BR>/dev/hda1 * 1 765 6144831 7 HPFS/NTFS<BR>/dev/hda2 766 2805
16386300 c W95 FAT32 (LBA)<BR>/dev/hda3 2806 7751 39728745 5
Extended<BR>/dev/hda5 2806 3825 8193118+ 83 Linux<BR>/dev/hda6 3826 5100
10241406 83 Linux<BR>/dev/hda7 5101 5198 787153+ 82 Linux swap /
Solaris<BR>/dev/hda8 5199 6657 11719386 83 Linux<BR>/dev/hda9 6658 7751
8787523+ 83 Linux<BR>Disk /dev/sda: 60.0 GB, 60011642880 bytes<BR>64
heads, 32 sectors/track, 57231 cylinders<BR>Units = cylinders of 2048 *
512 = 1048576 bytes<BR> Device Boot Start End Blocks Id
System<BR>/dev/sda1 1 57231 58604528 83 Linux</CODE></DIV>
<P></P>
<P>通过上面我们可以知道此机器有两块硬盘,我们也可以指定fdisk -l 来查看其中一个硬盘的分区情况;</P>
<P>
<DIV class=codeblock><CODE>[root@localhost beinan]# fdisk -l
/dev/sda<BR>Disk /dev/sda: 60.0 GB, 60011642880 bytes<BR>64 heads, 32
sectors/track, 57231 cylinders<BR>Units = cylinders of 2048 * 512 =
1048576 bytes<BR> Device Boot Start End Blocks Id
System<BR>/dev/sda1 1 57231 58604528 83
Linux</CODE></DIV><BR>通过上面情况可以知道,在/dev/sda 这个磁盘中,只有一个分区;使用量差不多是百分百了;
<P></P>
<P>我们还可以来查看 /dev/hda的<BR>
<DIV class=codeblock><CODE>[root@localhost beinan]# fdisk -l
/dev/hda</CODE></DIV>
<P></P>
<P>自己试试看?<BR><B><BR>三、cfdisk 来自于util-linux的软件包;<BR></B><BR>cfdisk
也是一款不错的分区工具;在有些发行版中,此工具已经从util-linux包中剔除;cfdisk 简单易用是他的特点;和DOS中的fdisk
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -