阿里云服务器上买了一个云盘需要挂载到服务器上,这里记录一下,默认阿里是不会帮我们挂载的
1. 查看系统挂载目录的情况
df -h
[root@iZbp16b2z9ui0h530heg1jZ ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 480K 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/vda1 30G 17G 14G 55% /
tmpfs 378M 0 378M 0% /run/user/0
2.查看未挂载的盘
df -l
[root@iZbp16b2z9ui0h530heg1jZ ~]# df -l
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 1918744 0 1918744 0% /dev
tmpfs 1934224 0 1934224 0% /dev/shm
tmpfs 1934224 480 1933744 1% /run
tmpfs 1934224 0 1934224 0% /sys/fs/cgroup
/dev/vda1 31445996 17071244 14374752 55% /
tmpfs 386844 0 386844 0% /run/user/0
[root@iZbp16b2z9ui0h530heg1jZ ~]# fdisk -l
Disk /dev/vda: 30 GiB, 32212254720 bytes, 62914560 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: 0x319ba3a3
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 62914526 62912479 30G 83 Linux
Disk /dev/vdb: 30 GiB, 32212254720 bytes, 62914560 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
3.挂载磁盘到/disk/d目录中
先创建目录
[root@iZbp16b2z9ui0h530heg1jZ ~]# mkdir -p /disk/d
fdisk 硬盘分区(依次输入:n -> p -> 回车 -> 回车 -> wq)
[root@iZbp16b2z9ui0h530heg1jZ /]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.32.1).
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.
Created a new DOS disklabel with disk identifier 0x3044a432.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-62914559, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-62914559, default 62914559):
Created a new partition 1 of type 'Linux' and of size 30 GiB.
Command (m for help): wq
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
查看磁盘设备
[root@iZbp16b2z9ui0h530heg1jZ /]# fdisk -l
Disk /dev/vda: 30 GiB, 32212254720 bytes, 62914560 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: 0x319ba3a3
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 62914526 62912479 30G 83 Linux
Disk /dev/vdb: 30 GiB, 32212254720 bytes, 62914560 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: 0x3044a432
Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 62914559 62912512 30G 83 Linux
格式化 /dev/vdb1 为 ext4
[root@iZbp16b2z9ui0h530heg1jZ /]# mkfs .ext4 /dev/vdb1
mke2fs 1.45.4 (23-Sep-2019)
mkfs.ext2: invalid blocks '/dev/vdb1' on device '.ext4'
[root@iZbp16b2z9ui0h530heg1jZ /]# mkfs.ext4 /dev/vdb1
mke2fs 1.45.4 (23-Sep-2019)
Creating filesystem with 7864064 4k blocks and 1966080 inodes
Filesystem UUID: 4b071292-9a89-4723-9149-9f81421724e5
Superblock 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
挂载设备到/disk/d
[root@iZbp16b2z9ui0h530heg1jZ /]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Nov 20 06:36:28 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=edf839fd-8e1a-4373-946a-c32c9b459611 / xfs defaults 0 0
/dev/vdb1 /disk/d ext4 defaults 0 0
挂载测试(无错误即可)
mount -a
然后查看系统目录
[root@iZbp16b2z9ui0h530heg1jZ /]# df -l
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 1918744 0 1918744 0% /dev
tmpfs 1934224 0 1934224 0% /dev/shm
tmpfs 1934224 484 1933740 1% /run
tmpfs 1934224 0 1934224 0% /sys/fs/cgroup
/dev/vda1 31445996 17873724 13572272 57% /
tmpfs 386844 0 386844 0% /run/user/0
/dev/vdb1 30831524 45080 29197248 1% /disk/d
已经挂载完成