KVM磁盘扩容

简介:

对于qcow2格式的虚拟磁盘扩容。


  1. 查看磁盘格式

1
2
3
4
5
6
[root@111 ~] # qemu-img info /kvm/kvm2/xy2.img.qcow2
image:  /kvm/kvm2/xy2 .img.qcow2
file  format : qcow2
virtual size: 10G (10737418240 bytes)
disk size: 1.8G
cluster_size: 65536

2.增加容量

1
2
[root@111 ~] # qemu-img resize /kvm/kvm2/xy2.img.qcow2 +2G
Image resized.

3.查看是否增加容量

1
2
3
4
5
6
[root@111 ~] # qemu-img info /kvm/kvm2/xy2.img.qcow2
image:  /kvm/kvm2/xy2 .img.qcow2
file  format : qcow2
virtual size: 12G (12884901888 bytes)
disk size: 1.8G
cluster_size: 65536

4.查看虚拟机

1
2
3
4
5
6
[root@111 ~] # virsh list --all
  Id    名称                         状态
----------------------------------------------------
  -     xiayun1                        关闭
  -     xy1                            关闭
  -     xy2                            关闭

5.连接到虚拟机

1
2
3
4
[root@111 ~] # virsh start xy2 --console
域 xy2 已开始
连接到域 xy2
Escape character is ^]

6.查看磁盘分区是否增加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[root@localhost ~] # fdisk -l
 
Disk  /dev/vda : 12.9 GB, 12884901888 bytes
16 heads, 63 sectors /track , 24966 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical /physical ): 512 bytes / 512 bytes
I /O  size (minimum /optimal ): 512 bytes / 512 bytes
Disk identifier: 0x0002fcf1
 
    Device Boot      Start         End      Blocks   Id  System
/dev/vda1    *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2             1018       20806     9972736   8e  Linux LVM
Partition 2 does not end on cylinder boundary.
 
Disk  /dev/mapper/VolGroup-lv_root : 9168 MB, 9168748544 bytes
255 heads, 63 sectors /track , 1114 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical /physical ): 512 bytes / 512 bytes
I /O  size (minimum /optimal ): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
 
Disk  /dev/mapper/VolGroup-lv_swap : 1040 MB, 1040187392 bytes
255 heads, 63 sectors /track , 126 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical /physical ): 512 bytes / 512 bytes
I /O  size (minimum /optimal ): 512 bytes / 512 bytes
Disk identifier: 0x00000000

7.磁盘分区[root@localhost ~]# fdisk /dev/vda

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
          switch off the mode ( command  'c' ) and change display  units  to
          sectors ( command  'u' ).
 
Command (m  for  help): p
 
Disk  /dev/vda : 12.9 GB, 12884901888 bytes
16 heads, 63 sectors /track , 24966 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical /physical ): 512 bytes / 512 bytes
I /O  size (minimum /optimal ): 512 bytes / 512 bytes
Disk identifier: 0x0002fcf1
 
    Device Boot      Start         End      Blocks   Id  System
/dev/vda1    *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2             1018       20806     9972736   8e  Linux LVM
Partition 2 does not end on cylinder boundary.
 
Command (m  for  help): n
Command action
    e   extended
    p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1-24966, default 1): 20807
Last cylinder, +cylinders or +size{K,M,G} (20807-24966, default 24966):
Using default value 24966
 
Command (m  for  help): p
 
Disk  /dev/vda : 12.9 GB, 12884901888 bytes
16 heads, 63 sectors /track , 24966 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical /physical ): 512 bytes / 512 bytes
I /O  size (minimum /optimal ): 512 bytes / 512 bytes
Disk identifier: 0x0002fcf1
 
    Device Boot      Start         End      Blocks   Id  System
/dev/vda1    *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2             1018       20806     9972736   8e  Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/vda3            20807       24966     2096640   83  Linux
 
Command (m  for  help): w
The partition table has been altered!
 
Calling ioctl() to re- read  partition table.
 
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

8.查看是否有vda3

ls /dev/vda3

若没有 ,virsh destroy xy2;virsh start xy2 --console  关闭虚拟机重启

9.创建物理卷

1
2
[root@localhost ~] # pvcreate /dev/vda3
   Physical volume  "/dev/vda3"  successfully created

10.得到物理卷的概要信息

1
2
3
4
[root@localhost ~] # pvs
   PV         VG       Fmt  Attr PSize PFree
   /dev/vda2   VolGroup lvm2 a--  9.51g    0
   /dev/vda3            lvm2 a--  2.00g 2.00g

11.加入物理卷

1
2
[root@localhost ~] # vgextend VolGroup /dev/vda3
   Volume group  "VolGroup"  successfully extended

12.查看物理卷组

1
2
3
[root@localhost ~] # vgs
   VG        #PV #LV #SN Attr   VSize  VFree
   VolGroup   2   2   0 wz--n- 11.50g 2.00g

13.查看逻辑卷组

1
2
3
4
[root@localhost ~] # lvs
   LV      VG       Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
   lv_root VolGroup -wi-ao----   8.54g                                           
   lv_swap VolGroup -wi-ao---- 992.00m

14.全部分配空间

1
2
3
[root@localhost ~] #  lvextend -l +100%FREE /dev/VolGroup/lv_root
   Extending logical volume lv_root to 10.54 GiB
   Logical volume lv_root successfully resized

15.df -h 

1
2
3
4
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root   8.5G  736M  7.3G  10% /
tmpfs                         246M     0  246M   0%  /dev/shm
/dev/vda1                      485M   33M  427M   8%  /boot

16.resize2fs /dev/VolGroup/lv_root

17.df -h 

1
2
3
4
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root    11G  738M  9.2G   8% /
tmpfs                         246M     0  246M   0%  /dev/shm
/dev/vda1                      485M   33M  427M   8%  /boot

成功扩容!





      本文转自YU文武貝 51CTO博客,原文链接:http://blog.51cto.com/linuxerxy/1729647,如需转载请自行联系原作者






相关文章
|
28天前
|
人工智能 自然语言处理 Shell
🦞 如何在 OpenClaw (Clawdbot/Moltbot) 配置阿里云百炼 API
本教程指导用户在开源AI助手Clawdbot中集成阿里云百炼API,涵盖安装Clawdbot、获取百炼API Key、配置环境变量与模型参数、验证调用等完整流程,支持Qwen3-max thinking (Qwen3-Max-2026-01-23)/Qwen - Plus等主流模型,助力本地化智能自动化。
37872 151
🦞 如何在 OpenClaw (Clawdbot/Moltbot) 配置阿里云百炼 API
|
10天前
|
人工智能 自然语言处理 监控
OpenClaw skills重构量化交易逻辑:部署+AI全自动炒股指南(2026终极版)
2026年,AI Agent领域最震撼的突破来自OpenClaw(原Clawdbot)——这个能自主规划、执行任务的智能体,用50美元启动资金创造了48小时滚雪球至2980美元的奇迹,收益率高达5860%。其核心逻辑堪称教科书级:每10分钟扫描Polymarket近千个预测市场,借助Claude API深度推理,交叉验证NOAA天气数据、体育伤病报告、加密货币链上情绪等多维度信息,捕捉8%以上的定价偏差,再通过凯利准则将单仓位严格控制在总资金6%以内,实现低风险高频套利。
4799 39
|
6天前
|
存储 人工智能 负载均衡
阿里云OpenClaw多Agent实战宝典:从极速部署到AI团队搭建,一个人=一支高效军团
在AI自动化时代,单一Agent的“全能模式”早已无法满足复杂任务需求——记忆臃肿导致响应迟缓、上下文污染引发逻辑冲突、无关信息加载造成Token浪费,这些痛点让OpenClaw的潜力大打折扣。而多Agent架构的出现,彻底改变了这一现状:通过“单Gateway+多分身”模式,让一个Bot在不同场景下切换独立“大脑”,如同组建一支分工明确的AI团队,实现创意、写作、编码、数据分析等任务的高效协同。
1445 22
|
23天前
|
人工智能 安全 机器人
OpenClaw(原 Clawdbot)钉钉对接保姆级教程 手把手教你打造自己的 AI 助手
OpenClaw(原Clawdbot)是一款开源本地AI助手,支持钉钉、飞书等多平台接入。本教程手把手指导Linux下部署与钉钉机器人对接,涵盖环境配置、模型选择(如Qwen)、权限设置及调试,助你快速打造私有、安全、高权限的专属AI助理。(239字)
8544 24
OpenClaw(原 Clawdbot)钉钉对接保姆级教程 手把手教你打造自己的 AI 助手
|
22天前
|
人工智能 机器人 Linux
OpenClaw(Clawdbot、Moltbot)汉化版部署教程指南(零门槛)
OpenClaw作为2026年GitHub上增长最快的开源项目之一,一周内Stars从7800飙升至12万+,其核心优势在于打破传统聊天机器人的局限,能真正执行读写文件、运行脚本、浏览器自动化等实操任务。但原版全英文界面对中文用户存在上手门槛,汉化版通过覆盖命令行(CLI)与网页控制台(Dashboard)核心模块,解决了语言障碍,同时保持与官方版本的实时同步,确保新功能最快1小时内可用。本文将详细拆解汉化版OpenClaw的搭建流程,涵盖本地安装、Docker部署、服务器远程访问等场景,同时提供环境适配、问题排查与国内应用集成方案,助力中文用户高效搭建专属AI助手。
5567 12
|
5天前
|
人工智能 JavaScript Linux
别再花钱买云服务器了!OpenClaw 本地部署保姆级教程,10分钟拥有私人AI助理(附阿里云简单部署流程)
2026年,AI私人助理已从“高端配置”变成“日常刚需”,而OpenClaw(原Clawdbot,曾用名Moltbot)作为开源界的“黑马”,凭借自然语言驱动、多技能扩展、零门槛上手的核心优势,成为无数人打造私人AI助理的首选——它无需复杂代码基础,无需高价云服务器,只要你有一台普通电脑(Windows、Mac、Linux均可),跟着步骤操作,10分钟就能完成本地部署,同时也支持阿里云简单部署,兼顾“零成本本地使用”与“云端稳定托管”双重需求,彻底打破“AI助理必花钱”的误区。
1261 5
|
8天前
|
人工智能 JavaScript API
Windows系统OpenClaw保姆级部署指南:本地+云端双方案,零技术基础也能玩转AI助手
在AI办公自动化全面普及的2026年,OpenClaw(原Clawdbot、Moltbot)凭借“自然语言指令操控、多任务自动化执行、多工具无缝集成”的核心优势,成为个人与轻量办公群体打造专属AI助手的首选。它不仅能通过聊天互动响应需求,更具备“动手”和“跑腿”的硬核能力——“手”可读写本地文件、执行代码、操控命令行,“脚”能联网搜索、访问网页并分析内容,“大脑”则可灵活接入Qwen、OpenAI等云端API,或利用本地GPU运行模型,真正实现“聊天框里办大事”。
1191 7