VMware7下CentOS5.6磁盘分区

一.总结一下CentOS的磁盘分区:

1.查看硬盘内的相关信息,看是否可以继续进行分区(我的虚拟机中只有一块硬盘,为/dev/sda,别的Linux版本可能是/dev/hda)

    [root@bogon ~]# fdisk /dev/sda

 

 

The number of cylinders for this disk is set to 2610.

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)

 

    #2610表示共有2610个柱面,故分区只可以到第2610

Command (m for help): m           #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: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        1912    15358108+  83  Linux

/dev/sda2            1913        1979      538177+  82  Linux swap / Solaris

 

#从/edv/sda2可看出才分到1979,总共可分到2610,故可在进行分区

 

2.继续新增分区

 

 

Command (m for help): n    #输入n,新增分区

Command action

   e   extended                     #拓展分区

   p   primary partition (1-4)   #主分区

e                                           #添加拓展分区

Partition number (1-4): 3     #随便填一个没有的分区号,注意最多有四个主分区,若还想多分,则必须是3个主分区再加拓展分区

First cylinder (1980-2610, default 1980):

Using default value 1980

Last cylinder or +size or +sizeM or +sizeK (1980-2610, default 2610):       #也可自己选择大小如:+1G

Using default value 2610

 

Command (m for help): p    #打印

 

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        1912    15358108+  83  Linux

/dev/sda2            1913        1979      538177+  82  Linux swap / Solaris

/dev/sda3            1980        2610     5068507+   5  Extended

 

Command (m for help): d     #删除分区

Partition number (1-5): 3

 

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 3

First cylinder (1980-2610, default 1980):

Using default value 1980

Last cylinder or +size or +sizeM or +sizeK (1980-2610, default 2610):

Using default value 2610

 

Command (m for help): p

 

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        1912    15358108+  83  Linux

/dev/sda2            1913        1979      538177+  82  Linux swap / Solaris

/dev/sda3            1980        2610     5068507+  83  Linux

 

Command (m for help):     w    #保存离开,若是练习则输入q,不保存离开

 

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

 

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

[root@bogon ~]# reboot

 

   

3.磁盘格式化:mke2fes -j -L "fdiskTest" /dev/sda3    #将刚刚建立的/dev/sda3格式化为ext3,且名称为fdiskTest

                 命令执行完如下:

 

mke2fs 1.39 (29-May-2006)

Filesystem label=fdiskTest

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

633984 inodes, 1267126 blocks

63356 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1300234240

39 block groups

32768 blocks per group, 32768 fragments per group

16256 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736

 

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 34 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@bogon ~]#


 

 

4.磁盘检验:fsck -C -t ext3 /dev/sda3    #检查前面我们建立的/dev/sda3设备

              fsck 1.39 (29-May-2006)

     e2fsck 1.39 (29-May-2006)

     fdiskTest: clean, 11/633984 files, 55186/1267126 blocks

     [root@bogon ~]#    

 

5.磁盘载入:将刚建立的/dev/sda3载入到/fdiskTest

        mkdir /fdiskTest

       mount -t ext3 /dev/sda3 /fdiskTest

       df 

6.设置启动载入

     在/etc/fstab中设置

  vi /etc/fstab

 #在文件中添加  LABEL=fdiskTest /fdiskTest ext3 defaults 0 0

 

 

 

补充:

   查看系统分区情况命令:    fd -h

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(centos)