{"id":37530,"date":"2019-10-31T22:18:10","date_gmt":"2019-10-31T19:18:10","guid":{"rendered":"https:\/\/prohoster.info\/blog\/ip-kvm-cherez-qemu\/"},"modified":"2019-10-31T22:18:10","modified_gmt":"2019-10-31T19:18:10","slug":"ip-kvm-cherez-qemu","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/ip-kvm-cherez-qemu","title":{"rendered":"IP-KVM via QEMU","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><img decoding=\"async\" alt=\"IP-KVM via QEMU\" src=\"\/wp-content\/uploads\/2019\/08\/f9620a262b690b4494984658d33805f9.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nTroubleshooting operating system boot issues on servers without KVM is a challenging task. We create KVM-over-IP through a recovery image and a virtual machine.<\/p>\n<p>In case of problems with the operating system <noindex><a rel=\"nofollow\" href=\"http:\/\/slc.tl\/q58Za\">on the remote server<\/a><\/noindex>, the administrator loads a recovery image and carries out the necessary work. This method works well when the cause of the failure is known and the recovery image and the operating system installed on the server belong to the same family. If the cause of the failure is not yet known, it is necessary to observe the boot process of the operating system.<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h2>Remote KVM<\/h2>\n<p>\nAccess to the server console can be achieved using built-in tools such as IPMI or Intel\u00ae vPro\u2122, or with external devices called IP-KVM. There are situations where none of the listed technologies are available. However, this is not the end. If the server can be remotely rebooted into a recovery image based on a Linux family operating system, KVM-over-IP can be quickly organized.<\/p>\n<p>The recovery image is a fully functional operating system that resides in RAM. Therefore, we can run any software, including virtual machines (VMs). This means that a VM can be launched, inside which the server's operating system will operate. Access to the VM console can be arranged, for example, via VNC.<\/p>\n<p>To start the server's operating system inside a VM, you need to specify the server disks as the VM disks. In Linux family operating systems, physical disks are represented as block devices of the type <b>\/dev\/sdX<\/b>, which can be operated on like regular files.<\/p>\n<p>Some hypervisors, such as QEMU and VirtualBox, allow storing VM data in a \u2018raw\u2019 format, which means only the storage data without hypervisor metadata. Thus, the VM can be launched using the physical disks of the server.<\/p>\n<p>This method requires resources to run the recovery image and the VM within it. However, with four or more gigabytes of RAM, this will not be a problem.<\/p>\n<h2>Preparing the Environment<\/h2>\n<p>\nA lightweight and simple program can be used as a virtual machine <noindex><a rel=\"nofollow\" href=\"https:\/\/www.qemu.org\/\">QEMU<\/a><\/noindex>, which is often not part of the recovery image, so it needs to be installed separately. The recovery image we offer to clients is based on <noindex><a rel=\"nofollow\" href=\"https:\/\/www.archlinux.org\/\">Arch Linux<\/a><\/noindex>, which uses the package manager <b>pacman<\/b>.<\/p>\n<p>First, make sure that the recovery image uses the latest software versions. You can check and update all OS components with the following command:<\/p>\n<p><code>pacman -Suy<\/code><\/p>\n<p>After the update, you need to install QEMU. The command for installation via pacman will look like this:<\/p>\n<p><code>pacman -S qemu<\/code><\/p>\n<p>Let's check that qemu has been installed correctly:<\/p>\n<p><code>root@sel-rescue ~ # qemu-system-x86_64 --version<br \/>\nQEMU emulator version 4.0.0<br \/>\nCopyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers<\/code><\/p>\n<p>If everything is fine, the recovery image is ready to use.<\/p>\n<h2>Starting the virtual machine<\/h2>\n<p>\nFirst, determine the amount of resources allocated to the VM, and find the paths to the physical disks. In our case, we will allocate two cores and two gigabytes of RAM to the virtual machine, and the disks are located at <b>\/dev\/sda<\/b> and <b>\/dev\/sdb<\/b>. Let's start the VM:<\/p>\n<p><code>qemu-system-x86_64 <br \/>\n -m 2048M <br \/>\n -net nic -net user <br \/>\n -enable-kvm <br \/>\n -cpu host,nx <br \/>\n -M pc <br \/>\n -smp 2 <br \/>\n -vga std <br \/>\n -drive file=\/dev\/sda,format=raw,index=0,media=disk <br \/>\n -drive file=\/dev\/sdb,format=raw,index=1,media=disk <br \/>\n -vnc :0,password <br \/>\n -monitor stdio<\/code><\/p>\n<p>A bit more about what each parameter means:<\/p>\n<ul>\n<li><b>-m 2048M<\/b> \u2014 allocate 2 GB of RAM to the VM;<\/li>\n<li><b>-net nic -net user<\/b> \u2014 add a simple network connection via the hypervisor using NAT (Network Address Translation);<\/li>\n<li><b>-enable-kvm<\/b> \u2014 enable full KVM (Kernel Virtual Machine) virtualization;<\/li>\n<li><b>-cpu host<\/b> \u2014 tell the virtual CPU to utilize all features of the server's CPU;<\/li>\n<li><b>-M pc<\/b> \u2014 PC hardware type;<\/li>\n<li><b>-smp 2<\/b> \u2014 the virtual CPU should be dual-core;<\/li>\n<li><b>-vga std<\/b> \u2014 select a standard graphic card that does not support high resolutions;<\/li>\n<li><b>-drive file=\/dev\/sda,format=raw,index=0,media=disk<\/b>\n<ul>\n<li><b>file=\/dev\/sdX<\/b> \u2014 the path to the block device representing the server's disk;<\/li>\n<li><b>format=raw<\/b> \u2014 indicate that all data in the specified file is in 'raw' format, that is, just like on the disk;<\/li>\n<li><b>index=0<\/b> \u2014 disk number, which should increase by one for each subsequent disk;<\/li>\n<li><b>media=disk<\/b> \u2014 the virtual machine should recognize this storage as a disk;<\/li>\n<\/ul>\n<\/li>\n<li><b>-vnc :0, password<\/b> \u2014 start the VNC server by default on 0.0.0.0:5900, using a password for authorization;<\/li>\n<li><b>-monitor stdio<\/b> \u2014 communication between the administrator and qemu will occur through standard input-output streams.<\/li>\n<\/ul>\n<p>\nIf everything is fine, the QEMU monitor will start: <\/p>\n<p><code>QEMU 4.0.0 monitor - type 'help' for more information<br \/>\n(qemu)<\/code><\/p>\n<p>We specified that the authorization occurs by password, but we did not specify the password itself. This can be done by sending the command change vnc password in the QEMU monitor. Important note: the password cannot be longer than eight characters.<\/p>\n<p><code>(qemu) change vnc password<br \/>\nPassword: ******<\/code><\/p>\n<p>After this, we can connect with any VNC client, such as Remmina, using the IP address of our server along with the specified password.<\/p>\n<p><img decoding=\"async\" alt=\"IP-KVM via QEMU\" src=\"\/wp-content\/uploads\/2019\/08\/f735a37d49038b472d6e5c22df4e7570.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n<img decoding=\"async\" alt=\"IP-KVM via QEMU\" src=\"\/wp-content\/uploads\/2019\/08\/02a12b62938a7883363807eaa379279f.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nNow we can not only see possible errors during the boot stage, but also deal with them.<\/p>\n<p>Upon completion of work, the virtual machine must be shut down. This can be done either from within the OS by sending a shutdown signal or by issuing a command <b>system_powerdown<\/b> in the QEMU monitor. This will be equivalent to pressing the shutdown button once: the operating system inside the virtual machine will shut down smoothly.<\/p>\n<h2>Installing the operating system<\/h2>\n<p>\nThe virtual machine has full access to the server's disks and can therefore be used to manually install the operating system. The only limitation is the amount of RAM: the ISO image cannot always fit in memory. We will allocate four gigabytes of memory to store the image in <b>\/mnt<\/b>:<\/p>\n<p><code>mount -t tmpfs -o size=4G tmpfs \/mnt<\/code><\/p>\n<p>We will also download the installer image of FreeBSD 12.0:<\/p>\n<p><code>wget -P \/mnt ftp:\/\/ftp.freebsd.org\/pub\/FreeBSD\/releases\/amd64\/amd64\/ISO-IMAGES\/12.0\/FreeBSD-12.0-RELEASE-amd64-bootonly.iso<\/code><\/p>\n<p>Now we can start the VM:<\/p>\n<p><code>qemu-system-x86_64 <br \/>\n -m 2048M <br \/>\n -net nic -net user <br \/>\n -enable-kvm <br \/>\n -cpu host,nx <br \/>\n -M pc <br \/>\n -smp 2 <br \/>\n -vga std <br \/>\n -drive file=\/dev\/sda,format=raw,index=0,media=disk <br \/>\n -drive file=\/dev\/sdb,format=raw,index=1,media=disk <br \/>\n -vnc :0,password <br \/>\n -monitor stdio <br \/>\n -cdrom \/mnt\/FreeBSD-12.0-RELEASE-amd64-bootonly.iso <br \/>\n -boot d<br \/>\n<\/code><\/p>\n<p>Flag <b>-boot d<\/b> it sets the boot from the CD drive. We connect using a VNC client and see the FreeBSD bootloader.<\/p>\n<p><img decoding=\"async\" alt=\"IP-KVM via QEMU\" src=\"\/wp-content\/uploads\/2019\/08\/722f904ba4212bcce8746ca473489d50.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nSince DHCP was used to obtain the internet address, it may be necessary to boot into the newly installed system after configuration and fix network settings. In some cases, installing network adapter drivers may be required, as the network card installed on the server and emulated in the VM differ.<\/p>\n<h2>Conclusion<\/h2>\n<p>\nThis method of organizing remote access to the server console consumes some of the server's resources; however, it does not impose any special requirements on the server's hardware, making it feasible under virtually any conditions. Using this solution significantly facilitates the diagnosis of software issues and the recovery of the remote server's functionality.<br \/>\n<br \/>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/selectel\/blog\/464565\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0423\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043d\u0435\u0438\u0441\u043f\u0440\u0430\u0432\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445 \u0431\u0435\u0437 KVM \u2014 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0437\u0430\u043d\u044f\u0442\u0438\u0435. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0431\u0435 KVM-over-IP \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u0440\u0430\u0437 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0437 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b. \u0422\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u0441\u0431\u043e\u044f \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430, \u0430 \u043e\u0431\u0440\u0430\u0437 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":28165,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-37530","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0423\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043d\u0435\u0438\u0441\u043f\u0440\u0430\u0432\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/ip-kvm-cherez-qemu\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47IP-KVM \u0447\u0435\u0440\u0435\u0437 QEMU | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0423\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043d\u0435\u0438\u0441\u043f\u0440\u0430\u0432\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/ip-kvm-cherez-qemu\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-10-31T19:18:10+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-10-31T19:18:10+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47IP-KVM via QEMU | ProHoster","description":"Troubleshooting operating system boot issues on servers.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/ip-kvm-cherez-qemu","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47IP-KVM \u0447\u0435\u0440\u0435\u0437 QEMU | ProHoster","og:description":"\u0423\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043d\u0435\u0438\u0441\u043f\u0440\u0430\u0432\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445.","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/ip-kvm-cherez-qemu","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-10-31T19:18:10+00:00","article:modified_time":"2019-10-31T19:18:10+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"37530","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-23 18:15:20","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-03-01 01:25:26","updated":"2026-01-23 18:15:20","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/37530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=37530"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/37530\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media\/28165"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=37530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=37530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=37530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}