1.前言
之前买的阿里云主机,都装的windows,默认数据盘已经挂载好了,不需要额外处理。此次装了CentOS,因不大熟悉,所以记录下挂载数据盘步骤,备查。
2.主要步骤
2.1 系统环境
Welcome to Alibaba Cloud Elastic Compute Service !
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Wed Sep 16 08:49:31 2020 from 122.226.XXX.XX
[root@ZSSM01 ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 8.2.2004 (Core)
Release: 8.2.2004
Codename: Core
2.2 查看数据盘
[root@ZSSM01 ~]# fdisk -l
Disk /dev/vda: 60 GiB, 64424509440 bytes, 125829120 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
Disklabel type: dos
Disk identifier: 0xe8c25923
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 125829086 125827039 60G 83 Linux
Disk /dev/vdb: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: dos
Disk identifier: 0x1d881b58
Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 41943039 41940992 20G 83 Linux
查看磁盘情况,本次机器系统盘为vda:60G,数据盘为vdb:20G 。
2.3 对数据盘分区
[root@ZSSM01 ~]# fdisk /dev/vdb
一般选择主分区(primary),而不是扩展分区(extended)。
2.4 格式化分区
[root@ZSSM01 ~]# mkfs.xfs/dev/vdb1
采用xfs文件格式——由于虚拟化的应用越来越广泛,虚拟化磁盘来源的举行文件越来越常见,这些巨型文件在处理上通常要考虑性能问题,而xfs比较适合高容量磁盘与巨型文件,且性能较佳的文件系统。查看下分区的文件系统类型:
[root@ZSSM01 ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
devtmpfs devtmpfs 3910024 0 3910024 0% /dev
tmpfs tmpfs 3925512 4 3925508 1% /dev/shm
tmpfs tmpfs 3925512 480 3925032 1% /run
tmpfs tmpfs 3925512 0 3925512 0% /sys/fs/cgroup
/dev/vda1 xfs 62903276 3995704 58907572 7% /
/dev/vdb1 xfs 20960256 200156 20760100 1% /data
tmpfs tmpfs 785100 0 785100 0% /run/user/0
2.5 创建挂载目录
root@ZSSM01 ~]# mkdir /data
2.6 挂载分区
[root@ZSSM01 ~]# mount /dev/vdb1 /data
2.7 开机自动挂载
在/etc/fstab文件中增加:/dev/vdb1 /data xfs defaults 0 0,写入分区信息。
#
# /etc/fstab
# Created by anaconda on Fri Jul 17 01:52:46 2020
#
# 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=164ac213-772b-4fa6-bf8a-ea46fb809a83 / xfs defaults 0 0
/dev/vdb1 /data xfs defaults 0 0
2.8 小结
查看挂载后的情况:
[root@ZSSM01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.8G 4.0K 3.8G 1% /dev/shm
tmpfs 3.8G 488K 3.8G 1% /run
tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup
/dev/vda1 60G 3.9G 57G 7% /
/dev/vdb1 20G 196M 20G 1% /data
tmpfs 767M 0 767M 0% /run/user/0
本文详细记录了在阿里云CentOS 8.2环境中,如何查看、分区、格式化、创建挂载目录、挂载数据盘以及设置开机自动挂载的步骤,旨在提供一种快速参考指南。

6736

被折叠的 条评论
为什么被折叠?



