本文主要介绍了CentOS系统的阿里云ECS服务器中数据盘的格式化和挂载多分区ext4格式的文件系统。
版本 操作系统:CentOS 7.2 64位
适合人群:linux运维人员
步骤
查看文件系统的使用情况:
通过"df -h "命令查看当前文件系统的使用情况,可以观察到文件系统的名称、总容量、已用、可用、使用比例、挂载点等信息。
命令:
[user1@iz8vb62snc6e5cage5yvz9z /]$ df -h
文件系统的名称 总容量 已用 可用 使用比例 挂载点
![0c20d5f24e8e4215935d76abbcef49f5.png](https://img-blog.csdnimg.cn/img_convert/0c20d5f24e8e4215935d76abbcef49f5.png)
20G系统盘/dev/vda
![47eb13dab1ff6ed16d7eb1ecb1a5b8d8.png](https://img-blog.csdnimg.cn/img_convert/47eb13dab1ff6ed16d7eb1ecb1a5b8d8.png)
50GB的数据盘/dev/vdb
![424093f71c1110c02dee545dde1928bd.png](https://img-blog.csdnimg.cn/img_convert/424093f71c1110c02dee545dde1928bd.png)
如果有旧的分区,可以输入d进行删除。
![d900e45f5fde38ca01ae2009b92ee0a7.png](https://img-blog.csdnimg.cn/img_convert/d900e45f5fde38ca01ae2009b92ee0a7.png)
首先输入 n 并按回车键:创建一个新分区。
![479c6662107f38d9bde4977002007405.png](https://img-blog.csdnimg.cn/img_convert/479c6662107f38d9bde4977002007405.png)
输入 p 并按回车键:选择主分区类型
![2c21381a9c6760c45eb404c4c4d67b4f.png](https://img-blog.csdnimg.cn/img_convert/2c21381a9c6760c45eb404c4c4d67b4f.png)
输入分区编号并按回车键
![8d925f27a58a326a08f3f08d85deb73b.png](https://img-blog.csdnimg.cn/img_convert/8d925f27a58a326a08f3f08d85deb73b.png)
输入第一个扇区的编号
![e35b13ca2fe1451f1ecb2ff033224d76.png](https://img-blog.csdnimg.cn/img_convert/e35b13ca2fe1451f1ecb2ff033224d76.png)
输入最后一个扇区的编号
![3360311539fe5d20e2d4c373f97df4ca.png](https://img-blog.csdnimg.cn/img_convert/3360311539fe5d20e2d4c373f97df4ca.png)
重复执行上述4个步骤,创建第二个分区
![1b2bddf58584a379160d47fdc780da6d.png](https://img-blog.csdnimg.cn/img_convert/1b2bddf58584a379160d47fdc780da6d.png)
最后输入 wq 并按回车键,开始分区
![9c16e6a649d3c34dd3112c1552ab1e79.png](https://img-blog.csdnimg.cn/img_convert/9c16e6a649d3c34dd3112c1552ab1e79.png)
![8590247ac783f57f5aeed5de1949789d.png](https://img-blog.csdnimg.cn/img_convert/8590247ac783f57f5aeed5de1949789d.png)
上述操作创建的分区/dev/vdb1与/dev/vdb2
![baccd0a7bd19bacf180b6dbdefc001ca.png](https://img-blog.csdnimg.cn/img_convert/baccd0a7bd19bacf180b6dbdefc001ca.png)
![f5f7830dffa63b6246ca8afbfae78d39.png](https://img-blog.csdnimg.cn/img_convert/f5f7830dffa63b6246ca8afbfae78d39.png)
备份分区信息文件
![bd76020bd0bcc9749a43dd6c40b66d24.png](https://img-blog.csdnimg.cn/img_convert/bd76020bd0bcc9749a43dd6c40b66d24.png)
user1用户使用sudo执行命令提示权限不足,切换到root账户下执行命令
![dbfea842abd8d19d13422b97b0b63c93.png](https://img-blog.csdnimg.cn/img_convert/dbfea842abd8d19d13422b97b0b63c93.png)
追加/dev/vdb1的分区信息,该分区挂载的路径为/home/user1/redis/data,格式为ext4
![83afe1e6d2572b6f71f26b1b88c21ed8.png](https://img-blog.csdnimg.cn/img_convert/83afe1e6d2572b6f71f26b1b88c21ed8.png)
追加/dev/vdb2的分区信息,该分区挂载的路径为/home/user1/program,格式为ext4
![446d1047a4934e2e28cbf0a4304b59c8.png](https://img-blog.csdnimg.cn/img_convert/446d1047a4934e2e28cbf0a4304b59c8.png)
查看分区信息
![355e5fd65b0db65231336b384aa2f047.png](https://img-blog.csdnimg.cn/img_convert/355e5fd65b0db65231336b384aa2f047.png)
使用mount将分区挂载到对应的路径下
![78f490fb0e02e8505c266bfcddaf30d6.png](https://img-blog.csdnimg.cn/img_convert/78f490fb0e02e8505c266bfcddaf30d6.png)
使用df -h观察挂载后的文件系统
![8b0e789d5e50d4744785ed9d9380a3f0.png](https://img-blog.csdnimg.cn/img_convert/8b0e789d5e50d4744785ed9d9380a3f0.png)
![71b7033bdb3ec61be83e5cf5f72a1f79.gif](https://img-blog.csdnimg.cn/img_convert/71b7033bdb3ec61be83e5cf5f72a1f79.gif)
扫码加入阿里云云栖社群
![b03c1964459fb9b0fa47a457c7c19122.png](https://img-blog.csdnimg.cn/img_convert/b03c1964459fb9b0fa47a457c7c19122.png)