linux查看分区标志命令,Linux 查看磁盘分区、文件系统、使用情况的命令和相关工具介绍...

Linux查看磁盘分区、文件系统、使用情况的命令和相关工具介绍

提要:

Linux磁盘分区表、文件系统的查看、统计的工具很多,有些工具是多功能的,不仅仅是查看磁盘的分区表,而且也能进行磁盘分区的操作;

一、df命令

df是来自于coreutils软件包,系统安装时,就自带的;我们通过这个命令可以查看磁盘的使用情况以及文件系统被挂载的位置;

举例:

[root@localhost]# df -lh

Filesystem容量已用 可用 已用%挂载点

/dev/hda811G6.0G4.4G58% /

/dev/shm236M0236M0% /dev/shm

/dev/sda156G22G35G39% /mnt/sda1

二、fdsik

fdisk是一款强大的磁盘操作工具,通过-l参数,能获得机器中所有的硬盘的分区情况;

[root@localhost]# fdisk -lDisk /dev/hda: 80.0 GB, 80026361856 bytes255 heads, 63 sectors/track, 9729 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/hda1 * 1 765 6144831 7 HPFS/NTFS/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)/dev/hda3 2806 7751 39728745 5 Extended/dev/hda5 2806 3825 8193118+ 83 Linux/dev/hda6 3826 5100 10241406 83 Linux/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris/dev/hda8 5199 6657 11719386 83 Linux/dev/hda9 6658 7751 8787523+ 83 Linux

在上面Blocks中,表示的是分区的大小,Blocks的单位是byte;

System表示的文件系统;

/dev/hda3 2806 7751 39728745 5 Extended这是扩展分区;他下面包含着逻辑分区;

fdisk -l能列出机器中所有磁盘的个数,也能列出所有磁盘分区情况;比如:

[root@localhost]# fdisk -lDisk /dev/hda: 80.0 GB, 80026361856 bytes255 heads, 63 sectors/track, 9729 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/hda1 * 1 765 6144831 7 HPFS/NTFS/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)/dev/hda3 2806 7751 39728745 5 Extended/dev/hda5 2806 3825 8193118+ 83 Linux/dev/hda6 3826 5100 10241406 83 Linux/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris/dev/hda8 5199 6657 11719386 83 Linux/dev/hda9 6658 7751 8787523+ 83 LinuxDisk /dev/sda: 60.0 GB, 60011642880 bytes64 heads, 32 sectors/track, 57231 cylindersUnits = cylinders of 2048 * 512 = 1048576 bytesDevice Boot Start End Blocks Id System/dev/sda1 1 57231 58604528 83 Linux

/dev/had和/dev/sda有两块硬盘,我们也可以指定fdisk -l来查看其中一个硬盘的分区情况;

[root@localhost]# fdisk -l /dev/sdaDisk /dev/sda: 60.0 GB, 60011642880 bytes64 heads, 32 sectors/track, 57231 cylindersUnits = cylinders of 2048 * 512 = 1048576 bytesDevice Boot Start End Blocks Id System/dev/sda1 1 57231 58604528 83 Linux

三、cfdisk来自于util-linux的软件包;

cfdisk也是一款不错的分区工具;在有些发行版中,此工具已经从util-linux包中剔除;cfdisk简单易用是他的特点;

查看磁盘分区的用法cfdisk -Ps磁盘设备名;

[root@localhost]cfdisk -Ps /dev/hda[root@localhost]cfdisk -PsPartition Table for /dev/hdaFirst Last# Type Sector Sector Offset Length Filesystem Type (ID) Flag-- ------- ----------- ----------- ------ ----------- -------------------- ----1 Primary 0 23438834 63 23438835 Linux (83) Boot2 Primary 23438835 156296384 0 132857550 Extended (05) None5 Logical 23438835 155268224 63 131829390 Linux (83) None6 Logical 155268225 156296384 63 1028160 Linux swap (82) None

我们只用的参数-Ps,就列出了磁盘的分区情况;目前在Slackware Debian Mandrake等主流发行版中存在cfdisk,

[root@localhost]cfdisk磁盘设备名

举例:

[root@localhost]cfdisk /dev/hda

您所看到的是如下的模式:

cfdisk 2.12aDisk Drive: /dev/hdaSize: 80026361856 bytes, 80.0 GBHeads: 255 Sectors per Track: 63 Cylinders: 9729Name Flags Part Type FS Type [Label] Size (MB)-------------------------------------------------------------------------------------------hda1 Boot Primary Linux ReiserFS 12000.69hda5 Logical Linux ReiserFS 67496.65hda6 Logical Linux swap 526.42[Bootable] [ Delete ] [ Help ] [Maximize] [ Print ] [ Quit ][ Type ] [ Units ] [ Write ]Toggle bootable flag of the current partition

您进入了cfdisk的操作界面;用键盘移动指针到[Quit]就可以退出;

四、parted功能不错的分区工具;

调用方法简单,parted默认是打开的设备是/dev/hda,也可以自己指定;退出的方法是quit

[root@localhost]# parted使用/dev/hda(parted)p/dev/hda的磁盘几何结构:0.000-76319.085兆字节磁盘标签类型:msdosMinor起始点 终止点 类型 文件系统 标志1 0.031 6000.842主分区ntfs启动2 6000.842 22003.088主分区fat32 lba3 22003.088 60800.690扩展分区5 22003.119 30004.211逻辑分区reiserfs6 30004.242 40005.615逻辑分区reiserfs7 40005.646 40774.350逻辑分区linux-swap8 40774.381 52219.094逻辑分区ext39 52219.125 60800.690逻辑分区reiserfs

我们在partd的操作面上,用p就可以列出当前磁盘的分区情况,如果想要查看其它磁盘,可以用select功能,比如select /dev/sda;

五、qtparted,与parted相关的软件还有qtparted,也能查看到磁盘的结构和所用的文件系统,是图形化的;# qtparted图形化的查看工具;

六、sfdisk也是一个分区工具,功能也多多;我们在这里只说他的列磁盘分区情况的功能;

[root@localhost]# sfdisk -l

七、partx也简要的说一说,有些系统自带了这个工具,功能也简单,和fdisk、parted、cfdisk来说不值一提;不用也罢;

用法:partx设备名

[root@localhost]# partx /dev/hda# 1: 63- 12289724 ( 12289662 sectors, 6292 MB)# 2: 12289725- 45062324 ( 32772600 sectors, 16779 MB)# 3: 45062325-124519814 ( 79457490 sectors, 40682 MB)# 4: 0- -1 ( 0 sectors, 0 MB)# 5: 45062388- 61448624 ( 16386237 sectors, 8389 MB)# 6: 61448688- 81931499 ( 20482812 sectors, 10487 MB)# 7: 81931563- 83505869 ( 1574307 sectors, 806 MB)# 8: 83505933-106944704 ( 23438772 sectors, 12000 MB)# 9: 106944768-124519814 ( 17575047 sectors, 8998 MB)

八、查看目前机器中的所有磁盘及分区情况:

[root@localhost]# cat /proc/partitionsmajor minor #blocks name3 0 78150744 hda3 1 6144831 hda13 2 16386300 hda23 5 8193118 hda53 6 10241406 hda63 7 787153 hda73 8 11719386 hda83 9 8787523 hda98 0 58605120 sda8 1 58604528 sda1

九、mac-fdisk这个工具主要是用在Powerpc版本的Linux中,咱们常用X86版本中没有这个工具;这个只是介绍一下;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值