新增分割區

  1. 使用 gdisk 分割硬碟 /dev/vda。
    [root@kvm10 ~]# gdisk /dev/vda
    GPT fdisk (gdisk) version 1.0.7
    
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present
    
    Found valid GPT with protective MBR; using GPT.
    
    Command (? for help):
    
  2. 命令 p:列出分割表,目前有三個分割區。
    Command (? for help): p
    Disk /dev/vda: 12582912 sectors, 6.0 GiB
    Sector size (logical/physical): 512/512 bytes
    Disk identifier (GUID): 85954A41-1113-4533-A9A4-FFEB73552195
    Partition table holds up to 128 entries
    Main partition table begins at sector 2 and ends at sector 33
    First usable sector is 34, last usable sector is 12582878
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 2340797 sectors (1.1 GiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1            2048            4095   1024.0 KiB  EF02
       2            4096         1028095   500.0 MiB   8300
       3         1028096        10244095   4.4 GiB     8E00
    
  3. 命令 n: 新增分割區,如果沒有要再新增其他分割區,可以直接將硬碟剩餘空間「全部」分割為 LVM 的分割區,分割區的 type 輸入 8e00 (Linux LVM) ,不知道 type 可輸入 L 查詢,其餘分割編號,分割起迄位置都按「Enter」接受系統建議值。
    Command (? for help): n
    Partition number (4-128, default 4):
    First sector (34-12582878, default = 10244096) or {+-}size{KMGTP}:
    Last sector (10244096-12582878, default = 12582878) or {+-}size{KMGTP}:
    Current type is 8300 (Linux filesystem)
    Hex code or GUID (L to show codes, Enter = 8300): 8e00
    Changed type of partition to 'Linux LVM'
    
  4. 命令 p:再次列出分割表,新增的第4個分割區1.1 GiB,type 是 Linux LVM。
    Command (? for help): p
    Disk /dev/vda: 12582912 sectors, 6.0 GiB
    Sector size (logical/physical): 512/512 bytes
    Disk identifier (GUID): 85954A41-1113-4533-A9A4-FFEB73552195
    Partition table holds up to 128 entries
    Main partition table begins at sector 2 and ends at sector 33
    First usable sector is 34, last usable sector is 12582878
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 2014 sectors (1007.0 KiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1            2048            4095   1024.0 KiB  EF02
       2            4096         1028095   500.0 MiB   8300
       3         1028096        10244095   4.4 GiB     8E00
       4        10244096        12582878   1.1 GiB     8E00  Linux LVM
    
  5. 命令 w:寫入 GTP 分割表,回答 y 寫入並退出。
    Command (? for help): w
    
    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
    PARTITIONS!!
    
    Do you want to proceed? (Y/N): y
    OK; writing new GUID partition table (GPT) to /dev/vda.
    Warning: The kernel is still using the old partition table.
    The new table will be used at the next reboot or after you
    run partprobe(8) or kpartx(8)
    The operation has completed successfully.
    
  6. partprobe 更新 /dev/vda 的分割表訊息。
    [root@kvm10 ~]# partprobe /dev/vda
    
  7. lsblk 查詢 /dev/vda,已出現 vda4。
    [root@kvm10 ~]# lsblk /dev/vda
    NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
    vda               252:0    0    6G  0 disk
    ├─vda1            252:1    0    1M  0 part
    ├─vda2            252:2    0  500M  0 part /boot
    ├─vda3            252:3    0  4.4G  0 part
    │ ├─vg_kvm10-root 253:0    0  4.3G  0 lvm  /
    │ └─vg_kvm10-swap 253:1    0  124M  0 lvm  [SWAP]
    └─vda4            252:4    0  1.1G  0 part