kvm扩容home目录
KVM虚拟磁盘扩容
1、磁盘扩容分为raw和qcow2两种扩容方式,命令相同,区别是后缀名
[root@daixuan ~]# qemu-img info /data/daixuan1.qcow2 //本身只有9G
p_w_picpath: /data/daixuan1.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 10G
cluster_size: 65536
[root@daixuan ~]# qemu-img resize /data/daixuan1.qcow2 +5G //加5G
Image resized.
[root@daixuan ~]# qemu-img info /data/daixuan1.qcow2 //查看已经+5G,登录后fdisk -l还是10G
p_w_picpath: /data/daixuan1.qcow2
file format: qcow2
virtual size: 15G (16106127360 bytes)
如果需要真正生效,需要destroy,之后start,把配置重新加载
[root@daixuan ~]# virsh destroy daixuan1
[root@daixuan ~]# virsh start daixuan1
[root@daixuan ~]# virsh console daixuan1
fdisk -l 列出系统中所有的磁盘设备和分区表,这里磁盘设备容量已经增加5G
[root@localhost ~]# fdisk -l
Disk /dev/vda: 16.1 GB, 16106127360 bytes
2、但是磁盘挂载的空间并没有增加,依然是8.3G
[root@localhost ~]# df -h //查看可用磁盘总容量和使用容量
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 8.3G 685M 7.2G 9% /
tmpfs 246M 0 246M 0% /dev/shm
/dev/vda1 477M 33M 419M 8% /boot
(1)因为新增加的空间还没有划分使用,所以要继续分区:
[root@localhost ~]# fdisk /dev/vda
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: 16.1 GB, 16106127360 bytes
16 heads, 63 sectors/track, 31207 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: 0x000dca27
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-31207, default 1): 20807
Last cylinder, +cylinders or +size{K,M,G} (20807-31207, default 31207): 31207
Command (m for help): p
Disk /dev/vda: 16.1 GB, 16106127360 bytes
16 heads, 63 sectors/track, 31207 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: 0x000dca27
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 31207 5242104 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.
(2)然后再把这个/dev/vda3 加入到lvm里面去:
[root@localhost ~]# ls /dev/vda3 //如果没有这个分区,需要重启一下
[root@localhost ~]# reboot
[root@localhost ~]# pvcreate /dev/vda3 //创建物理卷
Physical volume "/dev/vda3" successfully created
[root@localhost ~]# pvs //查看卷 把新建的vda加入原有的vg里
PV VG Fmt Attr PSize PFree
/dev/vda2 VolGroup lvm2 a-- 9.51g 0
/dev/vda3 lvm2 --- 5.00g 5.00g
[root@localhost ~]# vgextend VolGroup /dev/vda3 //VolGroup虚拟卷扩展,vda3加入到Vol
Volume group "VolGroup" successfully extended
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 VolGroup lvm2 a-- 9.51g 0
/dev/vda3 VolGroup lvm2 a-- 5.00g 0
[root@localhost ~]# vgs //VFree中5G
VG #PV #LV #SN Attr VSize VFree
VolGroup 2 2 0 wz--n- 14.50g 5.00g
如何把5G加入到lv_root中?
[root@localhost ~]# lvs //查看逻辑卷
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_root VolGroup -wi-ao---- 8.54g
lv_swap VolGroup -wi-ao---- 992.00m
[root@localhost ~]# lvextend -l +100%FREE /dev/VolGroup/lv_root //扩展卷 就是要扩展的全路径
Size of logical volume VolGroup/lv_root changed from 8.54 GiB (2186 extents) to 13.54 GiB (3465 extents).
Logical volume lv_root successfully resized
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 8.3G 685M 7.2G 9% /
tmpfs 246M 0 246M 0% /dev/shm
/dev/vda1 477M 33M 419M 8% /boot
[root@localhost ~]# resize2fs /dev/VolGroup/lv_root (查看文件系统) 如果是xfs_growfs /dev/mapper/rhel-root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/VolGroup/lv_root to 3548160 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 3548160 blocks long.
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 14G 687M 12G 6% /
tmpfs 246M 0 246M 0% /dev/shm
/dev/vda1 477M 33M 419M 8% /boot
如果提示 This p_w_picpath format does not support resize, 检查一下你qemu-img create的时候,是否有加 preallocation=metadata 选项,如果有,就不能resize了。
(3)另外,如果是增加磁盘,思路是
创建磁盘: qemu-img create -f qcow2 /data/daixuan1_2.qcow2 5G
关闭虚拟机: virsh destroy daixuan1
编辑配置文件: virsh edit daixuan1
复制增加如下:注意是vdb,qcow2
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/data/daixuan1_2.qcow2'/>
<target dev='vdb' bus='virtio'/>
</disk>
开启虚拟机:virsh start daixuan1
进入虚拟机:virsh console daixuan1
分区: fdisk /dev/vdb
格式化:mkfs.ext4 /dev/vdb
挂载:vim /etc/fstab,添加一行:/dev/vdb /mnt ext4 defaults 0 0
mount -a 然后mnt就可以使用了
[root@localhost ~]# cd /mnt
[root@localhost mnt]# touch 23.txt
当然也可以按照上面的思路把 /dev/vdb 加入到 lvm里面去,测试成功,这里省略步骤
注: raw格式
步骤基本上和qcow2一样。如果提示 This p_w_picpath format does not support resize, 检查一下你qemu-img create的时候,是否有加 preallocation=metadata 选项,如果有,就不能resize了。
kvm扩容home目录的更多相关文章
- [转载]XStar's Libvirt+KVM部署记录 目录
XStar's Libvirt+KVM部署记录 目录 Create: 2013-12-11 Update: 2014-01-03 准备工作 KVM网站 http://sourceforge.net/p ...
- CentOS-磁盘扩容挂载目录
挂载 查看存储情况 $ df -kh 查看磁盘情况 $ fdisk -l fdisk创建分区(注:可操作存储上限为2TB)$ fdisk /dev/sdb根据提示,依次输入"n", ...
- Linux中/目录扩容
1:原来的系统20G,目前增加到30G,我要把增加的10G扩容到/目录下 2:fdisk /dev/sda (对sda这块磁盘没有被使用的空间进行分区,联想Windows操作系统) 使用L ...
- Centos7 LVM管理的逻辑卷根目录扩容和/var目录扩容
Centos7 LVM管理的逻辑卷根目录扩容 fdisk /dev/sdb #对新加磁盘进行分区操作pvcreate /dev/sdb1 #创建一个物理卷vgs #查看现有的卷组vgextend ce ...
- Linux 分区扩容(根分区扩容,SWAP 分区扩容,挂载新分区为目录)
请访问原文链接:https://sysin.org/blog/linux-partition-expansion/,查看最新版.原创作品,转载请保留出处. 作者:gc(at)sysin.org,主页: ...
- 如何在KVM中管理存储池
来自:http://blog.csdn.net/my2005lb/article/details/8635661 KVM平台以存储池的形式对存储进行统一管理,所谓存储池可以理解为本地目录.通过远端磁盘 ...
- AIX逻辑卷扩容
aix的文件系统扩容是非常灵活的,如果不涉及加硬盘的硬件操作,只要通过aix里面的命令或者smitty菜单就行了,当然做好数据备份在任何情况下都是必要的. 1. 查看个逻辑卷大小 # df -gFil ...
- 云计算大数据:Xen、KVM、VMware、hyper-v等虚拟化技术的比较
1.Xen.KVM.VMware.hyper-v等虚拟化技术的比较,xen和kvm,是开源免费的虚拟化软件. vmware是付费的虚拟化软件. hyper-v比较特别,是微软windows 2008 ...
- 制作kvm镜像、格式转换
2018-12-25 制作kvm镜像(以centos 7 为例) 执行创建虚拟机命令 virt-install --name centos7_kvm --memory --vcpus= --disk ...
随机推荐
- Install.php
<!DOCTYPE html><html lang="en"><head> <meta charset="utf-8" ...
- STS插件创建springboot项目,pom第一行报unkown错误
Description Resource Path Location TypeUnknown pom.xml /amq-provider line 1 ...
- bzoj1706 [usaco2007 Nov]relays 奶牛接力跑 矩阵快速幂
题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=1706 题解 换个方法定义矩阵乘法:先加再取 \(\min\). 对于一个 \(n\times ...
- Windows结束某个端口的进程
1.打开cmd命令窗口,输入命令:netstat -ano | findstr 8080,根据端口号查找对应的PID.结果如下: 发现8080端口被PID(进程号)为2188的进程占用. 2.根据PI ...
- java.lang.unsatisfiedLinkError:找不到指定的程序
然后我检查了一下 明明在啊??? 查看下一个错误提示: 参考:https://bbs.csdn.net/topics/392215961 https://bbs.csdn.net/topics/3 ...
- js不区分大小写匹配并代码高亮,且不改变原来文本大小写格式
//高亮字符串 string: 需要处理的字符串,keyword:键盘输入的内容 function heightLight(string, keyword) { var reg = new RegEx ...
- 冲刺CSP-S集训考试反思+其它乱写(密码私信)
RT.开坑. 10.1 开门黑23333. 放假回来稍困,而且感冒似乎愈加严重,导致我正常考试基本睁不开眼.一个小时勉强把题读懂,神志恍惚如斯. 看T2觉得估计又是各种推柿子堆定理的数学大题,写了个暴 ...
- 相同name,取最小的id的值,mysql根据相同字段 更新其它字段
id name info1 a 1232 a 2353 a 1244 b 125 b 987相同name,取最小的id的值id name info1 a 1232 a 1233 a 1234 b 12 ...
- mysql.connector.errors.ProgrammingError: 1698 (28000): Access denied for user 'root'@'localhost'
排错,首先在sql编辑工具 通过测试连接,查看一下自己的密码是否正确 : 由此可见,是自己的密码错误,输入正确的密码后 在这里把密码修改为正确之后程序运行正常 #初始化数据库连接 engine = c ...
- 从有状态应用(Session)到无状态应用(JWT),以及 SSO 和 OAuth2
不管用哪种方式认证用户,都可能被中间人攻击窃取 SessionID 或 Token,从而发生 CSRF 攻击.解决方式就是全站 HTTPS.现在 Let's Encrypt 已经支持免费的通配符 HT ...