VmWare擴展硬盤分區


擴展硬盤

 

 

對硬盤進行分區

(1) 查看現有的硬盤分區情況
[mysql@china ~]$ df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/vg_china-lv_root   18G  5.2G   12G  32% /
tmpfs                         931M   72K  931M   1% /dev/shm
/dev/sda1                     485M   39M  421M   9% /boot

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

 sudo    fdisk     /dev/sda

出現如下提示:Command (m for help): 
 n   說明:新增分區
繼續提示:Command action
   e   extended
   p   primary partition (1-4)
p 說明:打印分區表    
3 說明:Partition number (1-4):此時fdisk會讓你選擇主分區的編號,如果已經有了主分區sda1,sda2,那么編號就選3,即要創建的該分區為sda3.
First cylinder (2611-16632, default 2611): 默認回車(最小)
Using default value 2611
Last cylinder or +size or +sizeM or +sizeK (2611-16632, default 16632):默認回車(最大)
Using default value 16632
Command (m for help):   t 說明:修改分區類型
Partition number (1-4):   3 說明:修改分區類型對應的分區號
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 說明:打印分區表

Command (m for help):    w 說明:保存退出
The partition table has been altered!
(3)重新啟動系統
    reboot
(4) 輸入一下命令
     sudo fdisk -l /dev/sda

 (5).執行
    sudo  pvcreate /dev/sda3       為這個新分區創建一個物理卷Volume;
 (6).現在要做的是把物理卷(volume)擴展到新的物理卷上,先執行命令
   sudo vgdisplay          來查看已有的系統Volume Group的情況,輸出如下:
   [root@china ~]# vgdisplay
  --- Volume group ---
  VG Name               vg_china
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               19.51 GiB
  PE Size               4.00 MiB
  Total PE              4994
  Alloc PE / Size       4994 / 19.51 GiB
  Free  PE / Size       0 / 0   
  VG UUID               SCI2oR-nhr6-89fG-AfDW-CzsM-HxqL-QpS3jr
  
(7)執行命令
     vgextend vg_china   /dev/sda3    ,   擴展以后的Volume Group到新的物理磁盤卷Volume上。

(8)下一步是擴展邏輯卷(Logic Volume)到新的卷上,先用命令
     vgdisplay     看看目前已有的邏輯卷(Logic Volume)的情況
    [root@china ~]# vgdisplay
  --- Volume group ---
  VG Name               vg_china
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               99.50 GiB
  PE Size               4.00 MiB
  Total PE              25473
  Alloc PE / Size       4994 / 19.51 GiB
  Free  PE / Size       20479 / 80.00 GiB
  VG UUID               SCI2oR-nhr6-89fG-AfDW-CzsM-HxqL-QpS3jr

 (9)執行命令 擴展邏輯分區
    [root@china ~]# lvextend -L +79.99G /dev/vg_china/lv_root /dev/sda3 
  Rounding size to boundary between physical extents: 79.99 GiB
  Extending logical volume lv_root to 97.50 GiB
  Logical volume lv_root successfully resized

(10)最后將文件系統resize到新的邏輯卷上來,執行命令
[root@china ~]# resize2fs /dev/vg_china/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_china/lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 7
Performing an on-line resize of /dev/vg_china/lv_root to 25559040 (4k) blocks.
The filesystem on /dev/vg_china/lv_root is now 25559040 blocks long.

(11)用命令看到擴展的分區

[root@china ~]# fdisk -l /dev/sda

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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: 0x0007243f

   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        2611    20458496   8e  Linux LVM
/dev/sda3            2611       13054    83884735   8e  Linux LVM

[root@china ~]# df -hl
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/vg_china-lv_root   96G  5.2G   86G   6% /
tmpfs                         931M   72K  931M   1% /dev/shm
/dev/sda1                     485M   39M  421M   9% /boot

 


免責聲明!

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



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