Skip to content

Instantly share code, notes, and snippets.

@joedborg
Last active May 14, 2025 13:29
Show Gist options
  • Save joedborg/2ad747923104273c79dda76fe5063ce2 to your computer and use it in GitHub Desktop.
Save joedborg/2ad747923104273c79dda76fe5063ce2 to your computer and use it in GitHub Desktop.

Revisions

  1. joedborg revised this gist Aug 19, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion launch_vm.sh
    Original file line number Diff line number Diff line change
    @@ -17,5 +17,5 @@ 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} -- growpart /dev/sda 2
    lxc exec ${VM} -- resize2fs /dev/sda2
  2. joedborg revised this gist Aug 19, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions launch_vm.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    #!/bin/env bash

    set -e

    readonly VM="banana"
    readonly CPU="8"
    readonly MEM="8GB"
  3. joedborg revised this gist Aug 19, 2020. 1 changed file with 34 additions and 0 deletions.
    34 changes: 34 additions & 0 deletions vm-lxd-profile.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    config:
    user.user-data: |
    apt_mirror: http://us.archive.ubuntu.com/ubuntu/
    ssh_pwauth: yes
    users:
    - name: ubuntu
    passwd: "\$6\$s.wXDkoGmU5md\$d.vxMQSvtcs1I7wUG4SLgUhmarY7BR.5lusJq1D9U9EnHK2LJx18x90ipsg0g3Jcomfp0EoGAZYfgvT22qGFl/"
    lock_passwd: false
    groups: lxd
    shell: /bin/bash
    sudo: ALL=(ALL) NOPASSWD:ALL
    growpart:
    mode: auto
    devices:
    - '/'
    - '/dev/sda'
    - '/dev/sda2'
    ignore_growroot_disabled: false
    description: VN profile
    devices:
    config:
    source: cloud-init:config
    type: disk
    eth0:
    nictype: bridged
    parent: lxdbr0
    type: nic
    root:
    path: /
    pool: default
    size: 100GB
    type: disk
    name: vm
  4. joedborg created this gist Aug 19, 2020.
    19 changes: 19 additions & 0 deletions launch_vm.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/bin/env bash

    readonly VM="banana"
    readonly CPU="8"
    readonly MEM="8GB"
    readonly DSK="120GB"

    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