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

华为云磁盘挂载

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

df  -hl

在这里插入图片描述
查看购买磁盘

fdisk -l

在这里插入图片描述
创建挂载目录:

mkdir /data

这里我的挂载点是/root因为我平时将我的一些文件存储到这个位置
在这里插入图片描述
挂载 :

mount /dev/vdb    /root

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

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

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

mkfs.ext4 /dev/vdb

在这里插入图片描述
重新挂载:

mount /dev/vdb    /root

查看磁盘使用情况:

df -hT

在这里插入图片描述
退出挂载

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

华为云分区扩容

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

参考华为云文档之后:
其中步骤报错:

-bash-4.2# resize2fs /dev/vda2
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/vda2
Couldn't find valid filesystem superblock.

发现扩容不成功,原因是因为resize2fs不能够对xfs文件系统进行调整
在这里插入图片描述
解决方案:
xfs_groufs
shell>xfs_growfs /dev/vda2
shell>df -hl

在这里插入图片描述

解释:
XFS支持在线调整大小,要扩展一个现存的XFS文件系统,你可以使用命令行工具xfs_growfs,这在大多数Linux发行版上都默认可用。

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱上编程2705

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值