Onion Information
Using QEMU without GUI
Using QEMU without GUI
Onion Details
Page Clicks: 1
First Seen: 03/12/2024
Last Indexed: 10/22/2024
Onion Content
Using QEMU without GUI Hello everyone, this should be a very simple tutorial on how to install Debian OS as a VM in a remote server, without usage of GUI. For this we will be using QEMU as the virtualization software and for the server I will be using ~vern , since it is the first pubnix that I got access. [Connecting] First step is to connect on the server you will be using for the task, in my case ~vern as said before, but to keep my privacy I always connect using Tor , I will not get into details of security/anonimity here, but here is the command to access my account on vern~ and the motd you should see if you are also using some similar pubnix $ ssh -i vern.cc/vern.cc giggles@vern.cc -o ProxyCommand='nc -x 127.0.0.1:9050 %h %p' Last login: Sat Jun 17 18:21:08 2023 from 127.0.0.1 Welcome to ▄▄ ▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄ ▀▄▄ ▄▄▀ ▄▄▀ ▀▄▄ ▄▄▄ ▀▄ ▄▄▀ ▄▄ ▀▀ ▀▀▀▀ ▄▄ ▄▄ ▄▄▀▀▀▀▀▀ ▄▄ ▄▄▄▀ ▀▄▄▄▄▄▄ ▄▄▄▄▄ ▄▄ ▀▀▀ ▀▀▀▀▀ ▀▀ We run NixOS on the pubnix! You can use home-manager/nix-env to install and configure your favorite programs. System information as of: Sat Jun 17 07:09:07 PM UTC 2023 -------------------------------------------------------------- System load: 0.18/0.09/0.09 Uptime: 7 days 15 hours 56 min Disk usage: 36G Memory usage: 3.8G Active Users: 3 Processes: 311 -------------------------------------------------------------- You can join us on - IRC at #vern on irc.tilde.chat - Matrix at #vern:vern.cc - XMPP at vern@muc.vern.cc Enjoy your stay! [127.*.0.1:22] [giggles@verntil:~] 127402μs $ [Installing software] Oh Yeh, we get into our shell in the previous step, but now we need to install the software for proceed with out goal, this is step can vary a lot depending upon the distro/OS you are using, as you can see vern~ uses nixos , I never used this one before, but the motd alread give the tip that we will be using nix-env to install our things here. I just linked the reference to the command, So I will just reproduce the commands as is: [127.*.0.1:22] [giggles@verntil:~] 271320μs $ nix-env -i tmux qemu installing 'tmux-3.2a' installing 'qemu-7.0.0' building '/nix/store/jji2bc36gjwj2652bvq7m34kvw91g0fq-user-environment.drv'... [Download OS] Here we will be using Debian, because I know it can work easy with his text installer, at the time of this writing the latest version is Debian 12, but whatever time you are reading thi you can just search in your favorite search engine "debian netinst", and you will find link like that one https://www.debian.org/CD/netinst/ . Once you open this page you can choose for the arch you want, I go with AMD64 , Here I will use wget to fetch the iso. [127.*.0.1:22] [giggles@verntil:~] 8127μs $ wget https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.0.0-amd64-netinst.iso --2023-06-17 19:45:37-- https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.0.0-amd64-netinst.iso Resolving cdimage.debian.org (cdimage.debian.org)... 194.71.11.165, 194.71.11.163, 194.71.11.173, ... Connecting to cdimage.debian.org (cdimage.debian.org)|194.71.11.165|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://gemmei.ftp.acc.umu.se/debian-cd/current/amd64/iso-cd/debian-12.0.0-amd64-netinst.iso [following] --2023-06-17 19:45:39-- https://gemmei.ftp.acc.umu.se/debian-cd/current/amd64/iso-cd/debian-12.0.0-amd64-netinst.iso Resolving gemmei.ftp.acc.umu.se (gemmei.ftp.acc.umu.se)... 194.71.11.137, 2001:6b0:19::137 Connecting to gemmei.ftp.acc.umu.se (gemmei.ftp.acc.umu.se)|194.71.11.137|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 773849088 (738M) [application/x-iso9660-image] Saving to: ‘debian-12.0.0-amd64-netinst.iso’ debian-12.0.0-amd64-netinst.iso 100%[========================================================================================================>] 738.00M 22.6MB/s in 36s 2023-06-17 19:46:15 (20.8 MB/s) - ‘debian-12.0.0-amd64-netinst.iso’ saved [773849088/773849088] [Preparing HD file] Great, we are almost ready to boot our VM, but we need an "HD" before so we can install the OS, for this we will be using a file with the "best" format(qcow2) to use just the needed space on the host. We will create the file 'hd.qcow2' to have at most 5G using the tool qemu-img with a single command as follows [127.*.0.1:22] [giggles@verntil:~] 8468μs $ qemu-img create -f qcow2 hd.qcow2 5G Formatting 'hd.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=5368709120 lazy_refcounts=off refcount_bits=16 [Booting to Install] Ok, cool! Now we have everything we need to proceed, I will not get into details of using tmux here, but it will be used se we can keep qemu running and access other shell and also let it running even if we disconnect from the server. For this we will create a new tmux session and boot our VM. [127.*.0.1:22] [giggles@verntil:~] 17s 739936μs $ tmux new -s VM *now from the tmux session* [127.*.0.1:22] [giggles@verntil:~] 4543μs $ qemu-system-x86_64 -m 512 -hda hd.qcow2 -cdrom debian-12.0.0-amd64-netinst.iso -display curses *following thing will pop on your terminal* 640 x 480 Graphic mode Well, its not supposed to work without GUI?! Yes, keep calm, when you get this in your terminal just press ESC, and you will be prompted to input boot options, you should input "install vga=false fb=false lowmem=1", your terminal should looks as follow if you followed those steps boot: install DEBIAN_FRONTEND=text console=ttyS0 Once you hit enter and wait some seconds, you will noticed that "... Graphic mode" appeared again on your terminal, dont worry, we need to switch to the serial console since we are going to use the text installer, for this you just need to type "ESC 3", I mean press ESC and then '3', and tada you should see something like this: serial0 console Starting system log daemon: syslogd, klogd. Low memory ---------- Entering low memory mode This system has relatively little free memory, so it will enter low memory mode. Among other things, this means that this program will proceed in English. You should set up swap space as soon as possible. [Press enter to continue] Here we go, we are about to install the OS, I will not get into details of all steps, if you already installed debian with GUI, its pretty much the same steps. Unless you need very custom settings is like "next, next, next". But you should select sshd when prompted about which packages installer should pre-install for your, from the previous screen when you press enter, you will see the following after a few seconds, and this confirm you managed to reach the installer: [ (1*installer) 2 shell 3 shell 4- log ][ Jun 17 21:08 ] Select your location -------------------- The selected location will be used to set your time zone and also for example to help select the system locale. Normally this should be the country where you live. Select the continent or region to which your location belongs. Continent or region: 1: Africa, 5: Caribbean, 9: North America, 2: Antarctica, 6: Central America, 10: Oceania, 3: Asia, 7: Europe, 11: South America, 4: Atlantic Ocean, 8: Indian Ocean, Prompt: '?' for help> I will just put another part of installer here, Its really cool if you enjoy text-only programs like me, this the part where you are prompted about partitions: [ (1*installer) 2 shell 3 shell 4- log ][ Jun 17 21:24 ] Detecting disks and all other hardware ... 2%... 95%... 100% Loading additional components ... 12%... 25%... 37%... 50%... 62%... 75%... 87% ... 100% Loading additional components ... 25%... 50%... 75%... 100% Starting up the partitioner ... 4%... 12%... 20%... 33%... 41%... 50%... 62%... 70%... 83%... 91%... 100% Partition disks --------------- The installer can guide you through partitioning a disk (using different standard schemes) or, if you prefer, you can do it manually. With guided partitioning you will still have a chance later to review and customise the results. If you choose guided partitioning for an entire disk, you will next be asked which disk should be used. Partitioning method: 1: Guided - use entire disk, 2: Guided - use entire disk and set up LVM, 3: Guided - use entire disk and set up encrypted LVM, 4: Manual, Prompt: '?' for help> Here is the part I said before, make sure ssh is marked, because it will be useful once you finish the install phase: [ (1*installer) 2 shell 3 shell 4- log ][ Jun 18 1:23 ] Participate in the package usage survey? 1: Yes 2: No [*] Prompt: '?' for help, default=2> 2 ... 16% Software selection ------------------ At the moment, only the core of the system is installed. To tune the system to your needs, you can choose to install one or more of the following predefined collections of software. Choose software to install: 1: Debian desktop environment, 7: ... MATE, 2: ... GNOME, 8: ... LXDE, 3: ... Xfce, 9: ... LXQt, 4: ... GNOME Flashback, 10: web server, 5: ... KDE Plasma, 11: SSH server [*], 6: ... Cinnamon, 12: standard system utilities [*], Prompt: '?' for help, default=11 12> ... 16%... 20%... 30%... 34%... 40%... 47%... 50%... 58%... 60%... 70%... 75%... Once you finish all steps you will have somthiing like this in your terminal: [ (1*installer) 2 shell 3 shell 4- log ][ Jun 18 2:00 ] You need to make the newly installed system bootable, by installing the GRUB boot loader on a bootable device. The usual way to do this is to install GRUB to your primary drive (UEFI partition/boot record). You may instead install GRUB to a different drive (or partition), or to removable media. Device for boot loader installation: 1: Enter device manually, 2: /dev/sda (ata-QEMU_HARDDISK_QM00001), Prompt: '?' for help> 2 ... 50%... 66%... 83%... 100% Finishing the installation ... 3%... 10%... 21%... 28%... 32%... 35%... 42% Finish the installation ----------------------- Installation complete Installation is complete, so it is time to boot into your new system. Make sure to remove the installation media, so that you boot into the new system rather than restarting the installation. Please choose to reboot. [Press enter to continue] Instead of restarting our virtual machine we will finish it to change a bit the parameters to run qemu and start it again, to do this the right way we will change to the qemu console, for this press 'ESC' + '2' and you should see the qemu console, just use the command quit as follow (qemu) quit [Start the VM] Now you are back on the shell, just need to run qemu again, but we dont need the -cdrom parameter anymore and we will add a port forward so we can access the ssh of our new VM from the host, $ qemu-system-x86_64 -m 512 -hda hd.qcow2 -display curses -nic user,hostfwd=tcp:127.0.0.1:6022-:22 * ESC + 3 * Booting `Debian GNU/Linux' Loading Linux 6.1.0-9-amd64 ... Loading initial ramdisk ... Please unlock disk sda5_crypt: cryptsetup: ...