VMware CentOS LVM磁盤擴容


一. 在虛擬機上增加磁盤空間

如下圖。



增加完后會有提示 “磁盤已成功擴展。您必須從客戶機操作系統內部對磁盤重新進行分區和擴展文件系統。是繼續完成以下步驟才算成功。

二、調整虛擬機磁盤LVM

 

1.查看現有的硬盤分區(現在空間沒有變大)


# df -h

2.對新增的硬盤空間做新增分區(硬盤數沒有增加,增加的是空間)

# fdisk  /dev/sda

照着紅色部分輸入,按回車。

The number of cylinders for this disk isset to 7832.

There is nothing wrong with that, but thisis larger than 1024,

and could in certain setups cause problemswith:

1) software that runs at boot time (e.g.,old versions of LILO)

2) booting and partitioning software fromother OSs

   (e.g., DOS FDISK, OS/2 FDISK)

 

Command (m for help): n 說明:新增分區

Command action

   e   extended

   p   primarypartition (1-4)

p

Partition number (1-4): 3 說明:新增分區號(1,2默認已經用了)

First cylinder (2611-7832, default 2611): 默認回車(最小)

Using default value 2611

Last cylinder or +size or +sizeM or +sizeK(2611-7832, default 7832):默認回車(最大)

Using default value 7832

 

Command (m for help): t 說明:修改分區類型

Partition number (1-4): 說明:修改分區類型對應的分區號

Hex code (type L to list codes): 8e 說明:8e是lvm磁盤類型

Changed system type of partition 3 to 8e(Linux LVM)

 

Command (m for help): p 說明:打印分區表

 

Disk /dev/sda: 64.4 GB, 64424509440 bytes

255 heads, 63 sectors/track, 7832 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

 

   Device Boot      Start        End      Blocks  Id  System

/dev/sda1   *           1         13      104391  83  Linux

/dev/sda2              14       2610    20860402+ 8e  Linux LVM

/dev/sda3            2611       7832    41945715  8e  Linux LVM

 

Command (m for help): w 說明:保存退出

The partition table has been altered!

 

3.重啟系統

# reboot

4.查看硬盤情況(核對剛才所做的分區操作是否保存成功)

# fdisk -l

5.查看當前分區的類型

# df -T /dev/sda1 說明:查看當前的主分區類型

 6.創建文件系統在新的磁盤上

# mkfs.ext4 /dev/sda3 說明:ext4為你查看到的文件系統類型(ext2、ext3、ext4等)

 7.創建PV(pv組成vg,vg組成lv)

# pvcreate /dev/sda3

 

查看pv狀態

# pvdisplay

查看vg狀態

# vgdisplay

8.剛創建的PV加入相應的VG

# vgextend vg_centos /dev/sda3 說明 vg_centos是我的服務器vg名稱,請通過查看vg狀態得到名稱VG name


9.查看LV狀態,把VG加入到LV

# lvdisplay

10.

# lvextend -l +2559 /dev/VolGroup00/LogVol00 

說明:2559為上面pvdisplay查看到的free的PE數量

如果剛才看到是0,要用命令pvdisplay再看一下

11.用 resize2fs 調整文件系統大小

# resize2fs/dev/mapper/VolGroup00-LogVol00

 


 



版權聲明:本文為博主原創文章,未經博主允許不得轉載。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM