Chinaunix首页 | 论坛 | 博客
  • 博客访问: 704342
  • 博文数量: 147
  • 博客积分: 6010
  • 博客等级: 准将
  • 技术积分: 1725
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-22 10:36
文章分类

全部博文(147)

文章存档

2011年(1)

2010年(1)

2009年(35)

2008年(110)

我的朋友

分类: LINUX

2008-10-13 00:26:51

1.查看磁盘的容量
  将容量以易读的方式显示出来:df -h
  将/etc下面可用的磁盘容量读出来
  df -h /etc(df会分析该目录所在的分区,并将该分区的容量显示出来)
  df -T:查看系统文件类型
 2.查看文件或者目录的大小
  du -sh 查看当前文件夹大小
  du -sh * 统计当前文件夹(目录)大小
  du -sh filename 查看指定文件大小
3.链接文件:
  硬链接:ln    源文件  目标文件(类似复制)
  软链接:ln -s 源文件  目标文件(类似快捷方式)
4.fdisk -l:查看硬盘的分区情况
  [root@localhost wuxiaoxiao]# /sbin/fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1275    10241406    7  HPFS/NTFS
/dev/sda2            1276       19456   146038882+   f  W95 Ext'd (LBA)
/dev/sda5            1276        7649    51199123+   b  W95 FAT32
/dev/sda6            7650        7661       96358+  83  Linux
/dev/sda7            7662       12830    41519961   83  Linux
/dev/sda8           12831       14742    15358108+  83  Linux
/dev/sda9           14743       15379     5116671   83  Linux
/dev/sda10          15380       17928    20474811   83  Linux
/dev/sda11          17929       19202    10233373+  83  Linux
/dev/sda12          19203       19456     2040223+  82  Linux swap / Solaris
从上面红色部分可以看出来硬盘是否用完!
5.查看一个硬盘的使用情况:fdisk /dev/sda
  [root@localhost wuxiaoxiao]# /sbin/fdisk /dev/sda

The number of cylinders for this disk is set to 19457.
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 action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition:删除一个分区
   l   list known partition types
   m   print this menu
   n   add a new partition:创建一个分区
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   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)

Command (m for help): p>>>>>>>>>>>>>>>>>>>>>>>>输出当前磁盘的状态

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1275    10241406    7  HPFS/NTFS
/dev/sda2            1276       19456   146038882+   f  W95 Ext'd (LBA)
/dev/sda5            1276        7649    51199123+   b  W95 FAT32
/dev/sda6            7650        7661       96358+  83  Linux
/dev/sda7            7662       12830    41519961   83  Linux
/dev/sda8           12831       14742    15358108+  83  Linux
/dev/sda9           14743       15379     5116671   83  Linux
/dev/sda10          15380       17928    20474811   83  Linux
/dev/sda11          17929       19202    10233373+  83  Linux
/dev/sda12          19203       19456     2040223+  82  Linux swap / Solaris

Command (m for help): q>>>>>>>>>>>>>>>>>>>>>>>>>>>>>不保存离开
6.删除分区:
[root@localhost wuxiaoxiao]# /sbin/fdisk /dev/sda

The number of cylinders for this disk is set to 19457.
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 action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   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)

Command (m for help): d
Partition number (1-12): 5

Command (m for help): p

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1275    10241406    7  HPFS/NTFS
/dev/sda2            1276       19456   146038882+   f  W95 Ext'd (LBA)
/dev/sda5            7650        7661       96358+  83  Linux
/dev/sda6            7662       12830    41519961   83  Linux
/dev/sda7           12831       14742    15358108+  83  Linux
/dev/sda8           14743       15379     5116671   83  Linux
/dev/sda9           15380       17928    20474811   83  Linux
/dev/sda10          17929       19202    10233373+  83  Linux
/dev/sda11          19203       19456     2040223+  82  Linux swap / Solaris

Command (m for help): q:不保存离开

7.新增分区
  输入n---->输入p或者e或者l------>输入分区编号--->选择起始的磁道或者按ENTER使用默认设置-->+100M表示该分区为100M---->接着分区....----->w保存退出!
8.磁盘格式化
将/dev/sda5分区格式化为ext3,且名称为logical.
参数-L后面可以接卷标
-j:本来是ext2,加上-j格式化为ext3
mke2fs -j -L "Logical" /dev/sda5
  9.磁盘检验
-C:检验时候显示进度
-t:文件类型
fsck -C -t ext3 /dev/sda5
注意:执行fsck时,被检查的分区不能是已经被挂载在系统上的!!!!
9.挂载磁盘
将windows盘挂载:
mkdir /mnt/windowsXP
mount -t vfat -o iocharset=cp950 /dev/sda5 /mnt/windowsXP
-o:正确的显示中文
将新加的分区挂载上
mkdir /mnt/sdb5
mount -t ext3 /dev/sdb5 /mnt/sdb5
10.查看已经挂载的分区
  mount
11.卸载设备文件
  unmount /dev/sda5或者是/mnt/windowsXP
12.要想启动时候就挂载
在/etc/fstab中加上
/dev/sda5              /mnt/windowsXP           vfat    defaults        2 2
13.挂载U盘
    fdisk -l查看u盘的分区表,例如:/dev/sdb1
    mkdir /mnt/usb
    mount -t msdoc -o iocharset=gb2312 /dev/sdb1 /mnt/usb(mount -t vfat(根据u盘的格式)(fat32) -o iocharset=gb2312(根据系统字符集)  /dev/sdb1 /mnt/usb)
(查看系统字符集locale ;查看系统支持的字符集:locale -m;修改系统的字符集/etc/profile.d/lang.sh例如:添加export LC_ALL=zh_CN.UTF-8)
    卸载:unmount /dev/sdb1
14.挂载光盘 
      mount -t is09660 /dev/cdrom /mnt/cdrom  
  该命令将光盘挂载到/mnt/cdrom目录,使用“ls /mnt/cdrom”命令即可显示光盘中数据和文件。  
  卸载光盘的命令如下:  
  # umount /mnt/cdrom
15.建立虚拟内存
新增64M的文件
if指的是要转换的输入文件格式
of指的是输出文件
bs指的是一个分区占用多少KB
count指的是使用多少个bs,最后的容量为4*16382~64M
[root@localhost tmp]# dd if=/dev/zero of=/tmp/swap bs=4k count=16382
16382+0 records in
16382+0 records out
67100672 bytes (67 MB) copied,0.437341 秒,153 MB/秒
格式化为虚拟内存文件格式
[root@localhost tmp]# /sbin/mkswap /tmp/swap
Setting up swapspace version 1, size = 67096 kB
[root@localhost tmp]# free
             total       used       free     shared    buffers     cached
Mem:        904776     662248     242528          0      90472     328536
-/+ buffers/cache:     243240     661536
Swap:      2040212          0    2040212
启动
[root@localhost tmp]# /sbin/swapon /tmp/swap
[root@localhost tmp]# free
             total       used       free     shared    buffers     cached
Mem:        904776     662248     242528          0      90528     328540
-/+ buffers/cache:     243180     661596
Swap:      2105732          0    2105732
关闭
[root@localhost tmp]# /sbin/swapoff /tmp/swap
[root@localhost tmp]# free
             total       used       free     shared    buffers     cached
Mem:        904776     662248     242528          0      90560     328548
-/+ buffers/cache:     243140     661636
Swap:      2040212          0    2040212




阅读(806) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~