溫馨提示×

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

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

怎么給VMware虛擬機(jī)中的CentOS分區(qū)擴(kuò)容

發(fā)布時(shí)間:2021-09-15 16:01:34 來源:億速云 閱讀:300 作者:chen 欄目:系統(tǒng)運(yùn)維

這篇文章主要講解了“怎么給VMware虛擬機(jī)中的CentOS分區(qū)擴(kuò)容”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“怎么給VMware虛擬機(jī)中的CentOS分區(qū)擴(kuò)容”吧!

由于開發(fā)測試機(jī)器dev-vhost017根分區(qū)規(guī)劃不足只有10G,需要擴(kuò)容。(基于LVM)

先關(guān)閉dev-vhost017,然后在vSphere Client 將根分區(qū)硬盤10G 調(diào)整到50G
怎么給VMware虛擬機(jī)中的CentOS分區(qū)擴(kuò)容

開啟虛擬機(jī)
原始/ 大小 10G

代碼如下:


[root@dev-vhost017 ~]# df -h


Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
                      8.3G  4.0G  3.9G  51% /
tmpfs                 939M   12K  939M   1% /dev/shm
/dev/sda1             477M   57M  396M  13% /boot

查看磁盤sda已擴(kuò)展到50G

代碼如下:


[root@dev-vhost017 ~]# fdisk /dev/sda


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/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x0007ef5b
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM
 
Disk /dev/mapper/vg_centos6-lv_root: 9135 MB, 9135194112 bytes
255 heads, 63 sectors/track, 1110 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/vg_centos6-lv_swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 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


查看lvm狀態(tài)

代碼如下:


[root@dev-vhost017 ~]# pvs


  PV         VG         Fmt  Attr PSize PFree
  /dev/sda2  vg_centos6 lvm2 a--  9.51g    0

代碼如下:


[root@dev-vhost017 ~]# vgs


  VG         #PV #LV #SN Attr   VSize VFree
  vg_centos6   1   2   0 wz--n- 9.51g    0

代碼如下:


[root@dev-vhost017 ~]# lvs


  LV      VG         Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_root vg_centos6 -wi-ao---- 8.51g                                                  
  lv_swap vg_centos6 -wi-ao---- 1.00g

分區(qū)/dev/sda3

代碼如下:


[root@dev-vhost017 ~]# fdisk /dev/sda


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/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x0007ef5b
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM
/dev/sda3            1306        6527    41942367+  83  Linux

代碼如下:


[root@dev-vhost017 ~]# partprobe


重啟虛擬機(jī) 格式化/dev/sda3

代碼如下:


[root@dev-vhost017 ~]# mkfs.ext4 /dev/sda3


lvm 擴(kuò)容

代碼如下:


[root@dev-vhost017 ~]# pvcreate  /dev/sda3


  Physical volume "/dev/sda3" successfully created
 

代碼如下:


[root@dev-vhost017 ~]# pvs


  PV         VG         Fmt  Attr PSize  PFree
  /dev/sda2  vg_centos6 lvm2 a--   9.51g     0
  /dev/sda3             lvm2 ---  40.00g 40.00g
 

代碼如下:


[root@dev-vhost017 ~]# vgextend /dev/mapper/vg_centos6 /dev/sda3 (注意組名)


  Volume group "vg_centos6" successfully extended
 

代碼如下:


[root@dev-vhost017 ~]# lvextend -L 39.9G /dev/vg_centos6/lv_root /dev/sda3


  Rounding size to boundary between physical extents: 39.90 GiB
  Size of logical volume vg_centos6/lv_root changed from 8.51 GiB (2178 extents) to 39.90 GiB (10215 extents).
  Logical volume lv_root successfully resized
 
 

代碼如下:


[root@dev-vhost017 ~]# resize2fs /dev/vg_centos6/lv_root


resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_centos6/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 3
Performing an on-line resize of /dev/vg_centos6/lv_root to 10460160 (4k) blocks.
The filesystem on /dev/vg_centos6/lv_root is now 10460160 blocks long.
 
 

代碼如下:


[root@dev-vhost017 ~]# pvs


  PV         VG         Fmt  Attr PSize  PFree
  /dev/sda2  vg_centos6 lvm2 a--   9.51g    0
  /dev/sda3  vg_centos6 lvm2 a--  40.00g 8.60g

代碼如下:


[root@dev-vhost017 ~]# vgs


  VG         #PV #LV #SN Attr   VSize  VFree
  vg_centos6   2   2   0 wz--n- 49.50g 8.60g

代碼如下:


[root@dev-vhost017 ~]# lvs


  LV      VG         Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_root vg_centos6 -wi-ao---- 39.90g                                                  
  lv_swap vg_centos6 -wi-ao----  1.00g 
 

代碼如下:


[root@dev-vhost017 ~]# df -h


Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
                       40G  4.0G   34G  11% /
tmpfs                 939M   12K  939M   1% /dev/shm
/dev/sda1             477M   57M  396M  13% /boot

感謝各位的閱讀,以上就是“怎么給VMware虛擬機(jī)中的CentOS分區(qū)擴(kuò)容”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)怎么給VMware虛擬機(jī)中的CentOS分區(qū)擴(kuò)容這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

向AI問一下細(xì)節(jié)

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

AI