[Openstack] Create virtual machine in console

Open environment variable script

source your_admin-openrc

Create image from file

openstack image create --disk-format qcow2 --public --file ubuntu1604-image.qcow2 ubuntu1604

Create volume for virtual machine from image

openstack volume create --size 11 --image ubuntu1604 ubuntu1604-volume

If flavor not exist, crate one.

openstack flavor create --ram 8096 --vcpus 4 --public --disk 15 m1.large

Create simple network

openstack network create local
openstack subnet create local_subnet --network local --subnet-range --allocation-pool start=,end= --dns-nameserver

Create vm

Unfortunately when createin vm you have to use network id, not network name

$ openstack network list
| ID | Name | Subnets |
| e5d6ba6a-9866-4089-8125-2d2d90d1e890 | local | ae9e3f32-8e8c-483d-a957-50a0551a7fab |
openstack server create --volume ubuntu1604-volume --flavor m1.large  --nic net-id=network_uuid ubuntu1604-vm

How to edit system images (e.g. Rasbian, Openstack)

We can use guestfish a simple tool to edit images file

Open file with command

guestfish -a OrangePi_2G-IOT_Ubuntu1604_Server_GSMPPP_V1_0.img
Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.
Type: 'help' for help on commands
 'man' to read the manual
 'quit' to quit the shell

><fs> run
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ --:--
><fs> list-filesystems 
/dev/sda1: ext2
/dev/sda2: ext4
><fs> mount /dev/sda2 /
><fs> edit /etc/network