next up previous contents
Next: sulogin 解決 Up: 邏輯卷冊變更 Previous: PV resize   Contents

刪除 vda5 vda6

  1. 查詢 /dev/vda5 是正在使用的 swap。
    [root@kvm7 ~]# swapon -s
    Filename		Type		Size	Used	Priority
    /dev/dm-1						partition	126972	0	-1
    /dev/vda5						partition	20476	0	-2
    
  2. 關閉 swap /dev/vda5。
    [root@kvm7 ~]# swapoff /dev/vda5
    [root@kvm7 ~]# swapon -s
    Filename		Type		Size	Used	Priority
    /dev/dm-1						partition	126972	0	-1
    
  3. 卸載 LV /dev/vg_mntx/pub,其掛載目錄為 /mnt/pub。
    [root@kvm7 ~]# umount /mnt/pub/
    
  4. 刪除 VG vg_mntx,會詢問是否也刪除其中的 LV pub,回答 y。
    [root@kvm7 ~]# vgremove vg_mntx 
    Do you really want to remove volume group "vg_mntx" containing 1 logical volumes? [y/n]: y
    Do you really want to remove active logical volume vg_mntx/pub? [y/n]: y
      Logical volume "pub" successfully removed
      Volume group "vg_mntx" successfully removed
    
  5. 刪除 PV /dev/vda6。
    [root@kvm7 ~]# pvremove /dev/vda6
      Labels on physical volume "/dev/vda6" successfully wiped.
    
  6. fdisk 刪除 vda5 及 vda6,重新產生 vda5 及 vda6,此例中新建的 vda5 大小為 80M。
    [root@kvm7 ~]# fdisk /dev/vda 
    Welcome to fdisk (util-linux 2.23.2).
    
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    
    Command (m for help): p
    
    Disk /dev/vda: 4294 MB, 4294967296 bytes, 8388608 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 label type: dos
    Disk identifier: 0x0009165e
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048      411647      204800   83  Linux
    /dev/vda2          411648     7579647     3584000   8e  Linux LVM
    /dev/vda3         7579648     7845887      133120   8e  Linux LVM
    /dev/vda4         7845888     8388607      271360    5  Extended
    /dev/vda5         7847936     7888895       20480   82  Linux swap / Solaris
    /dev/vda6         7890944     8388607      248832   8e  Linux LVM
    
    Command (m for help): d
    Partition number (1-6, default 6): 
    Partition 6 is deleted
    
    Command (m for help): d
    Partition number (1-5, default 5): 
    Partition 5 is deleted
    
    Command (m for help): p
    
    Disk /dev/vda: 4294 MB, 4294967296 bytes, 8388608 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 label type: dos
    Disk identifier: 0x0009165e
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048      411647      204800   83  Linux
    /dev/vda2          411648     7579647     3584000   8e  Linux LVM
    /dev/vda3         7579648     7845887      133120   8e  Linux LVM
    /dev/vda4         7845888     8388607      271360    5  Extended
    
    Command (m for help): n
    All primary partitions are in use
    Adding logical partition 5
    First sector (7847936-8388607, default 7847936): 
    Using default value 7847936
    Last sector, +sectors or +size{K,M,G} (7847936-8388607, default 8388607): +80M
    Partition 5 of type Linux and of size 80 MiB is set
    
    Command (m for help): t
    Partition number (1-5, default 5): 
    Hex code (type L to list all codes): 82
    Changed type of partition 'Linux' to 'Linux swap / Solaris'
    
    Command (m for help): n
    All primary partitions are in use
    Adding logical partition 6
    First sector (8013824-8388607, default 8013824): 
    Using default value 8013824
    Last sector, +sectors or +size{K,M,G} (8013824-8388607, default 8388607): 
    Using default value 8388607
    Partition 6 of type Linux and of size 183 MiB is set
    
    Command (m for help): t
    Partition number (1-6, default 6): 8e
    Partition number (1-6, default 6): 
    Hex code (type L to list all codes): 8e
    Changed type of partition 'Linux' to 'Linux LVM'
    
    Command (m for help): p
    
    Disk /dev/vda: 4294 MB, 4294967296 bytes, 8388608 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 label type: dos
    Disk identifier: 0x0009165e
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048      411647      204800   83  Linux
    /dev/vda2          411648     7579647     3584000   8e  Linux LVM
    /dev/vda3         7579648     7845887      133120   8e  Linux LVM
    /dev/vda4         7845888     8388607      271360    5  Extended
    /dev/vda5         7847936     8011775       81920   82  Linux swap / Solaris
    /dev/vda6         8013824     8388607      187392   8e  Linux LVM
    
    Command (m for help): w
    


De-Yu Wang 2018-11-30