溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Xen虛擬機怎樣擴展磁盤

發(fā)布時間:2022-01-14 16:23:27 來源:億速云 閱讀:129 作者:柒染 欄目:云計算

這篇文章給大家介紹Xen虛擬機怎樣擴展磁盤,內(nèi)容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。

擴展之前磁盤空間大小

[root@localhost ~]# df -THP
Filesystem                   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

創(chuàng)建磁盤不用關(guān)閉虛擬機有點生猛

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

查看

[root@localhost ~]# df -TH
Filesystem           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 -l

Disk /dev/xvda: 15.0 GB, 15032390656 bytes  #總大小已經(jīng)變了
255 heads, 63 sectors/track, 1827 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: 0x000398a4

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              64        1306     9972736   8e  Linux LVM

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

擴展

fdisk  /dev/xvda 分區(qū)分成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_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 3284992 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 3284992 blocks long.

[root@localhost ~]# df -TH
Filesystem           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

關(guān)于Xen虛擬機怎樣擴展磁盤就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI