2018/12/19
增大 Ubuntu 18.04 上 root lvm volume
昨天剛灌的機器今天磁碟就滿了, 怎麼可能?
一看, 原來當初給主磁碟 20G 空間 Ubuntu 18.04 只先配置 LV 4G 的空間, 難怪空間爆炸了
所以其實 PV 上空間還是夠的, 這時候就是把 LV 重新設定大小就好了
如果是用 lvextend 則會報錯:
```bash
$ sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
/etc/lvm/archive/.lvm_template_2310_1202205345: write error failed: No space left on device
```
正確步驟:
```bash
# 1. 用 lvresize
$ sudo lvresize -A n -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 4.00 GiB (1024 extents) to <19.00 GiB (4863 extents)
WARNING: This metadata update is NOT backed up.
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
# 2. resize ext4
$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 3
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 4979712 (4k) blocks long.
# 3. df 看一下
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv 19540624 4050844 14634724 22% /
```
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言