1. ssh登录云主机,查看磁盘状况
[root@MyCloudServer ~]# fdisk -l
Disk /dev/xvda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x000858c5
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2 64 1306 9972736 8e Linux LVM
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
从查询结果看出,一般我们需要挂载的是/dev/xvdb的盘
2. 用fdisk 对/dev/xvdb 进行分区
[root@MyCloudServer ~]# fdisk /dev/xvdb
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-652, default 2610):
Using default value 2610
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
再次查看分区情况,多出来一个/dev/xvdb1 的区,这个1是我们在前面指定的,如果我们指定2,就变成 xvdb2了。
[root@MyCloudServer ~]# fdisk -l
Disk /dev/xvda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x000858c5
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2 64 1306 9972736 8e Linux LVM
Disk /dev/xvdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280
bytesSector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/xvdb1 1 652 5237158+ 83 Linux
[root@MyCloudServer ~]#
3. 格式化 /dev/xvdb1 分区
[root@MyCloudServer ~]# mkfs -t ext3 /dev/xvdb1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
655360 inodes, 1309289 blocks
65464 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
4. 在根目录下创建目录 并将 /dev/sdb1 挂在到该目录下
[root@MyCloudServer ~]# cd /
[root@MyCloudServer ~]# mkdir /data
[root@MyCloudServer ~]# ls
bin boot data dev etc home lib lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr var
[root@MyCloudServer ~]# mount /dev/xvdb1 /data
5. 验证挂载是否成功
[root@MyCloudServer ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 9131772 7066884 1601012 82% /
none 454256 0 454256 0% /dev/shm
/dev/xvdb1 5154852 43040 4849956 1% /data
6. 设置开机自动挂载
[root@MyCloudServer ~]# vi /etc/fstab
在文本最下面添加
/dev/xvdb1 /data ext3 defaults 0 0
然后保存退出。