2021年12月10日 星期五

how to resize an existing vdi disk in vbox + resize an Ubuntu 18.04/20.04 LVM disk

step 1..to resize vdi of VBox ,please refer to :

https://www.howtogeek.com/124622/how-to-enlarge-a-virtual-machines-disk-in-virtualbox-or-vmware/

 File > Virtual Media Manager in the main VirtualBox window

step2 .extend to 100 free space.

ref:
https://kb.vander.host/operating-systems/how-to-resize-an-ubuntu-18-04-lvm-disk/

用sudo -i  (root身份去執行)

其中,

-------------------------------------

user@server:~# parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) resizepart
Partition number? 3
End? [26.8GB]?   <--這地方要自己輸入,不能只按enter,
因為parted 是不知道你有多少空間可以用 
(在上一個指令「fdisk -l」裡「Disk /dev/sda: 30.25 GiB」就是我們可用(用步驟1改的vdi大小)的大小,
所以請在此填入32.25G)
(parted) quit
Information: You may need to update /etc/fstab.
----------------------------------------------
接著用
 pvresize /dev/sda3
上述才會生效
又,我是直接用「lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv」
確定它出現以下訊息
------------------------------------------
 Size of logical volume ubuntu-vg/ubuntu-lv changed from <9.00 GiB (2303 extents) to 29.24 GiB (7486 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
---------------------------------------------
才是正確地完成了lvextend指令,
當然別忘了之後的「resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv」指令,再用df -h 確定LVM有擴充
才是真的功德圓滿了
以上,加油了!!

------------------------------------

沒有留言:

張貼留言