Skip to content

Instantly share code, notes, and snippets.

@goofrider
Last active May 17, 2023 04:52
Show Gist options
  • Save goofrider/37c75bf4a39c9f41c7f543bafae4f967 to your computer and use it in GitHub Desktop.
Save goofrider/37c75bf4a39c9f41c7f543bafae4f967 to your computer and use it in GitHub Desktop.
Changing CPU/hard disk/RAM size of a multipass instance

How to resize hard disk of a multipasss instance on osx

(see canonical/multipass#62)

    # if you have Docker Desktop installed
    
    sudo /Applications/Docker.app/Contents/MacOS/qcow-tool resize --size=$(( 15 * 1024**3 )) /var/root/Library/Application\ Support/multipassd/vault/instances/ubuntu20/ubuntu-20.04-server-cloudimg-amd64.img 

or

    # using multipass built-in qemu-img tool
    # with human-readable size params
    
    # Hyperkit driver
    sudo /Library/Application\ Support/com.canonical.multipass/bin/qemu-img-hyperkit resize /var/root/Library/Application\ Support/multipassd/vault/instances/ubuntu20/ubuntu-20.04-server-cloudimg-amd64.img 15G
    
    # qmeu driver
    sudo /Library/Application\ Support/com.canonical.multipass/bin/qemu-img resize /var/root/Library/Application\ Support/multipassd/vault/instances/ubuntu20/ubuntu-20.04-server-cloudimg-amd64.img 15G

How to change RAM/number of cores of a multipasss instance on osx

(see canonical/multipass#1158 (comment))

# stop multipassd
sudo launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist

# sudo nano /var/root/Library/Application\ Support/multipassd/multipassd-vm-instances.json
# you'll need sudo for that

# start multipassd again
sudo launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist

The format should be quite easy to grok:

{
    "primary": {
        "deleted": false,
        "disk_space": "5368709120",
        "mac_addr": "52:54:00:5c:f4:14",
        "mem_size": "1073741824",
        "metadata": {
        },
        "mounts": [
        ],
        "num_cores": 1,
        "ssh_username": "ubuntu",
        "state": 0
    }
}

Example mem/disk size

  • 1.0G = 1073741824
  • 1.5G = 1610612736
  • 2.0G = 2147483648
  • 3.0G = 3221225472
  • 4.0G = 4294967296
  • 5.0G = 5368709120
  • 10G = 10737418240
  • 15G = 16106127360
  • 20G = 214748364800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment