第一步:在阿里云创建云盘(必须和挂载的服务器是一个区域一个分区)
购买完之后在阿里云上面先挂载
第二步:创建磁盘分区
[root@iZj6c45wku1lv9c4w5dlpqZ ~]# fdisk -l 查看现有磁盘分区
Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00020f03Device Boot Start End Blocks Id System
/dev/vda1 * 1 5222 41940992 83 LinuxDisk /dev/vdb: 128.8 GB, 128849018880 bytes
16 heads, 63 sectors/track, 249660 cylindersUnits = cylinders of 1008 * 512 = 516096 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000对未分区磁盘进行分区
[root@iZj6c45wku1lv9c4w5dlpqZ ~]# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0x78851959.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').Command (m for help): m 查看帮助
Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)Command (m for help): n 新增加分区
Command action e extended p primary partition (1-4)p 基本分区Partition number (1-4): 1 分区编号First cylinder (1-249660, default 1): Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-249660, default 249660): Using default value 249660Command (m for help): w 写入修改
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks.[root@iZj6c45wku1lv9c4w5dlpqZ ~]# [root@iZj6c45wku1lv9c4w5dlpqZ ~]# fdisk -l 查看新建分区Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00020f03Device Boot Start End Blocks Id System
/dev/vda1 * 1 5222 41940992 83 LinuxDisk /dev/vdb: 128.8 GB, 128849018880 bytes
16 heads, 63 sectors/track, 249660 cylindersUnits = cylinders of 1008 * 512 = 516096 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x78851959Device Boot Start End Blocks Id System
/dev/vdb1 1 249660 125828608+ 83 Linux
将新建分区格式为ext4格式
[root@iZj6c45wku1lv9c4w5dlpqZ ~]# mkfs -t ext4 /dev/vdb1 将新建分区格式为ext4格式mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks7864320 inodes, 31457152 blocks1572857 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=4294967296960 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872Writing inode tables: done
Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.[root@iZj6c45wku1lv9c4w5dlpqZ ~]# fdisk -l 查看分区列表Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00020f03Device Boot Start End Blocks Id System
/dev/vda1 * 1 5222 41940992 83 LinuxDisk /dev/vdb: 128.8 GB, 128849018880 bytes
16 heads, 63 sectors/track, 249660 cylindersUnits = cylinders of 1008 * 512 = 516096 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x78851959Device Boot Start End Blocks Id System
/dev/vdb1 1 249660 125828608+ 83 Linux 第三步:挂载上要指定的目录(当挂载的目录下面有数据的时候把数据移出再挂载,否则挂载上目录下面会没有数据) [root@iZj6c45wku1lv9c4w5dlpqZ ~]# mount /dev/vdb1 /mnt 将分区挂载到/mnt下[root@iZj6c45wku1lv9c4w5dlpqZ ~]#
第四步:可以设置开机自动挂载
[root@iZj6c45wku1lv9c4w5dlpqZ ~]# [root@iZj6c45wku1lv9c4w5dlpqZ ~]# blkid 查看磁盘UUID/dev/vda1: UUID="a3b07a51-3009-4ddf-9240-81333f13880e" TYPE="ext4" /dev/vdb1: UUID="883cb023-0e52-45d0-bc4f-a40b0247bd99" TYPE="ext4" [root@iZj6c45wku1lv9c4w5dlpqZ ~]# [root@iZj6c45wku1lv9c4w5dlpqZ ~]#[root@iZm5e9eb5azhksxowz185wZ ~]# cat /etc/fstab
#
# /etc/fstab# Created by anaconda on Fri Feb 24 02:58:22 2017## 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=07151862-c2b9-45dc-bfndfasdssddfcadd / ext3 defaults 1 1UUID="a3b07a51-3009-4ddf-9240-81333f13880e /mnt ext4 defaults 0 0[root@iZm5e9eb5azhksxowz185wZ ~]#