create_box_debian
Differences
This shows you the differences between two versions of the page.
| create_box_debian [2025/07/26 17:09] – - Imported by DokuWiki Advanced Plugin wikiadm | create_box_debian [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Criando box Debian - libvirt ====== | ||
| - | ===== Instalando a vm ===== | ||
| - | <file bash> | ||
| - | $ sudo virt-install \ | ||
| - | --name debian11 \ | ||
| - | --description=" | ||
| - | --ram 2048 \ | ||
| - | --vcpus 2 \ | ||
| - | --disk size=32, | ||
| - | --cdrom / | ||
| - | --virt-type kvm \ | ||
| - | --os-type=Linux \ | ||
| - | --os-variant=debian10 \ | ||
| - | --graphics vnc, | ||
| - | --noautoconsole | ||
| - | </ | ||
| - | FIXME foi feito uma instalação mínima do Debian, apenas o pacote do **//SSH//** foi selecionado para instalação. | ||
| - | ===== Configurando a VM ===== | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo virsh domifaddr debian11 | ||
| - | | ||
| - | ------------------------------------------------------------------------------- | ||
| - | | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ ssh vagrant@192.168.122.106 | ||
| - | The authenticity of host ' | ||
| - | ECDSA key fingerprint is SHA256: | ||
| - | ECDSA key fingerprint is MD5: | ||
| - | Are you sure you want to continue connecting (yes/no)? yes | ||
| - | Warning: Permanently added ' | ||
| - | vagrant@192.168.122.106' | ||
| - | Linux debian 5.10.0-17-amd64 #1 SMP Debian 5.10.136-1 (2022-08-13) x86_64 | ||
| - | |||
| - | The programs included with the Debian GNU/Linux system are free software; | ||
| - | the exact distribution terms for each program are described in the | ||
| - | individual files in / | ||
| - | |||
| - | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | ||
| - | permitted by applicable law. | ||
| - | vagrant@debian: | ||
| - | </ | ||
| - | |||
| - | FIXME Usuário e senha **// | ||
| - | |||
| - | <file bash> | ||
| - | vagrant@debian: | ||
| - | Senha: | ||
| - | root@debian: | ||
| - | </ | ||
| - | |||
| - | ==== Configuração do sudo ==== | ||
| - | <file bash> | ||
| - | # apt install sudo | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | # echo ' | ||
| - | # chmod 440 / | ||
| - | </ | ||
| - | |||
| - | ==== Configuração de rede ==== | ||
| - | <file bash> | ||
| - | # sed -i ' | ||
| - | # sed -i ' | ||
| - | # update-grub; | ||
| - | # truncate -s 0 / | ||
| - | </ | ||
| - | |||
| - | ==== Removendo arquivo temporários e logs ==== | ||
| - | <file bash> | ||
| - | # find /var/log -type f -exec truncate --size=0 {} \; | ||
| - | # find /var/cache -type f -exec rm -rf {} \; | ||
| - | # rm -rf /tmp/* /var/tmp/* | ||
| - | # rm -f / | ||
| - | # history -c | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | # exit | ||
| - | sair | ||
| - | vagrant@debian: | ||
| - | sair | ||
| - | Connection to 192.168.122.106 closed. | ||
| - | </ | ||
| - | |||
| - | ==== Configurando as chaves SSH ==== | ||
| - | <file bash> | ||
| - | $ wget https:// | ||
| - | $ wget https:// | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ ssh-copy-id -i vagrant.pub vagrant@192.168.122.106 | ||
| - | / | ||
| - | / | ||
| - | / | ||
| - | vagrant@192.168.122.106' | ||
| - | |||
| - | Number of key(s) added: 1 | ||
| - | |||
| - | Now try logging into the machine, with: " | ||
| - | and check to make sure that only the key(s) you wanted were added. | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ chmod 0600 vagrant | ||
| - | [suporte@mba-vm-03 box]$ ssh -i vagrant vagrant@192.168.122.106 | ||
| - | Linux debian 5.10.0-17-amd64 #1 SMP Debian 5.10.136-1 (2022-08-13) x86_64 | ||
| - | |||
| - | The programs included with the Debian GNU/Linux system are free software; | ||
| - | the exact distribution terms for each program are described in the | ||
| - | individual files in / | ||
| - | |||
| - | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | ||
| - | permitted by applicable law. | ||
| - | vagrant@debian: | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ export HISTSIZE=0 | ||
| - | vagrant@debian: | ||
| - | sair | ||
| - | Connection to 192.168.122.106 closed. | ||
| - | </ | ||
| - | |||
| - | ==== Criando a box ==== | ||
| - | <file bash> | ||
| - | $ sudo virsh shutdown debian11 | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ wget https:// | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo bash create_box.sh / | ||
| - | {32} | ||
| - | ==> Creating box, tarring and gzipping | ||
| - | ./ | ||
| - | ./ | ||
| - | ./box.img | ||
| - | |||
| - | gzip: stdout: No space left on device | ||
| - | ==> debian11.box created | ||
| - | ==> You can now add the box: | ||
| - | ==> | ||
| - | </ | ||
| - | |||
| - | ==== Testando a box local ==== | ||
| - | <file bash> | ||
| - | $ vagrant box add debian11.box --name debian11 | ||
| - | </ | ||
| - | |||
| - | <file ruby Vagrantfile> | ||
| - | # -*- mode: ruby -*- | ||
| - | # vi: set ft=ruby : | ||
| - | |||
| - | ENV[' | ||
| - | |||
| - | Vagrant.configure(" | ||
| - | config.vm.define :debian11 do |debian11| | ||
| - | debian11.vm.box = " | ||
| - | debian11.vm.hostname = " | ||
| - | |||
| - | debian11.vm.provider :libvirt do |lv| | ||
| - | lv.memory = 2048 | ||
| - | lv.cpus = 2 | ||
| - | end | ||
| - | end | ||
| - | config.vm.synced_folder " | ||
| - | end | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ vagrant up | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ vagrant status | ||
| - | Current machine states: | ||
| - | |||
| - | debian11 | ||
| - | |||
| - | The Libvirt domain is running. To stop this machine, you can run | ||
| - | `vagrant halt`. To destroy the machine, you can run `vagrant destroy`. | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ vagrant ssh debian11 | ||
| - | Linux vm-01 5.10.0-17-amd64 #1 SMP Debian 5.10.136-1 (2022-08-13) x86_64 | ||
| - | |||
| - | The programs included with the Debian GNU/Linux system are free software; | ||
| - | the exact distribution terms for each program are described in the | ||
| - | individual files in / | ||
| - | |||
| - | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | ||
| - | permitted by applicable law. | ||
| - | Last login: Fri Sep 2 15:56:29 2022 from 192.168.122.1 | ||
| - | vagrant@vm-01: | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ vagrant halt | ||
| - | ==> debian11: Attempting graceful shutdown of VM... | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ vagrant destroy | ||
| - | debian11: Are you sure you want to destroy the ' | ||
| - | ==> debian11: Removing domain... | ||
| - | ==> debian11: Deleting the machine folder | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ vagrant box remove debian11 | ||
| - | </ | ||
| - | |||
| - | ==== Publicando uma box ==== | ||
| - | <file bash> | ||
| - | $ vagrant cloud publish g3anmart1ns/ | ||
| - | --description " | ||
| - | --version-description " | ||
| - | --release --no-private | ||
| - | </ | ||
| - | |||
| - | ===== Referências ===== | ||
| - | - [[https:// | ||
| - | - [[https:// | ||
| - | - [[https:// | ||
create_box_debian.1753560543.txt.gz · Last modified: by wikiadm
