Difference between revisions of "Expand Disk LXD VM"
Jump to navigation
Jump to search
(Created page with "Existing size is about 10G on Centos host called nas ``` lxc config device set nas root size=100GiB lxc shell nas ``` Add tools and expand (you can use fdisk/parted but this...") |
|||
| Line 17: | Line 17: | ||
lsblk | lsblk | ||
df -h | df -h | ||
| + | ``` | ||
| + | |||
| + | |||
| + | # Ubuntu | ||
| + | |||
| + | Ubuntu Script example (replace overide with set for existing) | ||
| + | ``` | ||
| + | set -e | ||
| + | |||
| + | readonly VM="myhost" | ||
| + | readonly CPU="8" | ||
| + | readonly MEM="4GB" | ||
| + | readonly DSK="60GB" | ||
| + | |||
| + | lxc init images:ubuntu/focal ${VM} -p default -p vm --vm | ||
| + | lxc config set ${VM} limits.cpu ${CPU} | ||
| + | lxc config set ${VM} limits.memory ${MEM} | ||
| + | lxc config device override ${VM} root size=${DISK} | ||
| + | lxc start ${VM} | ||
| + | |||
| + | sleep 10 # `lxc start` needs a `--wait`. | ||
| + | |||
| + | lxc exec ${VM} -- apt update | ||
| + | lxc exec ${VM} -- apt install cloud-initramfs-growroot -y | ||
| + | lxc exec ${VM} -- growpart /dev/sda 2 | ||
| + | lxc exec ${VM} -- resize2fs /dev/sda2 | ||
``` | ``` | ||
Revision as of 01:29, 16 May 2021
Existing size is about 10G on Centos host called nas
lxc config device set nas root size=100GiB lxc shell nas
Add tools and expand (you can use fdisk/parted but this is easer)
lsblk df -h yum install e2fsprogs cloud-utils-growpart gdisk growpart /dev/sda 2 resize2fs /dev/sda2 lsblk df -h
Ubuntu
Ubuntu Script example (replace overide with set for existing)
set -e
readonly VM="myhost"
readonly CPU="8"
readonly MEM="4GB"
readonly DSK="60GB"
lxc init images:ubuntu/focal ${VM} -p default -p vm --vm
lxc config set ${VM} limits.cpu ${CPU}
lxc config set ${VM} limits.memory ${MEM}
lxc config device override ${VM} root size=${DISK}
lxc start ${VM}
sleep 10 # `lxc start` needs a `--wait`.
lxc exec ${VM} -- apt update
lxc exec ${VM} -- apt install cloud-initramfs-growroot -y
lxc exec ${VM} -- growpart /dev/sda 2
lxc exec ${VM} -- resize2fs /dev/sda2