腾讯云服务器挂载云硬盘

1、到腾讯云服务器购买一块云硬盘,然后直接挂载到你的服务器下就可以了,如果服务器不能识别,请看​​部分存量云服务器无法识别弹性云盘的解决方法​

2、挂载完云硬盘之后,云硬盘默认处于未加载状态,使用df -h指令可以看见服务器中硬盘的加载状况,如下:

ubuntu@VM-164-254-ubuntu:/$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 414M 0 414M 0% /dev
tmpfs 87M 9.4M 78M 11% /run
/dev/vda1 20G 4.5G 15G 24% /
tmpfs 433M 48K 433M 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 433M 0 433M 0% /sys/fs/cgroup
tmpfs 87M 0 87M 0% /run/user/500
ubuntu@VM-164-254-ubuntu:/$ cd etc/

,没有相关硬盘信息,使用fdisk -l查看所有硬盘信息:

ubuntu@VM-164-254-ubuntu:/$ sudo fdisk -l
Disk /dev/ram0: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram1: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram2: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram3: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram4: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram5: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram6: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram7: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram8: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram9: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram10: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram11: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram12: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram13: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram14: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/ram15: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/vda: 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: 0x27921508

Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 41943039 41940992 20G 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
ubuntu@VM-164-254-ubuntu:/$

根据最后一段disk可以看到事这块30G的硬盘没有加载,所以接下来使用

腾讯云服务器挂载云硬盘_ubuntu

进行磁盘分区:

ubuntu@VM-164-254-ubuntu:/$ sudo fdisk /dev/vdb

Welcome to fdisk (util-linux 2.27.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 0x0d50e367.

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): 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.

ubuntu@VM-164-254-ubuntu:/$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 414M 0 414M 0% /dev
tmpfs 87M 9.4M 78M 11% /run
/dev/vda1 20G 4.5G 15G 24% /
tmpfs 433M 48K 433M 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 433M 0 433M 0% /sys/fs/cgroup
tmpfs 87M 0 87M 0% /run/user/500
ubuntu@VM-164-254-ubuntu:/$ mkfs.ext3 /dev/vdb1
mke2fs 1.42.13 (17-May-2015)
Could not open /dev/vdb1: Permission denied
ubuntu@VM-164-254-ubuntu:/$ sudo mkfs.ext3 /dev/vdb1
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 7864064 4k blocks and 1966080 inodes
Filesystem UUID: 3b8757e2-f85a-41ed-b4c8-eceb1c10aa3f
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

ubuntu@VM-164-254-ubuntu:/$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 414M 0 414M 0% /dev
tmpfs 87M 9.4M 78M 11% /run
/dev/vda1 20G 4.5G 15G 24% /
tmpfs 433M 48K 433M 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 433M 0 433M 0% /sys/fs/cgroup
tmpfs 87M 0 87M 0% /run/user/500
ubuntu@VM-164-254-ubuntu:/$

分区完成之后,进行挂载,首先创建一个待挂载的目录:

ubuntu@VM-164-254-ubuntu:/var/www/html/test/adminweb$ mkdir tuijian

挂载分区有两种办法:
1、直接使用mount指令:

ubuntu@VM-164-254-ubuntu:/var/www/html/test/adminweb$ sudo mount /dev/vdb1 ./tuijian

2、写入到/dev/fstab文件中,操作系统开机启动时会检查这个文件并自动加载

vi /dev/fstab
/dev/vdb1 /var/www/html/test/adminweb/tuijian exy3 defaults 0 0

保存之后就行了,使用

腾讯云服务器挂载云硬盘_ubuntu_02

查看:

ubuntu@VM-164-254-ubuntu:/var/www/html/test/adminweb$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 414M 0 414M 0% /dev
tmpfs 87M 9.4M 78M 11% /run
/dev/vda1 20G 4.5G 15G 24% /
tmpfs 433M 48K 433M 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 433M 0 433M 0% /sys/fs/cgroup
tmpfs 87M 0 87M 0% /run/user/500
/dev/vdb1 30G 45M 28G 1% /var/www/html/test/adminweb/tuijian

挂载成功。后面更新扩容教程