格式化分割區

  1. 分割規劃如下:
    [root@dyw1 ~]# gdisk -l /dev/sdb
    GPT fdisk (gdisk) version 1.0.3
    
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present
    
    Found valid GPT with protective MBR; using GPT.
    Disk /dev/sdb: 61767680 sectors, 29.5 GiB
    Model: USB Flash Drive
    Sector size (logical/physical): 512/512 bytes
    Disk identifier (GUID): B9DE9231-21B1-42DB-BB35-CD774FD870E1
    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 61767646
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 6012861 sectors (2.9 GiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1            2048          206847   100.0 MiB   EF00  EFI System
       2          206848         1230847   500.0 MiB   EF02  BIOS boot partition
       3         1230848        55756799   26.0 GiB    8E00  Linux LVM
    
  2. 以 vfat 格式化分割區 /dev/sdb1。
    [root@dyw1 ~]# mkfs.vfat /dev/sdb1
    mkfs.fat 4.1 (2017-01-24)
    
  3. 以 ext4 格式化分割區 /dev/sdb2。
    [root@dyw1 ~]# mkfs.ext4 /dev/sdb2
    mke2fs 1.45.6 (20-Mar-2020)
    Creating filesystem with 512000 1k blocks and 128016 inodes
    Filesystem UUID: 6a58db34-95e8-4c84-aea1-8ee1d6c3d060
    Superblock backups stored on blocks:
    	8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
    
    Allocating group tables: done
    Writing inode tables: done
    Creating journal (8192 blocks): done
    Writing superblocks and filesystem accounting information: done
    
  4. LVM 管理 /dev/sdb3,建立 VG vg_crt,兩個 LV root, swap 。
    [root@dyw1 ~]# pvcreate /dev/sdb3
      Physical volume "/dev/sdb3" successfully created.
    [root@dyw1 ~]# vgcreate vg_crt /dev/sdb3
      Volume group "vg_crt" successfully created
    [root@dyw1 ~]# lvcreate -L 20G -n root vg_crt
      Logical volume "root" created.
    [root@dyw1 ~]# lvcreate -L 2G -n swap vg_crt
      Logical volume "swap" created.
    [root@dyw1 ~]# lvs vg_crt
      LV   VG     Attr       LSize  Pool Origin Data.....
      root vg_crt -wi-a----- 20.00g                                     
      swap vg_crt -wi-a-----  2.00g
    
  5. 以 xfs 格式化 LV /dev/vg_crt/root,。
    [root@dyw1 ~]# mkfs.xfs /dev/vg_crt/root
    meta-data=/dev/vg_crt/root       isize=512    agcount=4, agsize=1310720 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=1        finobt=1, sparse=1, rmapbt=0
             =                       reflink=1
    data     =                       bsize=4096   blocks=5242880, imaxpct=25
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
    log      =internal log           bsize=4096   blocks=2560, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    
  6. 格式化 LV /dev/vg_crt/swap 為 swap。
    [root@dyw1 ~]# mkswap /dev/vg_crt/swap
    Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
    no label, UUID=7eeec893-bd1c-4ae0-b438-424ceb71a054