文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>(linux)学习硬盘操作知识

(linux)学习硬盘操作知识

时间:2006-03-21  来源:songduanlei

一、df 命令;

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

[root@localhost sdaull]# df -h
Filesystem            容量  已用 可用 已用% 挂载点
/dev/hda8             6.7G  4.1G  2.3G  65% /
/dev/hda7             236M  9.7M  214M   5% /boot
/dev/shm              125M     0  125M   0% /dev/shm
/dev/hda9             8.2G  1.2G  6.6G  15% /home
/dev/hda1             9.8G  6.0G  3.8G  62% /mnt/winc

二、fdsik

fdisk 是一款强大的磁盘操作工具,来自util-linux软件包,我们在这里只说他如何查看磁盘分区表及分区结构;参数 -l ,通过-l 参数,能获得机器中所有的硬盘的分区情况;
[root@localhost sdaull]# /sbin/fdisk -l

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        1275    10241406    7  HPFS/NTFS
/dev/hda2            1276        9729    67906755    f  W95 Ext'd (LBA)
/dev/hda5            1276        3825    20482843+   7  HPFS/NTFS
/dev/hda6            3826        7649    30716248+   7  HPFS/NTFS
/dev/hda7            7650        7680      248976   83  Linux
/dev/hda8            7681        8572     7164958+  83  Linux
/dev/hda9            8573        9666     8787523+  83  Linux
/dev/hda10           9667        9729      506016   82  Linux swap / Solaris
三、cfdisk 来自于util-linux的软件包;

cfdisk 也是一款不错的分区工具;在有些发行版中,此工具已经从util-linux包中剔除;cfdisk 简单易用是他的特点;和DOS中的fdisk 相似;在本标题中,我们只来解说如何查看机器的中的磁盘分区状况及所用的文件系统等;


四、parted 功能不错的分区工具;在Fedora 4.0中有带,可以自己安装上;在此主题中,我们只说如何查看磁盘的分区情况;

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

[root@localhost sdaull]# /sbin/parted
GNU Parted 1.6.22
Copyright (C) 1998 - 2005 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.

使用 /dev/hda
五、sfdisk 也是一个分区工具,功能也多多;我们在这里只说他的列磁盘分区情况的功能;
[root@localhost sdaull]# /sbin/sfdisk -l

Disk /dev/hda: 155061 cylinders, 16 heads, 63 sectors/track
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Warning: The partition table looks like it was made
  for C/H/S=*/255/63 (instead of 155061/16/63).
For this listing I'll assume that geometry.
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/hda1   *      0+   1274    1275-  10241406    7  HPFS/NTFS
/dev/hda2       1275    9728    8454   67906755    f  W95 Ext'd (LBA)
/dev/hda3          0       -       0          0    0  Empty
/dev/hda4          0       -       0          0    0  Empty
/dev/hda5       1275+   3824    2550-  20482843+   7  HPFS/NTFS
/dev/hda6       3825+   7648    3824-  30716248+   7  HPFS/NTFS
/dev/hda7       7649+   7679      31-    248976   83  Linux
/dev/hda8       7680+   8571     892-   7164958+  83  Linux
/dev/hda9       8572+   9665    1094-   8787523+  83  Linux
/dev/hda10      9666+   9728      63-    506016   82  Linux swap / Solaris
六、partx 也简要的说一说,有些系统自带了这个工具,功能也简单,和fdisk 、parted、cfdisk 来说不值一提;不用也罢;

用法: partx 设备名
[root@localhost sdaull]# /sbin/partx /dev/hda
# 1:        63- 20482874 ( 20482812 sectors,  10487 MB)
# 2:  20482875-156296384 (135813510 sectors,  69536 MB)
# 3:         0-       -1 (        0 sectors,      0 MB)
# 4:         0-       -1 (        0 sectors,      0 MB)
# 5:  20482938- 61448624 ( 40965687 sectors,  20974 MB)
# 6:  61448688-122881184 ( 61432497 sectors,  31453 MB)
# 7: 122881248-123379199 (   497952 sectors,    254 MB)
# 8: 123379263-137709179 ( 14329917 sectors,   7336 MB)
# 9: 137709243-155284289 ( 17575047 sectors,   8998 MB)
#10: 155284353-156296384 (  1012032 sectors,    518 MB)
七、查看目前机器中的所有磁盘及分区情况:

[root@localhost sdaull]# cat /proc/partitions
major minor  #blocks  name

   3     0   78150744 hda
   3     1   10241406 hda1
   3     2          1 hda2
   3     5   20482843 hda5
   3     6   30716248 hda6
   3     7     248976 hda7
   3     8    7164958 hda8
   3     9    8787523 hda9
   3    10     506016 hda10

相关阅读 更多 +
排行榜 更多 +
Event Horizon

Event Horizon

飞行射击 下载
Counter Terrorist Sniper Shoot

Counter Terrorist Sniper Shoot

飞行射击 下载
Special Agent

Special Agent

飞行射击 下载