Last active
February 25, 2020 15:34
-
-
Save aufi/aa2a50c832537d66ad45c1c133420a99 to your computer and use it in GitHub Desktop.
Boot a VM using libvirt, based on https://www.cyberciti.biz/faq/how-to-install-kvm-on-centos-7-rhel-7-headless-server/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2 | |
37 ls | |
38 cd .. | |
39 cd images/ | |
40 ls | |
41 mkdir packstack | |
42 cd packstack/ | |
43 vi meta-data | |
44 ssh-keygen | |
45 vi user-data | |
46 cp ../../boot/CentOS-7-x86_64-GenericCloud.qcow2 . | |
47 ls | |
48 mc CentOS-7-x86_64-GenericCloud.qcow2 packstack.qcow2 | |
49 mv CentOS-7-x86_64-GenericCloud.qcow2 packstack.qcow2 | |
50 export LIBGUESTFS_BACKEND=direct | |
51 df -h | |
52 qemu-img create -f qcow2 -o preallocation=metadata packstack.image.new 20G | |
53 ls -la | |
54 virt-resize --quiet --expand /dev/sda1 packstack.qcow2 packstack.image.new | |
55 ls .lha | |
56 ls -lha | |
57 mv packstack.image.new packstack.qcow2 | |
58 mkisofs -o packstack-cidata.iso -V cidata -J -r user-data meta-data | |
59 ls -lha | |
60 virsh pool-create-as --name packstack --type dir --target /var/lib/libvirt/images/packstack | |
61 ls | |
62 virt-install --import --name packstack --memory 10000 --vcpus 2 --cpu host --disk packstack.qcow2,format=qcow2,bus=virtio --disk packstack-cidata.iso,device=cdrom --network bridge=virbr0,model=virtio --os-type=linux --os-variant=centos7.0 --graphics spice --noautoconsole | |
63 virsh net-dhcp-leases default | |
64 virsh list | |
65 virsh list --all | |
66 ssh [email protected] | |
67 cat /etc/hosts | |
68 vi /etc/hosts | |
69 ssh packstack | |
70 ssh centos@packstack | |
71 virsh autostart packstack |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
instance-id: packstack | |
local-hostname: packstack |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
# Configure where output will go | |
output: | |
all: ">> /var/log/cloud-init.log" | |
# Install my public ssh key to the first user-defined user configured | |
# in cloud.cfg in the template (which is centos for CentOS cloud images) | |
ssh_authorized_keys: | |
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQDJhnpk0NkmVAoAZfO+FMzIrvsbWtGoIbFTwTWpAEofrIJnUdYFdJW0j+2vZiZmKWBh4QzHDYMtD0UNJ9hcoWCbNNg3hb87cEx2Azpi23XSXOJ9pU5vIh8JMIFCXPA0EW+GiHysCDvczOV8KaCOaPYCdAsruqAfttKkAN+nikoiC4GehzVxhBPapT2iFtqCazEUMGDB6tKbTtj/pkIT8GWtYvoBi2utO78Nv91lUyrZLMhvlAtidydp7bkP9+luxGYIn2640qvOCC5kvop9LvEAp5sfQEaAf9uep/6BI5jMpJClyMj009vwSkx6gLzO02p543ZA8rRc17memJErvdJC21VlDvoisnr/GN/tqrGLrxIN/zgJKcNHBqlw1zRnVZCB7WFxpTwEgtNTSSmjARm919WmClbeACcRQPSGr7RCMZsJc7V8QtkJYjvMzTHg1cEQmlY26XJH3JQR+biJ9fZrW+kjC88PYMjpUm/dB8YJ+KGX5IeKv7tUF0SeB5WWVPGvxOG3CBfH4i1bt3cW9hyeNXZ67+0a7VwDfIPx99mPXgElxVuRj3aq9QVI7hU/HaQB7CKmlcpO/bNmfeg/BC95bnyYbXh7a3pIx0We0oojKId53W0PuWZ6EVzuF3T9SE5AZgO1oFZAkBin2tMRewi6XnZhfEZIWCPp0IcVhdpe3DtDxNAlH5b7iDjXDShFv+JemwYQ7hqFtnPaq2hWqyY6daROWs5bxvvAQhtZqbR0/ikH1PjxvHoe4wUYe2qTUzcU+ZRQO9kduvPwBRqPrwIZvwbvShMJ3EJEYT2NDMnusEyCbY8OLWrcOmJm0wZGgw9dOW02QoGIJUocgU72cZc8jYy3BE0pC6posogI6fuyB8j4sX7hknwJFs2Mxc1T2x157gKuhtR2hbhVQX+g4n/rARSL04OY63GeDZX+flGAzKqxZf7LhGRrwePcST0VOAnNi38iLI+v7hxvI7Lfl+iQYtDqH5cQvE9nNCEKtVgwFz+aidq0aDQQqlMGCDB1kVcd5NGPYrWm0nwTkr36vInqhvZrLwXcpYGWps0QHIY0Vzn7n54TlmGYMFfMSGHPdGqaH9eTbiGVQEXpwzZ/6tuJ1DyaAOMbdUfdBmmWrPTbIH1cOsxMC/Wzv7Qqv2a/pDHWmvKO7asRFlLojU+zPeDoV79No... | |
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAPyLHXhyju8OYfAdqTscxHmwGWbEoOOFggf1OFA4SfSmxjAepavKR61z0hfWXP0j0uuf9SY/tR2eXLHB9/+GrjYkQZLGAjV1lvJPPQnnYvlz4ak5rIynNGPiw45RIDeug51QWkDdJ4j3/TTYR+3H17XaQZjatDKmMo6DmTcs+C6BUh1H8QzkHt2267WEzyXldv8n7tiHnK9GyBBVxKFtwYjZ/D6EDkOoEmGsxvmKNnGIkF/5RNuhE8g66pTBrX/+AWbrmHBUdVMuMlpDYtVdadV8phOtYeovbZvcHqKxMMic... | |
# set timezone for VM | |
timezone: Europe/Prague | |
# Remove cloud-init | |
runcmd: | |
- systemctl stop network && systemctl start network | |
- yum -y remove cloud-init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment