1. 查看磁盘情况: fdisk -l
[root@xxxx/]# 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: 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 /dev/vdb
2. 格式化云盘
[root@xxxx /]# sudo mkfs.ext4 /dev/vdb
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
2621440 inodes, 10485760 blocks
524288 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2157969408
320 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
3. 创建目录 mkdir /xymiao用户挂载磁盘.
[root@xxxx/]# mkdir /xymiao
4. 挂载磁盘
sudo mount /dev/vdb /xymiao
将磁盘挂载到 /xymiao中.
5. 配置开机自动挂载
修改/etc/fstab文件, 文件末尾添加:
/dev/vdb /opt ext4 defaults 0 0
6. 重启检查是否配置成功
使用: init 6
sudo df -h
[root@xxxx ~]# sudo df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 1.3G 36G 4% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 292K 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/vdb 40G 49M 38G 1% /xymiao
tmpfs 380M 0 380M 0% /run/user/0
可以看到了, 已经挂载成功了.