阿里云单独购买的数据盘必须先挂载数据盘的命令和步骤教程
阿里云服务器 | 腾讯云服务器 | 习梦云:高防云服务器 | ZJI:香港日本美国独服 |
LOCVPS服务周到 | HostKvm低调KVM VPS | 傲游主机:优质VPS | 80VPS:老牌VPS主机 |
搬瓦工:CN2 GIA线路 | CloudCone:性价比高 | Vultr:按小时计费VPS | VirMach:超级便宜 |
JustMySocks科学上网 | 好用的宝塔面板 | 洛杉矶QN机房官方VPS | 恒创:香港CN2服务器 |
准备工作
单独 购买的数据盘 必须先 挂载数据盘 才能格式化。随实例一起购买的数据盘,无需挂载。
获取数据盘的设备名。
数据盘的设备名默认由系统分配,从/dev/vdb递增排列,包括/dev/vdb−/dev/vdz。您可以在ECS控制台的云盘页面中,选择 查看。
更多文章,可见 http://www.vpsqk.com/tags/aliyun/
本示例采用一块新的 20 GiB 数据盘,设备名为 /dev/vdb,创建一个单分区数据盘并格式化为 ext4 文件系统。使用 I/O 优化实例,操作系统为 CentOS 7.6。 远程连接实例。 运行 如果数据盘设备名为 执行命令后,如果不存在 /dev/vdb,表示您的实例没有数据盘。确认数据盘是否已挂载。 依次执行以下命令以创建一个单分区数据盘: 运行 输入 输入 输入 输入分区编号并按回车键。本示例中,仅创建一个分区,输入 输入第一个可用的扇区编号:按回车键采用默认值 2048。 输入最后一个扇区编号:本示例仅创建一个分区,按回车键采用默认值。 输入 输入 运行命令 如果出现以下信息,表示新分区 运行命令 本示例中,创建一个 ext4 文件系统。您也可以根据自己的需要,选择创建其他文件系统,例如,如果您需要在 Linux、Windows 和 Mac 系统之间共享文件,可以使用 (建议)运行命令 运行命令 如要把数据盘单独挂载到某个文件夹,例如单独用来存放网页,则将命令中 运行命令 运行命令 运行命令 出现新建文件系统的信息,表示挂载成功,您不需要重启实例即可以使用新的文件系统。操作步骤
fdisk -l
命令查看实例上的数据盘。dev/xvd?
(?
是 a−z 的任意一个字母),表示您使用的是非 I/O 优化实例。fdisk -u /dev/vdb
:分区数据盘。p
:查看数据盘的分区情况。本示例中,数据盘没有分区。n
:创建一个新分区。p
:选择分区类型为主分区。e
(extended)。1
。p
:查看该数据盘的规划分区情况。w
:开始分区,并在分区后退出。# fdisk -u /dev/vdbWelcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partitiON table
Building a new DOS disklabel with disk identifier 0x3e60020e.
Command (m for help): p
Disk /dev/vdb: 21.5 GB, 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
Disk label type: dos
Disk identifier: 0x3e60020e
Device Boot Start End Blocks Id SystemCommand (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is setCommand (m for help): p
Disk /dev/vdb: 21.5 GB, 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
Disk label type: dos
Disk identifier: 0x3e60020e
Device Boot Start End Blocks Id System/dev/vdb1 2048 41943039 20970496 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
fdisk -lu /dev/vdb
查看新分区。/dev/vdb1
创建成功。# fdisk -lu /dev/vdb
Disk /dev/vdb: 21.5 GB, 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
Disk label type: dos
Disk identifier: 0x3e60020eDevice Boot Start End Blocks Id System
/dev/vdb1 2048 41943039 20970496 83 Linux
mkfs.ext4 /dev/vdb1
在新分区上创建一个文件系统。mkfs.vfat
创建 VFAT 文件系统。[root@i##### ~]# mkfs.ext4 /dev/vdb1
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
1310720 inodes, 5242624 blocks
262131 blocks (5.00%) reserved for the super userFirst data block=0
Maximum filesystem blocks=2153775104
160 block groups
32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
cp /etc/fstab /etc/fstab.bak
备份 etc/fstab。echo /dev/vdb1 /mnt ext4 defaults 0 0 >> /etc/fstab
向 /etc/fstab 写入新分区信息。echo '/dev/vdb1 /mnt ext4 barrier=0 0 0' >> /etc/fstab
。/mnt
替换成所需的挂载点路径。cat /etc/fstab
查看 /etc/fstab 中的新分区信息。[root@i##### ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Wed Dec 12 07:53:08 2018#
# 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=d67c3b17-255b-4687-be04-f29190d37396 / ext4 defaults 1 1/dev/vdb1 /mnt ext4 defaults 0 0
mount /dev/vdb1 /mnt
挂载文件系统。df -h
查看目前磁盘空间和使用情况。[root@i##### ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 1.6G 36G 5% /
devtmpfs 234M 0 234M 0% /dev
tmpfs 244M 0 244M 0% /dev/shm
tmpfs 244M 484K 244M 1% /run
tmpfs 244M 0 244M 0% /sys/fs/cgroup
tmpfs 49M 0 49M 0% /run/user/0/dev/vdb1 20G 45M 19G 1% /mnt
评论专区