千家信息网

Xen虚拟机怎样扩展磁盘

发表于:2025-01-23 作者:千家信息网编辑
千家信息网最后更新 2025年01月23日,这篇文章给大家介绍Xen虚拟机怎样扩展磁盘,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。扩展之前磁盘空间大小[root@localhost ~]# df -THPFilesyst
千家信息网最后更新 2025年01月23日Xen虚拟机怎样扩展磁盘

这篇文章给大家介绍Xen虚拟机怎样扩展磁盘,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

扩展之前磁盘空间大小

[root@localhost ~]# df -THPFilesystem                   Type   Size  Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root ext4   8.9G  642M  7.8G   8% /tmpfs                        tmpfs  257M     0  257M   0% /dev/shm/dev/xvda1                   ext4   500M   27M  448M   6% /boot

创建磁盘不用关闭虚拟机有点生猛

 dd if=/dev/zero bs=1024M count=4 >>/data/centos6.6.img #直接追加到磁盘

查看

[root@localhost ~]# df -THFilesystem           Type   Size  Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root                     ext4   8.9G  642M  7.8G   8% /tmpfs                tmpfs  257M     0  257M   0% /dev/shm/dev/xvda1           ext4   500M   27M  448M   6% /boot上面查看好像没变其实添加到磁盘了没分[root@localhost ~]# fdisk -lDisk /dev/xvda: 15.0 GB, 15032390656 bytes  #总大小已经变了255 heads, 63 sectors/track, 1827 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000398a4    Device Boot      Start         End      Blocks   Id  System/dev/xvda1   *           1          64      512000   83  LinuxPartition 1 does not end on cylinder boundary./dev/xvda2              64        1306     9972736   8e  Linux LVMDisk /dev/mapper/VolGroup-lv_root: 9168 MB, 9168748544 bytes255 heads, 63 sectors/track, 1114 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/VolGroup-lv_swap: 1040 MB, 1040187392 bytes255 heads, 63 sectors/track, 126 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000

扩展

fdisk  /dev/xvda 分区分成lvm 。。省略[root@localhost ~]# partprobe[root@localhost ~]# cat /proc/partitions major minor  #blocks  name 202        0   14680069 xvda 202        1     512000 xvda1 202        2    9972736 xvda2 202        3    4189617 xvda3 253        0    8953856 dm-0 253        1    1015808 dm-1 [root@localhost ~]# pvcreate /dev/xvda3   Physical volume "/dev/xvda3" successfully created[root@localhost ~]# pvs  PV         VG       Fmt  Attr PSize PFree  /dev/xvda2 VolGroup lvm2 a--  9.51g    0   /dev/xvda3          lvm2 ---  4.00g 4.00g    [root@localhost ~]# vgextend VolGroup /dev/xvda3   Volume group "VolGroup" successfully extended    [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 12.53 GiB (3208 extents).  Logical volume lv_root successfully resized    [root@localhost ~]# resize2fs  -P /dev/VolGroup/lv_rootresize2fs 1.41.12 (17-May-2010)Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing requiredold desc_blocks = 1, new_desc_blocks = 1Performing an on-line resize of /dev/VolGroup/lv_root to 3284992 (4k) blocks.The filesystem on /dev/VolGroup/lv_root is now 3284992 blocks long.[root@localhost ~]# df -THFilesystem           Type   Size  Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root                     ext4    14G  722M   12G   6% /tmpfs                tmpfs  257M     0  257M   0% /dev/shm/dev/xvda1           ext4   500M   27M  448M   6% /boot

关于Xen虚拟机怎样扩展磁盘就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

0