服务器挂载新的数据盘.
查看数据盘
执行
fdisk -l
在没有分区和格式化数据盘之前,使用 df -h 命令是无法看到数据盘的
结果显示:
Disk /dev/vda: 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: 0x635e6c7d
Device Boot Start End Blocks Id System
/dev/vda1 2048 83886079 41942016 83 Linux
Disk /dev/vdb: 85.9 GB, 85899345920 bytes, 167772160 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
如果没有/dev/vdb
表示没有数据盘需要挂载
数据盘分区
执行
fdisk /dev/vdb
根据提示,依次输入 n,p,1,两次回车,wq
,数据盘就开始分区了.
过程显示:
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 0x8ea4d8ea.
Command (m for help): n //输入n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p //输入p
Partition number (1-4, default 1): 1 //输入1
First sector (2048-167772159, default 2048): //输入enter
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-167772159, default 167772159): //输入enter
Using default value 167772159
Partition 1 of type Linux and of size 80 GiB is set
Command (m for help): wq //输入wq保存
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks. //分区完成
查看分区
执行
fdisk -l
结果显示:
Disk /dev/vda: 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: 0x635e6c7d
Device Boot Start End Blocks Id System
/dev/vda1 2048 83886079 41942016 83 Linux
Disk /dev/vdb: 85.9 GB, 85899345920 bytes, 167772160 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: 0x8ea4d8ea
Device Boot Start End Blocks Id System
/dev/xvdb1 2048 167772159 83885056 83 Linux
可以查看到分区 /dev/vdb1
分区格式化
执行命令
mkfs.ext3 /dev/vdb1 //文件格式可选,如果ext4 mkfs.ext4 /dev/vdb1
结果显示
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
5242880 inodes, 20971264 blocks
1048563 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
640 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
新建挂载目录
执行
mkdir /www
写入分区信息
执行
echo /dev/vdb1 /www ext3 defaults 0 0 >> /etc/fstab // /www为挂载目录
使用命令查看分区信息
cat /etc/fstab
结果显示:
#
# /etc/fstab
# Created by anaconda on Tue May 3 13:48:10 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=80b9b662-0a1d-4e84-b07b-c1bf19e72d97 / ext4 defaults 1 1
/dev/vdb1 /www ext3 defaults 0 0
数据盘挂载
执行
mount /dev/vdb1 /www
查看结果
执行
df -h