Skip to content

Instantly share code, notes, and snippets.

@philipz
Last active June 7, 2022 14:00
Show Gist options
  • Save philipz/3b14938a65770270f4fcc5d8071662cc to your computer and use it in GitHub Desktop.
Save philipz/3b14938a65770270f4fcc5d8071662cc to your computer and use it in GitHub Desktop.
擴充LVM磁碟空間步驟
  1. VM increasing the size of Disk.
  2. sudo fdisk -l 確認是否已經DISK空間是否擴增。
  3. sudo fdisk /dev/sda

[root@localhost ~]# fdisk /dev/sda 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.

命令 (m 以獲得說明):p

Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O 大小 (最小/最佳化):512 位元組 / 512 位元組 Disk label type: dos 磁碟識別碼:0x000c35eb

所用裝置 開機 開始 結束 區塊 識別號 系統 /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM

命令 (m 以獲得說明):n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p 分割區編號 (3,4, default 3): 3 起初 sector (41943040-104857599, 預設 41943040): 使用預設值 41943040 最後 sector, +sectors 或 +大小{K,M,G} (41943040-104857599, 預設 104857599): 使用預設值 104857599 Partition 3 of type Linux and of size 30 GiB is set

命令 (m 以獲得說明):w 分割表已變更!

  1. sudo reboot 重啟
  2. sudo pvcreate /dev/sda3
  3. sudo vgextend centos /dev/sda3 可透過vgdisplay確認vg group name
  4. sudo lvextend -l +100%FREE /dev/mapper/centos-root
  5. sudo xfs_growfs /dev/mapper/centos-root,可透過lvdisplay確認lv狀況
  6. sudo df -lh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment