I have script to setup headless machine on remote headless server, connected by ssh. It will create machine, attaches disk and archiso, and launches installation.Also, I have script to setup configured Arch, which I launch in its prompted shell, previously pulled by scp.But there are three intermediate steps between them I would like to eliminate.Pressing Enter on x64 install in grub of archiso, waiting for login in root shell, executing scp user@server:~/arch-install . && ./arch-installAll those actions I can do through RDP. But it's irritating, to be able to automate all installation process beside that. Of course, there is topic Headless linux install. But I would prefer not to repack archiso, as I need to automate only those 3 steps. Maybe VBox supporting something like expect?
VBox on headless server: install linux without RDP
scripting;virtualbox;arch linux;headless
I had found the way to implement the automatic guest installation of default archiso image, controlling only host machine, however it's somewhat cumbersome. You need to combine VBox native functionality with exposed serial port over ssh.Enable virtual serial port support for VBox:VBoxManage modifyvm $VNM --uart1 0x3F8 4 --uartmode1 server $SERIALLaunch vbox:VBoxManage startvm $VNM# Wait for boot menu. WARNING: May be affected by problem with timing!sleep 8Send commands into guest to enable serial port on kernel's boot:# Press <Tab> to edit boot string, add 'console=ttyS0', then <Enter>VBoxManage controlvm $VNM keyboardputscancode 0f 8f 39 b9  # <Tab><Space>VBoxManage controlvm $VNM keyboardputscancode 2e ae 18 98 31 b1 1f 9f 18 98 26 a6 12 92  # 'console'VBoxManage controlvm $VNM keyboardputscancode 0d 8d 14 94 14 94 15 95 36 1f 9f b6 0b 8b  # '=ttyS0'VBoxManage controlvm $VNM keyboardputscancode 1c 9c  # EnterLogin into shell by serial pipe. I used netcat, but either will work. Next commands show how to work with socket locally (but you can redirect to ssh):sleep 25printf root\n | nc -q 2 -U $SERIALSend installation script as heredoc over socket. It was simpler than my primary approach with scp. Hovewer you can execute scp over serial too.printf \n'cat - <<-''EOFARCHSETUP' > ~/arch-setup\n | nc -U $SERIALcat $SCRIPT_DIR/arch-setup | nc -U $SERIAL  # Send text content of setup fileprintf \nEOFARCHSETUP\n | nc -U $SERIAL     # End of heredoc fileStart installation:printf \nchmod u+x ~/arch-setup\n | nc -U $SERIAL      # Make executableprintf \ncd ~ && ./arch-setup --new\n | nc -U $SERIAL  # Start installNon-interactive monitoring of installation (safe with Ctrl-C to interrupt monitoring only w/o affecting the installation):nc -d -U $SERIAL  If there are some unclear moments left, you can see full scripts at Github