Hallo zusammen, ich möchte meinen Server mit neuen VMs bestücken. Ich habe folgende Anleitung gefunden, das mittels Skript zu erledigen:
https://www.golem.de/news/virtuelle-maschinen-virtualbox-funktioniert-auch-ohne-grafische-oberflaeche-1603-119609.html Aufgrund dieser Anleitung habe ich drei Skripte erstellt, die auf Debian Jessie laufen: -- schnipp: Skript 1: Install VirtualBox -- ## Add repo # Source: https://www.virtualbox.org/wiki/Linux_Downloads echo "# Virtualbox Repo" >> /etc/apt/sources.list echo "deb http://download.virtualbox.org/virtualbox/debian jessie contrib" >> /etc/apt/sources.list echo " " >> /etc/apt/sources.list ## Install keys wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - ## If signatures are invalid sudo -s -H apt-get clean rm /var/lib/apt/lists/* rm /var/lib/apt/lists/partial/* apt-get clean ## Refresh package list apt-get update ## Install Virtualbox sudo apt-get install virtualbox-5.1 dkms ## Check installation /usr/lib/virtualbox/vboxdrv.sh status # If Linux kernel is updated use # /usr/lib/virtualbox/vboxdrv.sh setup #---------------------------------------------------------- # %TODO%: Install Guest Additions # Source: http://www.virtualbox.org/manual/ch04.html#idp46730491626640 #---------------------------------------------------------- ## Extension pack: Virtualbox Remote Display Protocol # Source: https://forums.virtualbox.org/viewtopic.php?f=7&t=44337 version=$(vboxmanage -v) echo $version var1=$(echo $version | cut -d 'r' -f 1) echo $var1 var2=$(echo $version | cut -d 'r' -f 2) echo $var2 file="Oracle_VM_VirtualBox_Extension_Pack-$var1-$var2.vbox-extpack" echo $file wget http://download.virtualbox.org/virtualbox/$var1/$file -O /tmp/$file #sudo VBoxManage extpack uninstall "Oracle VM VirtualBox Extension Pack" sudo VBoxManage extpack install /tmp/$file --replace #---------------------------------------------------------- # EOF . -- schnipp (Ende Skript 1) -- Dieses Skript tut's (jedenfalls auf meiner Maschine :) ). Das Einrichten der VM mittels Skript sieht so aus: -- schnipp: Skript 2: Setup Virtual Machine -- # %ADAPT% name of virtual machine # Change 'x2017-vbox-srv-ux-1001' to <your-vm-name> # Annotation # VirtualBox creates the VM ALWAYS in $HOME/'VirtualBox VMs'. # There it is switched to this directory for easy use. cd ~/'VirtualBox VMs' ## Create and register new virtual machine vboxmanage createvm --name "x2017-vbox-srv-ux-1001" --register #---------------------------------------------------------- ## Assign RAM and activat ACPI power management vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --memory 1024 --acpi on #---------------------------------------------------------- ## Configure processor usage ### Allow 100 percent processor usage vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --cpuexecutioncap 100 ### Allow hotplug CPU and define maximum for allocated CPUs vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --cpuhotplug on --cpus 2 ### Hint: Use ### vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --plugcpu 1 ### to add and ### vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --unplugcpu 1 ### to remove a CPU. #---------------------------------------------------------- ## Create virtual hard drive ## Configuration: maximum of 25 GB dynamically allocated space ## Rational: 25 GB can be saved as backup on a blu-ray disc vboxmanage createhd --filename 'x2017-vbox-srv-ux-1001/x2017-vbox-srv-ux-1001.vdi' --size 25000 ### If needed the virtual hard drive can be extended. Use ### vboxmanage modifyhd --resize ### and follow these steps ### Source: https://forums.virtualbox.org/viewtopic.php?f=35&t=50661 ## Connect virtual hard drive with virtual box server ### Add SATA controller vboxmanage storagectl "x2017-vbox-srv-ux-1001" --name "SATA Controller" --add sata ### Attach virtual hard drive and use ### 1st controller (= -port 0) ### 1st device (= -device 0) ### The first device at the first controller is important for installation of operating system vboxmanage storageattach "x2017-vbox-srv-ux-1001" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium x2017-vbox-srv-ux-1001/x2017-vbox-srv-ux-1001.vdi ## Attach DVD optical drive vboxmanage storageattach "x2017-vbox-srv-ux-1001" --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium emptydrive #---------------------------------------------------------- ## Install network ## Source: http://www.virtualbox.org/manual/ch06.html ## Source: http://www.virtualbox.org/manual/ch06.html#nichardware ### Prepare the network adapter for installation using ### Trivial File Transfer Protocol (TFTP) over ### Preboot Execution Environment (PXE) ### Use 1st network adaptor (= --nic1) ### Emulate Intel PRO/1000 MT Desktop (= --nictype1 82540EM) vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --nic1 nat --nictype1 82540EM ### Annotation: Network addresses for 1st network adaptor #### Standard IPv4 network address space: 10.0.2.0/24 #### Standard guest IPv4 network address: 10.0.2.15 #### Standard gateway IPv4 network address: 10.0.2.2 #### Standard nameserver IPv4 network address: 10.0.2.3 ### Annotation: Network address of 2nd network adaptor #### 10.0.3.15 # Change internal network address space # vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --natnet1 "192.168/16" #---------------------------------------------------------- ## Configure port forwarding for SSH ### Use port 2222 of host to connect to port 22 on guest. ### Name "guestssh" can be freely chosen. ### Use 1st network adaptor (= -natpf1) vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --natpf1 "guestssh,tcp,,2222,,22" ### To remove port forwarding use ### vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --natpf1 delete "guestssh" #---------------------------------------------------------- ## Set boot options ### Setup PXE support vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --nattftpfile1 /debian.pxe ### Boot network as 1st device vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --boot1 net #---------------------------------------------------------- ## Setup serial port for debugging and to read /var/log/syslog ### Create serial port vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --uart1 0x3F8 4 ### Create pipe file vboxmanage modifyvm "x2017-vbox-srv-ux-1001" --uartmode1 server /tmp/deb_debug # EOF . -- schnipp (Ende Skript 2) -- Auch dieses Skript läuft auf meiner Maschine fehlerfrei. Der letzte Schritt in der Anleitung war etwas kompliziert und m. E. auch nicht so verständlich geschrieben. Mein Skript sieht so aus: -- schnipp: Skript 3: Install Debian Server -- # Annotation # It is assumed that the installation is done on machines running Debian/Ubuntu. ## Setup Debian server using an unattended approach ## Source: https://wiki.debianforum.de/Debian-Installation_%C3%BCber_PXE,_TFTP_und_Preseed ## Configure Virtualbox and Debian installation using preseed files sudo su root cd ~/.config/Virtualbox mkdir TFTP cd TFTP wget -v http://ftp.debian.org/debian/dists/jessie/main/installer-amd64/current/images/netboot/netboot.tar.gz tar xzvf netboot.tar.gz mkdir temp cd temp cat ../debian-installer/amd64/initrd.gz | gzip -d | sudo cpio -i ## Create and adapt preseed file ## Source: https://www.debian.org/releases/jessie/example-preseed.txt ### Create preseed file wget -v https://www.golem.de/projekte/vbox/preseed.cfg ### %ADAPT% according to your needs. sed -ie 's/<Rechnername>/x2016-ux-srv-deb/g' preseed.cfg sed -ie 's/<localhost>/milkyway/g' preseed.cfg sed -ie 's/<Benutzername>/nobody/g' preseed.cfg sed -ie 's/<Benutzerkürzel>/nb/g' preseed.cfg sed -ie 's/<Passwort>/start/g' preseed.cfg sed -ie 's/<Passwort wiederholt>/start/g' preseed.cfg # %TODO%: How can I put this string # ::respawn:cat /var/log/syslog > /dev/ttyS0 # in /etc/inittab # below the entry # "logging"? # DONE MANUALLY!!! ## Build install image find | cpio -o --format=newc | gzip -9c > ../initrd.gz ## Copy initrd.gz to install image cp ../initrd.gz ./debian-installer/amd64/ # EOF . -- schnipp (Ende Skript 3) -- Mit den Änderungen an der Host Machine sudo gpasswd --add root dialout sudo apt-get install socat zeigt der Aufruf von vboxmanage startvm "Debian_Server" --type headless -- schnipp -- Waiting for VM "x2017-vbox-srv-ux-1001" to power on... VM "x2017-vbox-srv-ux-1001" has been successfully started. -- schnipp -- Die VM sollte sich nach der Installation selbständig beenden. Das findet jedoch trotz langer Wartezeit nicht statt. Die Installationskontrolle socat unix-Client:/tmp/deb_debug stdout zeigt keine Ausgabe. Wo liegt mein Fehler? Was muss ich ändern, um die Installation in die VM hinzubekommen? Viele Grüße Georg _______________________________________________ Trolug_trolug.de mailing list [email protected] https://ml01.ispgateway.de/mailman/listinfo/trolug_trolug.de
