新增分割區

  1. fdisk 進行 vdb 分割區管理。
    [root@kvm10 ~]# fdisk /dev/vdb
    
    Welcome to fdisk (util-linux 2.40.2).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    This disk is currently in use - repartitioning is probably a bad idea.
    It's recommended to umount all file systems, and swapoff all swap
    partitions on this disk.
    
  2. 命令 m:可以查看輔助說明
    Command (m for help): m
    
    Help:
    
      GPT
       M   enter protective/hybrid MBR
    
      Generic
       d   delete a partition
       F   list free unpartitioned space
       l   list known partition types
       n   add a new partition
       p   print the partition table
       t   change a partition type
       v   verify the partition table
       i   print information about a partition
       e   resize a partition
    
      Misc
       m   print this menu
       x   extra functionality (experts only)
    
      Script
       I   load disk layout from sfdisk script file
       O   dump disk layout to sfdisk script file
    
      Save & Exit
       w   write table to disk and exit
       q   quit without saving changes
    
      Create a new label
       g   create a new empty GPT partition table
       G   create a new empty SGI (IRIX) partition table
       o   create a new empty MBR (DOS) partition table
       s   create a new empty Sun partition table
    
  3. 命令 p:列出分割表,目前有 vdb1 一個分割區。
    Command (m for help): p
    
    Disk /dev/vdb: 3 GiB, 3221225472 bytes, 6291456 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: gpt
    Disk identifier: 289C3DC7-CC6A-489A-9CB5-552D550FDAD3
    
    Device     Start    End Sectors  Size Type
    /dev/vdb1   2048 821247  819200  400M Linux LVM
    
  4. 命令 n:新增分割區,都直接按 Enter 使用預設建議:新增編號 2 的分割區,分割區起始及結尾 sector 都用建議值,使用 vdb 剩餘所有空間。
    Command (m for help): n
    Partition number (2-128, default 2): 
    First sector (821248-6291422, default 821248): 
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (821248-6291422, default 6289407): 
    
    Created a new partition 2 of type 'Linux filesystem' and of size 2.6 GiB.
    
  5. 命令 p:再列出分割區,出現 vdb2 分割區。
    Command (m for help): p
    Disk /dev/vdb: 3 GiB, 3221225472 bytes, 6291456 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: gpt
    Disk identifier: 289C3DC7-CC6A-489A-9CB5-552D550FDAD3
    
    Device      Start     End Sectors  Size Type
    /dev/vdb1    2048  821247  819200  400M Linux LVM
    /dev/vdb2  821248 6289407 5468160  2.6G Linux filesystem
    
  6. 命令 t:變更 vdb2 分割區的 Type。
    Command (m for help): t
    Partition number (1,2, default 2):
    
  7. 命令 L:查詢 Type 編號。
    Partition type or alias (type L to list all): L
      1 EFI System                     C12A7328-F81F-11D2-BA4B-00A0C93EC93B
      2 MBR partition scheme           024DEE41-33E7-11D3-9D69-0008C781F39F
      3 Intel Fast Flash               D3BFE2DE-3DAF-11DF-BA40-E3A556D89593
      4 BIOS boot                      21686148-6449-6E6F-744E-656564454649
    ..........................................................
     44 Linux LVM                      E6D6D379-F507-44C2-A23C-238F2A3DF928
    ..........................................................
    
  8. 命令 44:使用 Linux LVM Type。
    Partition type or alias (type L to list all): 44
    
    Changed type of partition 'Linux filesystem' to 'Linux LVM'.
    
  9. 命令 p:再列出分割區 vdb2 的 Type 已改成 Linux LVM。
    Command (m for help): p
    Disk /dev/vdb: 3 GiB, 3221225472 bytes, 6291456 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: gpt
    Disk identifier: 289C3DC7-CC6A-489A-9CB5-552D550FDAD3
    
    Device      Start     End Sectors  Size Type
    /dev/vdb1    2048  821247  819200  400M Linux LVM
    /dev/vdb2  821248 6289407 5468160  2.6G Linux LVM
    
  10. 命令 w:寫入分割區表並退出。
    Command (m for help): w
    The partition table has been altered.
    Syncing disks.
    
  11. lsblk 查詢硬碟,已出現 vdb2。
    [root@kvm10 ~]# lsblk 
    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]
    vdb               252:16   0    3G  0 disk 
    ├─vdb1            252:17   0  400M  0 part 
    │ └─myvdb-vo      253:2    0  252M  0 lvm  /reports
    └─vdb2            252:18   0  2.6G  0 part