新增分割區

  1. fdisk 在硬碟 /dev/vda 分割一塊 LVM 分割區,目前只有兩個分割區。
    [root@kvm10 ~]# fdisk /dev/vda
    
    Welcome to fdisk (util-linux 2.32.1).
    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: 8 GiB, 8589934592 bytes, 16777216 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
    Disklabel type: dos
    Disk identifier: 0x2812136d
    
    Device     Boot  Start      End  Sectors  Size Id Type
    /dev/vda1  *      2048   411647   409600  200M 83 Linux
    /dev/vda2       411648 15771647 15360000  7.3G 8e Linux LVM
    
  2. n 新增分割區:硬碟 MBR 最多只能存 4 個分割區,目前只有兩個分割區,如果沒有要再新增多於兩個分割區,可以直接將硬碟剩餘空間「全部」分割為 LVM 的分割區,全部都按「Enter」接受系統建議值。
    Command (m for help): n
    Partition type
       p   primary (2 primary, 0 extended, 2 free)
       e   extended (container for logical partitions)
    Select (default p): 
    
    Using default response p.
    Partition number (3,4, default 3): 
    First sector (15771648-16777215, default 15771648): 
    Last sector, +sectors or +size{K,M,G,T,P} (15771648-16777215, default 16777215): 
    Created a new partition 3 of type 'Linux' and of size 491 MiB.
    
  3. p 列出目前分割區,新增的 vda3,type 是 Linux。
    Command (m for help): p
    Disk /dev/vda: 8 GiB, 8589934592 bytes, 16777216 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
    Disklabel type: dos
    Disk identifier: 0x2812136d
    
    Device     Boot    Start      End  Sectors  Size Id Type
    /dev/vda1  *        2048   411647   409600  200M 83 Linux
    /dev/vda2         411648 15771647 15360000  7.3G 8e Linux LVM
    /dev/vda3       15771648 16777215  1005568  491M 83 Linux
    
  4. t 修改新增的 vda3,type 為 Linux LVM (8e)。
    Command (m for help): t
    Partition number (1-3, default 3): 
    Hex code (type L to list all codes): 8e
    
    Changed type of partition 'Linux' to 'Linux LVM'.
    
  5. p 再列出目前分割區,vda3 type 為 Linux LVM (8e)。
    Command (m for help): p
    Disk /dev/vda: 8 GiB, 8589934592 bytes, 16777216 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
    Disklabel type: dos
    Disk identifier: 0x2812136d
    
    Device     Boot    Start      End  Sectors  Size Id Type
    /dev/vda1  *        2048   411647   409600  200M 83 Linux
    /dev/vda2         411648 15771647 15360000  7.3G 8e Linux LVM
    /dev/vda3       15771648 16777215  1005568  491M 8e Linux LVM
    
  6. w 儲存並退出,RHEL/CentOS 8 自動重新偵測並載入分割表,不用再執行 partprobe 或 kpart,就可以直接使用新的分割區。
    Command (m for help): w
    The partition table has been altered.
    Syncing disks.