ITPub博客

首页 > Linux操作系统 > Linux操作系统 > linux磁盘和文件系统

linux磁盘和文件系统

原创 Linux操作系统 作者:tolilong 时间:2012-10-23 08:15:59 0 删除 编辑
fdisk 磁盘设备          查看分区信息
fdisk m 查看操作指令的帮助信息 
      p 列表查看分区信息
      n 新建分区
      d 删除分区
      t 变更分区类型
      w 保存分区设置并退出
      q 放弃分区设置并退出
---=============================================
(1)fdisk只能建立3个主分区和一个扩展分区.
[root@weblogic dev]# fdisk /dev/sdb      
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

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): n           --->输入n新建分区
Command action
   e   extended
   p   primary partition (1-4)
p                                 --->输入p建立主分区
Partition number (1-4): 1         --->输入分区编号1,最多为4个编号
First cylinder (1-261, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): +1000M    

Command (m for help): p            -->输入p,列出分区

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         123      987966   83  Linux   
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e                                  --->输入e,简历扩展分区
Partition number (1-4): 1          --->其中不能输入1了,因为已经重复了
Partition 1 is already defined.  Delete it before re-adding it.

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e                                  --->输入e,简历扩展分区
Partition number (1-4): 2          
First cylinder (124-261, default 124): 
Using default value 124
Last cylinder or +size or +sizeM or +sizeK (124-261, default 261): +600M

Command (m for help): p           -->输入p,列出分区

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         123      987966   83  Linux
/dev/sdb2             124         197      594405    5  Extended

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (124-197, default 124): 
Using default value 124
Last cylinder or +size or +sizeM or +sizeK (124-197, default 197): +400M

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         123      987966   83  Linux
/dev/sdb2             124         197      594405    5  Extended
/dev/sdb5             124         173      401593+  83  Linux

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (174-197, default 174): 
Using default value 174
Last cylinder or +size or +sizeM or +sizeK (174-197, default 197): 
Using default value 197

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         123      987966   83  Linux
/dev/sdb2             124         197      594405    5  Extended
/dev/sdb5             124         173      401593+  83  Linux
/dev/sdb6             174         197      192748+  83  Linux

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
p
Partition number (1-4): 3             --->建立最后一个分区3
First cylinder (198-261, default 198): 
Using default value 198
Last cylinder or +size or +sizeM or +sizeK (198-261, default 261): 
Using default value 261
 
Command (m for help): p               -->输入p,列出分区

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         123      987966   83  Linux
/dev/sdb2             124         197      594405    5  Extended
/dev/sdb3             198         261      514080   83  Linux
/dev/sdb5             124         173      401593+  83  Linux
/dev/sdb6             174         197      192748+  83  Linux   

Command (m for help): w               --->w保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
---=====================================================
(3)格式化分区
mkfs -t ext3 /dev/sdb1
mkfs.ext3 /dev/sdb5
---=====================================================
(4)为swap增加空间
[root@weblogic ~]# mkswap /dev/sdb5      --->格式化交换分区
Setting up swapspace version 1, size = 411226 kB
[root@weblogic ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1470        393       1076          0         33        272
-/+ buffers/cache:         87       1382
Swap:         2000          0       2000
[root@weblogic ~]# swapon /dev/sdb5      --->启用交换分区
[root@weblogic ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1470        393       1076          0         33        272
-/+ buffers/cache:         87       1382
Swap:         2392          0       2392 
[root@weblogic ~]# swapoff /dev/sdb5      --->停用交换分区
[root@weblogic ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1470        393       1076          0         33        272
-/+ buffers/cache:         87       1382
Swap:         2000          0       2000
---===================================================
(5)挂载,卸载文件系统
mount [-t] 存储设备  挂载点目录
mount -o loop iso镜像文件  挂载点目录
unmount 

mount -t ext3 /dev/sdb1 /disk1
mount /dev/sdb5 /disk2
mount 显示所有mount的目录

光盘的挂载:
mount /dev/cdrom /media/cdrom    &  mount /dev/cdrom /disk4
镜像文件的挂载:
mount -o loop 镜像 /disk5
---======================================================
(6)配置文件系统自动挂载
系统挂载配置文件主要读取 /etc/fstab,
倒数第二列,表示是否需要转储,0表示不需要。倒数第一列,表示是否要检测,0表示不需要。
[root@weblogic ~]# more /etc/fstab 
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/u01              /u01                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda3         swap                    swap    defaults        0 0
/dev/sdb1               /disk1                  ext3    defaults        0 0
/dev/sdb3               /disk2                  ext3    defaults        0 0

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24237320/viewspace-746981/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: flashback使用(2)
请登录后发表评论 登录
全部评论

注册时间:2010-07-13

  • 博文量
    406
  • 访问量
    1208650