ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

KVM虚拟机磁盘扩容

2021-10-14 19:34:22  阅读:208  来源: 互联网

标签:blocks kubernetes 207 虚拟机 KVM bytes 10G home 磁盘


创建磁盘

dd if=/dev/zero of=kubernetes-207_home_10G.img bs=1 count=1 seek=10G;

磁盘分区

[root@host-machine file]# fdisk kubernetes-207_home_10G.img

#创建一个新的分区
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

#第一扇区从xxx开始
First sector (2048-20971519, default 2048):
Using default value 2048

#最后扇区到xxx结束
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519):
Using default value 20971519
Partition 1 of type Linux and of size 10 GiB is set

#打印
Command (m for help): p

Disk kubernetes-207_home_10G.img: 10.7 GB, 10737418240 bytes, 20971520 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: 0x2b72a5ce

                      Device Boot      Start         End      Blocks   Id  System
kubernetes-207_home_10G.img1            2048    20971519    10484736   83  Linux

Command (m for help): w
The partition table has been altered!

Syncing disks.

磁盘格式化

[root@host-machine file]# mkfs.ext4 kubernetes-207_home_10G.img
mke2fs 1.42.9 (28-Dec-2013)
kubernetes-207_home_10G.img is not a block special device.
Proceed anyway? (y,n) y
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2151677952
80 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

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

磁盘挂载

virsh edit kubernetes-207
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/kubernetes-207_home_10G.img'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </disk>
#编辑是删除address行,此行是自动生成的,如果不删除,会报错。
mount /dev/vda /tmp/home/

标签:blocks,kubernetes,207,虚拟机,KVM,bytes,10G,home,磁盘
来源: https://www.cnblogs.com/FongZhang/p/15408113.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有