2018/12/17

增大 EBS 磁碟容量後 LVM 要做的事情



前情提要:
1. 磁碟採用 NVME 介面(t3, m5, c5, r5)
2. 原先建置 LVM 時是用整顆磁碟, 所以裝置下只會有 /dev/nvme1n1 不會有 /dev/nvme1n1p1


增大前先看一下 lvm 配置

```sh
$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/nvme1n1
VG Name VG1
PV Size 50.00 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 12799
Free PE 0
Allocated PE 12799

$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/VG1/DATA
LV Name DATA
VG Name VG1
LV Write Access read/write
LV Creation host, time ip-172-31-37-10, 2018-10-08 09:05:34 +0000
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12799
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0

$ sudo vgdisplay
--- Volume group ---
VG Name VG1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 50.00 GiB
PE Size 4.00 MiB
Total PE 12799
Alloc PE / Size 12799 / 50.00 GiB
Free PE / Size 0 / 0
```

在 ebs 頁面把該磁碟加大到100G後 直接跑 resize2fs 發現沒有做用

研究了一下發現需要先做 pvresize,做完後 pv 的確變成 100G 了

```sh
$ sudo pvresize /dev/nvme1n1
Physical volume "/dev/nvme1n1" changed
1 physical volume(s) resized / 0 physical volume(s) not resized

$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/nvme1n1
VG Name VG1
PV Size 100.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 25599
Free PE 12800
Allocated PE 12799
```

看一下 lv,還是 50G 沒變

```sh
$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/VG1/DATA
LV Name DATA
VG Name VG1
LV Write Access read/write
LV Creation host, time ip-172-31-37-10, 2018-10-08 09:05:34 +0000
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12799
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
```

lv 也要 resize一下,這邊把它稱大到所有的可用空間 +100%FREE

```sh
$ sudo lvresize -l +100%FREE /dev/mapper/VG1-DATA
Size of logical volume VG1/DATA changed from 50.00 GiB (12799 extents) to 100.00 GiB (25599 extents).
Logical volume DATA successfully resized.
```

lv resize 完後看一下,恩 變大了

```sh
$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/VG1/DATA
LV Name DATA
VG Name VG1
LV Write Access read/write
LV Creation host, time ip-172-31-37-10, 2018-10-08 09:05:34 +0000
LV Status available
# open 1
LV Size 100.00 GiB
Current LE 25599
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0

$ sudo vgdisplay
--- Volume group ---
VG Name VG1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 100.00 GiB
PE Size 4.00 MiB
Total PE 25599
Alloc PE / Size 25599 / 100.00 GiB
Free PE / Size 0 / 0
```

不過用 df 看 還是沒變大

```sh
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VG1-DATA 51470972 48766280 67076 100% /data
```

跑 resize2fs 後就正常了

```sh
$ sudo resize2fs /dev/mapper/VG1-DATA
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mapper/VG1-DATA is mounted on /data; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 7
The filesystem on /dev/mapper/VG1-DATA is now 26213376 (4k) blocks long.

$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VG1-DATA 103077152 48774260 49568340 50% /data
```

1 則留言:

  1. But like so many reviewers have mentioned, The Playtika folks seem to be getting very grasping with the payouts. Even the "pals in my circle" stopped half in} so I do not get 10 free spins anymore either. What's the explanation...hmmm...you would hope the Playtika people would READ AND HEED these rankings they keep asking us to make. Leveling up takes so friggin long and after they take all your coins it is really unimaginable 빅카지노 to move up. Inspired by diet labels on meals, they displayed metrics similar to volatility and frequency of payouts.

    回覆刪除