centos 下挂载新硬盘

1.查看硬盘信息

#fdisk -l
Disk /dev/xvda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008e9bc

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048     2099199     1048576   83  Linux
/dev/xvda2         2099200    83886079    40893440   83  Linux

Disk /dev/xvdb: 322.1 GB, 322122547200 bytes, 629145600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

2.分区

#fdisk /dev/xvdb
fdisk /dev/xvdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x2c4e69bc.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)   //输入p为创建逻辑分区  
   e   extended  //输入e为创建扩展分区
Select (default p): p
Partition number (1-4, default 1): 1  //在这里输入l,就进入划分逻辑分区阶段了
First sector (2048-629145599, default 2048):   //注:这个就是分区的Start 值   这里最好直接按回车,如果您输入了一个非默认的数字,会造成空间浪费
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-629145599, default 629145599): 
Using default value 629145599
Partition 1 of type Linux and of size 300 GiB is set

Command (m for help): w   //最后输入w回车保存
The partition table has been altered!

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

3.再次查看下分区情况

#fdisk -l
Disk /dev/xvda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008e9bc

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048     2099199     1048576   83  Linux
/dev/xvda2         2099200    83886079    40893440   83  Linux

Disk /dev/xvdb: 322.1 GB, 322122547200 bytes, 629145600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x2c4e69bc

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1            2048   629145599   314571776   83  Linux

4.格式化分区

#mkfs.ext3 /dev/xvdb1

5.创建挂载目录

#mkdir /mnt2

6.挂载目录

mount /dev/xvdb1 /mnt2

7.查看磁盘情况

#df -h
/dev/xvda2       39G  2.1G   35G   6% /
devtmpfs        7.8G     0  7.8G   0% /dev
tmpfs           7.8G     0  7.8G   0% /dev/shm
tmpfs           7.8G  8.5M  7.8G   1% /run
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/xvdb1      296G   63M  281G   1% /mnt2

8.配置开机自动挂载

#vim /etc/fstab
/dev/xvdb1(磁盘分区)  /mnt2(挂载目录) ext3(文件格式)defaults  0  0

收工

喜欢 0

这篇文章还没有评论

发表评论

您必须登录才能评论