next up previous contents
Next: 開機自動掛載 Up: 邏輯捲軸管理員 Previous: 邏輯捲軸管理   Contents

管理原已存在的 VG

  1. 新增 PV partition
    [root@kvm8 ~]# fdisk -uc /dev/vda
    Command (m for help): p
    
    Disk /dev/vda: 1717 MB, 1717987328 bytes
    16 heads, 63 sectors/track, 3328 cylinders, total 3355444 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0005f7da
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048      198655       98304   83  Linux
    /dev/vda2          198656     2656255     1228800   8e  Linux LVM
    /dev/vda3         2656256     2922495      133120   8e  Linux LVM
    
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    e
    Selected partition 4
    First sector (2922496-3355443, default 2922496): 
    Using default value 2922496
    Last sector, +sectors or +size{K,M,G} (2922496-3355443, default 3355443): 
    Using default value 3355443
    
    Command (m for help): p
    
    Disk /dev/vda: 1717 MB, 1717987328 bytes
    16 heads, 63 sectors/track, 3328 cylinders, total 3355444 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0005f7da
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048      198655       98304   83  Linux
    /dev/vda2          198656     2656255     1228800   8e  Linux LVM
    /dev/vda3         2656256     2922495      133120   8e  Linux LVM
    /dev/vda4         2922496     3355443      216474    5  Extended
    
    Command (m for help): n
    First sector (2924544-3355443, default 2924544): 
    Using default value 2924544
    Last sector, +sectors or +size{K,M,G} (2924544-3355443, default 3355443): +20M
    
    Command (m for help): p
    
    Disk /dev/vda: 1717 MB, 1717987328 bytes
    16 heads, 63 sectors/track, 3328 cylinders, total 3355444 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0005f7da
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048      198655       98304   83  Linux
    /dev/vda2          198656     2656255     1228800   8e  Linux LVM
    /dev/vda3         2656256     2922495      133120   8e  Linux LVM
    /dev/vda4         2922496     3355443      216474    5  Extended
    /dev/vda5         2924544     2965503       20480   83  Linux
    
    Command (m for help): t 
    Partition number (1-5): 5
    Hex code (type L to list codes): 8e
    Changed system type of partition 5 to 8e (Linux LVM)
    
    Command (m for help): p
    
    Disk /dev/vda: 1717 MB, 1717987328 bytes
    16 heads, 63 sectors/track, 3328 cylinders, total 3355444 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0005f7da
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048      198655       98304   83  Linux
    /dev/vda2          198656     2656255     1228800   8e  Linux LVM
    /dev/vda3         2656256     2922495      133120   8e  Linux LVM
    /dev/vda4         2922496     3355443      216474    5  Extended
    /dev/vda5         2924544     2965503       20480   8e  Linux LVM
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    
    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table. The new table will be used at
    the next reboot or after you run partprobe(8) or kpartx(8)
    Syncing disks.
    
  2. 重新開機
    [root@kvm8 ~]# reboot
    
  3. 查看 VG vg_kvmusb
    [root@kvm8 ~]# vgdisplay vg_kvmusb
      --- Volume group ---
      VG Name               vg_kvmusb
      System ID             
      Format                lvm2
      Metadata Areas        1
      Metadata Sequence No  5
      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               1.17 GiB
      PE Size               4.00 MiB
      Total PE              299
      Alloc PE / Size       287 / 1.12 GiB
      Free  PE / Size       12 / 48.00 MiB  <= 剩 12 個 PE, 48 MiB
      VG UUID               iqDLSv-BhBM-uxdY-sffi-MEb6-NzaM-IVUKVS
    
  4. 將分割好的 /dev/vda5 產生 pv
    [root@kvm8 ~]# pvcreate /dev/vda5
      Physical volume "/dev/vda5" successfully created
    
  5. 將分割好的 /dev/vda5 併入 VG vg_kvmusb
    [root@kvm8 ~]# vgextend vg_kvmusb /dev/vda5
      Volume group "vg_kvmusb" successfully extended
    
  6. 再觀察 VG vg_kvmusb
    [root@kvm8 ~]# vgdisplay vg_kvmusb
      --- Volume group ---
      VG Name               vg_kvmusb
      System ID             
      Format                lvm2
      Metadata Areas        2
      Metadata Sequence No  6
      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               1.18 GiB
      PE Size               4.00 MiB
      Total PE              303
      Alloc PE / Size       287 / 1.12 GiB
      Free  PE / Size       16 / 64.00 MiB  <= 多出 4 個 PE, 16 MiB
      VG UUID               iqDLSv-BhBM-uxdY-sffi-MEb6-NzaM-IVUKVS
    
  7. 將 /dev/vda5 移出 VG vg_kvmusb
    [root@kvm8 ~]# vgreduce vg_kvmusb /dev/vda5
      Removed "/dev/vda5" from volume group "vg_kvmusb"
    



2015-04-13