日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux为已有磁盘扩容 kvm,KVM虚拟磁盘扩容

發布時間:2025/3/12 linux 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux为已有磁盘扩容 kvm,KVM虚拟磁盘扩容 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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 //查看卷

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

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

開啟虛擬機: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了。

總結

以上是生活随笔為你收集整理的linux为已有磁盘扩容 kvm,KVM虚拟磁盘扩容的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 99久久久无码国产精品不卡 | 日本高清免费aaaaa大片视频 | 亚洲精品在线观看网站 | 日韩精品成人在线观看 | 精品一区二区三区四 | 麻豆理论片 | 亚洲一区二区三区高清在线 | 天天干,天天爽 | 伊人国产在线观看 | 免费成年人视频在线观看 | 国产成人精品亚洲 | 日韩尤物 | 91视频导航| 在线毛片网 | 日韩精品中文字幕在线 | 成人污污www网站免费丝瓜 | 国产jizz18女人高潮 | 国产成人久久 | 国产欧美精品aaaaaa片 | 制服.丝袜.亚洲.中文.综合懂 | 91视频高清| 国产不卡一二三 | 国产女人和拘做受视频免费 | 日本黄色xxxx | 免费精品在线观看 | 日韩黄色一级片 | 黄色大全免费观看 | 中文字幕你懂的 | 99re这里只有精品在线 | 日本少妇做爰全过程毛片 | 欧美老肥熟 | 免费性爱视频 | 亚洲人精品 | 久久视频在线 | 日本一二三区视频在线 | av久色 | 婷婷的五月天 | 亚洲图片偷拍区 | 欧美激情在线看 | 无码精品人妻一区二区三区漫画 | 蜜臀av免费一区二区三区水牛 | 99久久99久久精品免费看蜜桃 | 播播激情网 | 国产美女毛片 | 91中文字幕视频 | 日本一区二区不卡视频 | 欧美黄色a视频 | 在线亚洲不卡 | 亚洲AV无码久久精品国产一区 | 少妇被粗大猛进进出出s小说 | 午夜精品一区 | 99免费在线| 麻豆传媒观看 | 日韩免费成人av | 亚洲一区二区免费在线观看 | 午夜美女福利视频 | 日少妇av | 毛片在哪看 | 国产乱free国语对白 | 亚洲欧洲综合av | 岛国色图 | 久久99精品久久久久久水蜜桃 | 人人草人 | 99免费视频 | 丰满熟妇肥白一区二区在线 | 亚洲一区免费在线观看 | 欧美激情一区二区视频 | 免费在线h | 欧美成人精品一区二区综合免费 | 国产精品久久一 | 欧美色插| 久久久一级黄色片 | 国产亚洲成av人片在线观看桃 | 日韩另类在线 | 国产成人综合网 | 欧美激情一区二区三区免费观看 | 成人夜色 | 亚洲国产精彩视频 | 黄色一级片免费看 | 能看的av网站 | 老汉av在线 | 久久一区视频 | av解说在线| 亚洲三级小说 | 成人春色影视 | www.天天干.com | 久久99久久久久久 | 成人午夜精品一区二区三区 | 好吊视频一区二区三区四区 | 亚洲国产无线乱码在线观看 | 久久精品国产亚洲 | 五月激情六月丁香 | 激烈娇喘叫1v1高h糙汉 | 超碰男人的天堂 | 日韩在线观看中文字幕 | 精品国产aⅴ一区二区三区四川人 | 国产成人小视频在线观看 | 精品久久ai | 久热最新视频 |