- Information Security Squad
- 🍓 Эмуляция Raspberry Pi на QEMU
- Установка Raspbian:
- Устранение неполадок службы SSH:
- Изменение размера образа Raspbian:
- Запускаем и эмулируем Windows на Raspberry Pi с помощью QEMU
- Raspberry Pi Emulation for Windows with QEMU
- Install QEMU on Windows
- Get a Linux Kernel and the latest Raspbian
- Resize the Raspbian image
- Create a startup batch file
- Configure the Raspberry Pi emulation for QEMU
- Raspberry Pi emulation: The first run
- Did you have any trouble with the Raspberry Pi emulation?
- Support PCsteps
- About Angelos Kyritsis
Information Security Squad
stay tune stay secure
🍓 Эмуляция Raspberry Pi на QEMU
- Образ Raspbian: http://downloads.raspberrypi.org/raspbian/images/raspbian-2017-04-10/ (другие версии могут работать, но рекомендуется Jessie)
- Ядро QEMU: https://github.com/dhruvvyas90/qemu-rpi-kernel
Установка Raspbian:
Внутри вашей Ubuntu VM создайте новую папку:
Загрузите и разместите Образ Raspbian в
Загрузите и поместите ядро qemu в
Закомментируйте каждую запись в этом файле с помощью «#», сохраните и выйдите с помощью Ctrl-x >> Y.
Если вы видите что-то с mmcblk0 в fstab, то:
- Замените первую запись, содержащую /dev/mmcblk0p1, на /dev/sda1
- Замените вторую запись, содержащую /dev/mmcblk0p2, на /dev/sda2, сохраните и выйдите.
Теперь вы можете эмулировать его в Qemu, используя следующую команду:
Из терминала вам нужно запустить службу SSH, чтобы вы могли получить к ней доступ из вашей хост-системы (той, с которой вы запустили qemu).
Устранение неполадок службы SSH:
Если SSH не запускается в вашем эмуляторе при запуске по умолчанию, вы можете изменить это в своем терминале Pi с помощью:
Если ваш эмулируемый Pi запускает графический интерфейс и вы хотите, чтобы он запускался в режиме консоли при запуске, используйте следующую команду в вашем терминале Pi:
Изменение размера образа Raspbian:
Когда вы закончите настройку, у вас останется 3,9 ГБ на вашем образе.
Чтобы увеличить образ Raspbian, выполните следующие действия на вашем компьютере с Ubuntu:
Создайте копию вашего существующего образа:
Запустите эту команду, чтобы изменить размер вашей копии:
Запускаем и эмулируем Windows на Raspberry Pi с помощью QEMU
Скорее всего это первый русскоязычный мануал о настройке QEMU на Raspberry.
Какое-то время назад я загорелся идеей запустить на своей Raspberry Pi 2 какую-нибуть Windows систему. Сначала я хотел узнать возможно ли установить её, просто записав на SDCARD и вставив в «малинку», но этому не дано было осуществится…
После я стал искать возможность запуска через какие-нибудь эмуляторы. Наткнулся на QEMU и стал копаться с ним. Пытался я запустить эмулятор очень долго, почти всё, что я находил на форумах, было написано на английском, причём информации там было «по-минимуму», а людей, которые запустили, было совсем немного. После нескольких неудачных попыток запуска QEMU, я решил написать на 4PDA в теме, посвящённой Raspberry. Там мне помогли, и я благополучно запустил Windows 98 (почти идеально. ). Запускал я это на Raspibiane (Debian).
Начнём, открываем терминал и прописываем это:
Желательно всё это делать через putty, чтобы всё символы точно соответствовали написанному.
Команда начинает скачивать «внутренности» эмулятора, этот процесс не займёт много времени.
После того, как файл скачается и распакуется, появится папка (расположение /home/%username%/qemu), в которой будут расположены все файлы, которые необходимы для работы эмулятора. После того, как у нас всё скачалось и распаковалось, прописываем это:
Начинается процесс конфигурации, это не займёт много времени (
30-60 секунд). Теперь нам нужно запустить процесс отладки:
После ввода команды, начнётся отладка, она выглядит примерно так:
15-20 минут). Последнее, что мы должны сделать, это подправить конфиги и отладить.
Иногда при выполнение вышеперечисленных команд система создаёт новый файл, тогда выходим из редактора и руками открываем необходимые конфиги.
Зажимаем Ctrl+W, открывается строка поиска, вводим: static void tcg_out_addi. Меняем на static inline void tcg_out_addi. Переходим ко второму конфигу, так же вызываем строку поиска и вводим этот текст: static void tcg_out_opc и меняем на static inline void tcg_out_opc. Если вы не нашли какую-то из строк, то ничего не делаем, а просто закрываем конфиг и выполняем следующий шаг (в первом конфиге я не нашёл нужную строку, однако эмулятор у меня работает нормально).
Если вы закончили с заменой строк, продолжаем дальше мучать нашу «малинку»:
Настройку эмулятора мы закончили. Теперь перейдём к запуску системы. Насколько я знаю, эмулятор поддерживает данные форматы образов:
.img — Образ системы.
.vhd — Виртуальный «хард»
.iso — Образ диска.
Скачать образы интересующих вас систем можно тут, там же есть инструкция по созданию своего образа системы.
Я собрал на Яндекс.Диске все образы, которые запускаются на QEMU и взяты из темы, ссылка на которую дана выше. Стоит заметить, что в названии образа Linux KDE написан пароль от пользователя.
Переходим к запуску систему. Пишем в консоль:
Если все настройки верны, должна начаться загрузка образа системы.
Это фото, как скринить в линуксе я так и не освоил.
QEMU может эмулировать не только i386 процессоры, но и другие «платформы», подробнее:
Данный запрос вызывает список команд QEMU:
Поиграйтесь с настройками QEMU, сам ещё не до конца разобрался с ним. Стоит учесть, что я запускал систему, используя ресурсы только одного ядра «малинки», при этом компьютер нагружался на 25-26% (запускал Win98). Я читал на форумах о многопоточной работе QEMU с образом системы, но так и не понял как заставить эмулятор использовать ресурсы больше, чем одного ядра. Опять же, поиграйтесь с настройками и возможно вы поймёте как настроить многопоточность (не забудьте написать в комментариях как вы это сделали).
Raspberry Pi Emulation for Windows with QEMU
May 4, 2015 Author: Angelos Kyritsis 95
A virtual machine is the best way to test a complete operating system within our OS, without the risk or inconvenience of a dual-boot installation. If, however, we want to try Raspbian, VirtualBox or VMware can’t emulate the ARM processor. Let’s create a Raspberry Pi emulation on Windows with QEMU.
Unblock any international website, browse anonymously, and download movies and Mp3 with complete safety with CyberGhost, just for $2.75 per month:
A Raspberry Pi emulation is a great way to try out the Raspbian environment without buying a Raspberry Pi first.
But, even if we already own the device, with the Raspberry Pi emulation we can test new software in Raspbian without any risk.
Table of Contents
Install QEMU on Windows
First, we need the Windows version of QEMU (Quick EMUlator). We must select the proper binaries for 32-bit or 64-bit Windows.
We download the 20150424 version. The current latest version 20150503 won’t work.
After the installer downloads, we don’t run the application. We use an archiving program, such as 7-zip or WinRAR, to extract all the files it contains.
Let’s say we extract the files on a folder QEMU on the desktop.
Get a Linux Kernel and the latest Raspbian
The next thing we need for the Raspberry Pi emulation is to download a Linux Kernel compiled for ARM and the latest version of the Raspbian operating system, currently 2015-02-16.
We move the Linux Kernel in the QEMU folder, and extract the contents of the Raspbian .zip inside too.
Inside the QEMU folder, it’s important to note the exact filename of the disk Image file.
Resize the Raspbian image
The Raspbian image we downloaded will contain the complete Raspberry Pi emulation, and any programs we will install. So, it’s a good idea to resize the image and give it a couple more Gigabytes.
We do a Windows search for cmd and open the command prompt.
On the command prompt, we navigate to the QEMU folder. If we created it on the desktop, we navigate with:
To resize the Raspbian image, we run the command:
Note that we need to use the exact filename of the image file, with the «.img» extension. The +10G parameter will add 10 Gigabytes to the image, which should be more than enough.
Running the command will produce a Warning, but if we get the «Image resized» message, everything went well.
Create a startup batch file
QEMU doesn’t have a sexy user interface like VirtualBox and VMware. We need to type long commands to start it up. And it’s easier if we create a batch file instead.
We open notepad, or any other plain text editor.
. and paste inside the following command. Ignore the text-wrap, it’s all in one line.
You might have noticed that the -m 256 part of the command will allocate 256MB of RAM for the Raspberry Pi emulation. Unfortunately, we can’t allocate more RAM, or the emulation won’t boot at all. This is a bug of QEMU when doing ARM emulation.
We make perfectly sure that the final part of the command is identical to the filename of the Raspbian disk image.
Then, we save the file as .bat. We make sure we save it inside the QEMU folder, with a .bat extension and that we have selected the «All files» option.
If we did it correctly, we will have a Windows Batch File within QEMU.
We double-click this file to start the Raspberry Pi emulation.
Configure the Raspberry Pi emulation for QEMU
The emulator will load to a command prompt.
This is a Linux command prompt, and as such, it is case-sensitive. Nano or NANO or nAnO won’t work.
The above order will open the ld.so.preload file in the nano text editor. We just need to add a hashtag «#» at the beginning of the single line.
Then we exit nano. We press ctrl+X.
. and then press y for «Yes», to save the changes, and Enter, to overwrite the file.
If we did it correctly, we will get a «Wrote 1 line» message.
Next, we create a new file, with the command:
Inside, we type exactly the following three lines:
We exit with ctrl+X and make sure to save the file (get the «Wrote 3 lines» message).
Then we exit the Raspberry Pi emulation with «exit».
Raspberry Pi emulation: The first run
Now, we ‘re nearly ready to run the Raspberry Pi emulation for Windows.
Fist, we need to edit the batch file we created earlier.
Inside, the only thing we change is to delete the init=/bin/bash option near the end of the command, including the preceding blank space. Be carefull not to delete the quotes.
After that, we save the batch file, and double-click to open it.
It will take a while to load, and it will produce some errors. This is to be expected.
We have to create again the file we previously made, with
This time, however, we write the quotes » with shift+2, because the Raspberry Pi emulation currently has an English UK keyboard layout.
After that, again we exit.
This time, the «exit» command will lead to a reboot, that will get us to the Raspberry Pi Software Configuration Tool. We press «Tab» on the keyboard to select «Finish».
As the pi@raspberrypi user, we type the command:
This command will close the emulation. We start it again, double-clicking the «Start» batch file.
This time, after the boot sequence, the system will ask us to login.
The default credentials are:
Remember, when we type our password on Linux, nothing will show by default, not stars or dots or anything.
Once inside, we type two consecutive orders:
This will get us back to the configuration tool. We select the first option, «Expand Filesystem».
The configuration tool will momentarily close, and in a couple of seconds it will queue up the /root partition to expand and cover all the 10GB of the space on the next reboot.
Again, we press tab to select «Finish».
. and this time, we select to reboot.
The Raspberry Pi emulation will shutdown again. We start it with the «Start» batch.
This time, the boot will take longer. It will seem stuck at the message below.
This is the resize command, and it will take some time. Leave it alone, and in a few minutes it will proceed with the boot.
After we log in as the «pi» user, we do a full update with:
This will also take a while, both to download and to install the updates. When the update is done, we type:
The most important configuration is the «Enable Boot to Desktop/Scratch» option.
There, we select the «Desktop Log in as user ‘pi’ at the graphical desktop» option.
We can also configure other stuff, such as the locales.
Once we are done, we tab to «Finish».
Once again, we select to reboot.
On the next boot, the system will automatically start the graphical user Interface.
That’s it. The Raspberry Pi emulation for Windows is complete.
Did you have any trouble with the Raspberry Pi emulation?
If any of the above didn’t work as described, and you were unable to create a Raspberry Pi emulation, leave us a comment. If you used a different version of QEMU and/or Raspbian, you should also mention the exact versions.
Support PCsteps
Do you want to support PCsteps, so we can post high quality articles throughout the week?
You can like our Facebook page, share this post with your friends, and select our affiliate links for your purchases on Amazon.com or Newegg.
If you prefer your purchases from China, we are affiliated with the largest international e-shops:
- GearBest
- Banggood
- Geekbuying
About Angelos Kyritsis
Angelos Kyritsis is the Editor-In-Chief of PCsteps.gr, which is the #1 Computer Hardware site in Greece.
He loves good beer, having more RAM on his PC that he will ever, ever need, and writing for a living.
He has also published a novel, but it would be, quite literally, all Greek to you.