华为云磁盘挂载与分区扩容

华为云磁盘挂载

    • 华为云磁盘挂载
      • 创建分区过程
    • 华为云分区扩容

华为云磁盘挂载

华为云磁盘满了怎么挂载新增磁盘
查看磁盘使用情况

df  -hl

华为云磁盘挂载与分区扩容_第1张图片
查看购买磁盘

fdisk -l

华为云磁盘挂载与分区扩容_第2张图片
创建挂载目录:

mkdir /data

这里我的挂载点是/root因为我平时将我的一些文件存储到这个位置
华为云磁盘挂载与分区扩容_第3张图片
挂载 :

mount /dev/vdb    /root

在这里插入图片描述
发现报错:

mount: /dev/vdb is write-protected, mounting read-only
mount: unknown filesystem type '(null)'

解决办法:
创建ext4文件系统

mkfs.ext4 /dev/vdb

华为云磁盘挂载与分区扩容_第4张图片
重新挂载:

mount /dev/vdb    /root

查看磁盘使用情况:

df -hT

华为云磁盘挂载与分区扩容_第5张图片
退出挂载

umount   /root

取消挂载之后,挂载之前的文件会恢复
当出现如下错误的时候

[root@hdp01 centos7]#umount   /root
umount: /root: target is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
  1. 查看占用线程
[root@hdp01 centos7]# fuser -m /root
/root:        21746c
  1. 关闭占用线程
kill  -9   21746
  1. 再次取消挂载
umount   /root

创建分区过程

# 查看分区
[root@ecs-3b04-0004 /]# fdisk -l

Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000a6f64

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1            2048     8001535     3999744   82  Linux swap / Solaris
/dev/vda2   *     8001536    83886079    37942272   83  Linux

Disk /dev/vdb: 536.9 GB, 536870912000 bytes, 1048576000 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

#进入分区
[root@ecs-3b04-0004 /]# fdisk /dev/vdb
Welcome 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 0xeda9ebfd.
#m指的是查看分区命令
Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
#n表示建立分区
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
   #默认分区 
Select (default p): p
#建立分区1
Partition number (1-4, default 1): 1
#enter默认初始分区2048
First sector (2048-1048575999, default 2048): 
Using default value 2048
#构建分区大小为100G
Last sector, +sectors or +size{K,M,G} (2048-1048575999, default 1048575999): +100G
Partition 1 of type Linux and of size 100 GiB is set
#w保存
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#将分区同步
[root@ecs-3b04-0004 /]# partprobe
#格式化分区
[root@ecs-3b04-0004 /]# mkfs -t 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
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   
#查看分区
[root@ecs-3b04-0004 /]# lsblk -l
NAME MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda  253:0    0   40G  0 disk 
vda1 253:1    0  3.8G  0 part [SWAP]
vda2 253:2    0 36.2G  0 part /
vdb  253:16   0  500G  0 disk 
vdb1 253:17   0  100G  0 part 
查看分区树结构
[root@ecs-3b04-0004 /]# lsblk -f
NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
vda                                                      
├─vda1 swap   swap  5bf05464-a61a-4962-a70a-e73f39b1141a [SWAP]
└─vda2 xfs          acc22fb1-001c-4909-9f35-4dba7c654405 /
vdb    ext4         ce617cc3-f0f6-41b4-a4ee-26c539b47346 
└─vdb1 ext4         dd9c2b78-af9d-4dac-be38-bddd31780e9f 

挂载、分区参考文档:https://support.huaweicloud.com/qs-evs/evs_01_0033.html

参考文档:https://blog.csdn.net/qq_32901251/article/details/113246916

华为云分区扩容

在购买的华为云服务器上进行扩容
华为云磁盘挂载与分区扩容_第6张图片
扩容之后
华为云磁盘挂载与分区扩容_第7张图片
扩容成功之后需要将扩容的磁盘放入分区(见参考文档)这里注意ubuntu安装软包是用的这个命令apt-get
参考文档:https://support.huaweicloud.com/usermanual-evs/evs_01_0072.html

你可能感兴趣的:(虚拟机,华为云)