Sian 发表于 2015-6-19 17:05:51

CentOS 磁盘挂载(Linux磁盘挂载)

1、 查看新磁盘信息

# fdisk -l

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00060953

    Device Boot      Start         End      Blocks   IdSystem
/dev/xvda1   *         1      2611    20970496   83Linux

Disk /dev/xvdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

2、硬盘分区

2.1、进入fdisk模式
# fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc233737d.
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)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

2.2、输入n进行分区
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)

2.3、选择分区类型,p为主分区,linux上主分区最多能有4个;e为扩展分区,扩展分区 linux上扩展分区只能有1个,扩展分区创建后不能直接使用,还要在扩展分区上创建逻辑分区。这里选择p
p

2.4、选择分区个数,最多可以分4个区,这里就只分一个了。
Partition number (1-4): 1

2.5、设置柱面,这里选择默认值就可以
First cylinder (1-2610, default 1):
Using default value 1

2.6、设置柱面,这里选择默认值就可以
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
Using default value 2610

2.7、输入w,写入分区表,进行分区
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#

3、格式化分区
如果创建的是主分区
# mkfs -t ext3/dev/xvdb

4、挂载硬盘

4.1、创建挂载点
在根目录下创建storage目录
#mkdir /storage

4.2、将/dev/sdb1挂载到/storage下
#mount /dev/xvdb/storage

5、设置开机启动自动挂载

新创建的分区不能开机自动挂载,每次重启机器都要手动挂载。
设置开机自动挂载需要修改/etc/fstab文件
#vi /etc/fstab
在文件的最后增加一行
/dev/sdb5 /storage ext3 defaults 1 2
页: [1]
查看完整版本: CentOS 磁盘挂载(Linux磁盘挂载)