码迷,mamicode.com
首页 > 其他好文 > 详细

磁盘分区和挂载

时间:2014-08-03 07:56:55      阅读:315      评论:0      收藏:0      [点我收藏+]

标签:contain   虚拟机   企业版   接口   操作系统   

实验目标

  • 为虚拟机添加一块80GB、SCSI接口的硬盘

  • 划分2个20GB的主分区,剩余作为扩展分区

  • 新建2个逻辑分区,分别为2GB、10GB

  • 将第1个逻辑分区的类型改为SWAP(ID 82)

  • 将第2个逻辑分区的类型改为VFAT(ID b)

  • 确认分区无误后,保存退出

  • 使用partprobe识别新的分区表     【最好是重启一次】

1.实验环境

     企业版Linux5.9操作系统

     硬盘一块

 

bubuko.com,布布扣

  • bubuko.com,布布扣

  • bubuko.com,布布扣

  • bubuko.com,布布扣

  • bubuko.com,布布扣

 

2.实验步骤

1.[root@localhost ~]# fdisk    -l                                      查看磁盘块数

   Disk /dev/sdb: 85.8 GB, 85899345920 bytes           磁盘没有分区

   Disk /dev/sdb doesn‘t contain a valid partition table

 

2.[root@localhost ~]# fdisk     /dev/sdb                           磁盘进行分区

 

   Command (m for help): m                                                   查看帮助信息

    Command (m for help): n                                                    添加一个分区

   Command action

   e   extended

   p   primary partition (1-4)

p                                                                                                     添加的分区为主分区

Partition number (1-4): 1                                                         添加第一个主分区

First cylinder (1-10443, default 1):                                         默认系统只需回车键

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-10443, default 10443): +20G        分区大小为20G

 

Command (m for help): p                                                                                     查看分区表

 /dev/sdb1               1        2433    19543041   83  Linux

 Command (m for help): n                                                              添加第二个主分区

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 2

Last cylinder or +size or +sizeM or +sizeK (2434-10443, default 10443): +20g        分区大小为20G

 Command (m for help): p

    Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        2433    19543041   83  Linux

/dev/sdb2            2434        4866    19543072+  83  Linux

 Command (m for help): n                                    添加第三个主分区

Command action

   e   extended

   p   primary partition (1-4)

e                                                                                 类型为扩展分区

Partition number (1-4): 3

Command (m for help): p

     Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        2433    19543041   83  Linux

/dev/sdb2            2434        4866    19543072+  83  Linux

/dev/sdb3            4867       10443    44797252+   5  Extended

 Command (m for help): n                                添加分区

Command action

   l   logical (5 or over)

   p   primary partition (1-4)

l                                                                                   添加第一个逻辑分区(l  代表逻辑分区)

Last cylinder or +size or +sizeM or +sizeK (4867-10443, default 10443): +2G             分区大小2G

 

Command (m for help): n                                    添加分区

Command action

   l   logical (5 or over)

   p   primary partition (1-4)

l                                                                                     添加第二个逻辑分区(l  代表逻辑分区)

Last cylinder or +size or +sizeM or +sizeK (5111-10443, default 10443): +10G        分区大小10G

 

Command (m for help): p                                                                   查看分区结果

    Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        2433    19543041   83  Linux

/dev/sdb2            2434        4866    19543072+  83  Linux

/dev/sdb3            4867       10443    44797252+   5  Extended

/dev/sdb5            4867        5110     1959898+  83  Linux

/dev/sdb6            5111        6327     9775521   83  Linux

 Command (m for help): t                                                   转换分区类型

Partition number (1-6): 5                                   

Hex code (type L to list codes): 82                                   分区类型为交换分区

Changed system type of partition 5 to 82 (Linux swap / Solaris) 

Command (m for help):  n                                                    转换分区类型

Partition number (1-6): 6

Hex code (type L to list codes): b                                       分区类型为windows分区类型

Changed system type of partition 6 to b (W95 FAT32)

Command (m for help): p                                                      查看结果

   Device Boot      Start         End      Blocks   Id  System                

/dev/sdb1               1        2433    19543041   83  Linux

/dev/sdb2            2434        4866    19543072+  83  Linux

/dev/sdb3            4867       10443    44797252+   5  Extended

/dev/sdb5            4867        5110     1959898+  82  Linux swap / Solaris

/dev/sdb6            5111        6327     9775521    b  W95 FAT32

Command (m for help): w                                                    保存退出

 

 [root@localhost ~]# partprobe                                         刷新分区结果

                          

[root@localhost ~]# ls /dev/sdb *                                      查看分区结果

/dev/sdb  /dev/sdb1  /dev/sdb2   /dev/sdb3  /dev/sdb5  /dev/sdb6

 

[root@localhost ~]# mkfs.ext3    /dev/sdb1                    格式化主分区

 [root@localhost ~]# mkfs.ext3   /dev/sdb2                  

[root@localhost ~]# mkswap    /dev/sdb5                       格式化交换分

 

[root@localhost ~]# mkdir   /mnt/sdb1                            新建三个目录

[root@localhost ~]# mkdir   /mnt/sdb2

[root@localhost ~]# mkdir   /mnt/sdb6

 

[root@localhost ~]# mount   /dev/sdb1   /mnt/sdb1           挂载分区到目录

[root@localhost ~]# mount   /dev/sdb2    /mnt/sdb2

[root@localhost ~]# mount   /dev/sdb6    /mnt/sdb6

 

 3.结果验证

[root@localhost ~]# mount                                                         查看分区是否挂载成功

/dev/sdb1 on /mnt/sdb1 type ext3 (rw)

/dev/sdb2 on /mnt/sdb2 type ext3 (rw)

/dev/sdb6 on /mnt/sdb6 type vfat (rw)

 

[root@localhost ~]# swapon  -s                                                 查看交换分区是否挂载

Filename                                Type            Size    Used    Priority

/dev/sdb5                               partition       1959888 0       -2

 

 [root@localhost ~]# df     -hT                                                      查看 分区详细信息                                                  

文件系统      类型    容量  已用可用已用% 挂载点

/dev/sdb1     ext3     19G  173M   18G   1% /mnt/sdb1

/dev/sdb2     ext3     19G  173M   18G   1% /mnt/sdb2

/dev/sdb6     vfat    9.4G  8.0K  9.4G   1% /mnt/sdb6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

本文出自 “Kupig_平” 博客,请务必保留此出处http://baixueping.blog.51cto.com/9126294/1534275

磁盘分区和挂载,布布扣,bubuko.com

磁盘分区和挂载

标签:contain   虚拟机   企业版   接口   操作系统   

原文地址:http://baixueping.blog.51cto.com/9126294/1534275

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!