Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a raspberry pie environment for QEMU

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces QEMU how to build a raspberry pie environment, the article is very detailed, has a certain reference value, interested friends must read it!

0x01

Recently, raspberry pie was borrowed by my classmates to do a complete set, and there was no other ARM platform for me to study, so I had no choice but to try to use QEMU to simulate raspbian. The building process is relatively tedious, and many holes have not been pointed out in the online tutorials, so this article paves the way for friends who are also interested in doing IoT security and ARM platform security.

0x02

What is QEMU?

QEMU is a managed virtual machine image that simulates CPU through dynamic binary transformation and provides a set of device models that enable it to run a variety of unmodified client OS that can be used with KVM (kernel-basedvirtual machine Open Source Accelerator) to run virtual machines close to local speed (close to the speed of real computers).

0x03

Platform description:

Ubuntu18.04 (4G memory, 40G hard disk)

Create a new folder for the project

Put the downloaded raspberry pie image in this folder, and the qemukernel downloaded from github (the official kernel doesn't work in qemu, so I found a useful one on github: https://github.com/dhruvvyas90/qemu-rpi-kernel) here, too, and extract the image.

Use fdisk to observe the physical usage of the hard disk

You can see that the bootstart of img2 is 92160, which is multiplied by 512 (you can see the unit units:sectorsof 1 * 512 = 512bytes in the figure above, which means it needs to be multiplied by 512) to get 47185920, which is the offset in the following command.

Next, create a folder for mounting.

Then use the following mount command

Next, edit the ld.so.preload file, comment its contents, and then use umount to write on the loaded file system

Next, simulate raspberry pie through qemu, using the following command

Qemu-system-arm-kernel ~ / qemu_vms/- cpu arm1176-m 256-Mversatilepb-serial stdio-append "root=/dev/sda2rootfstype=ext4 rw"-hda ~ / qemu_vms/-redir tcp:5022::22-no-reboot

The startup process is shown in the following figure

After startup, it is shown in the figure.

For subsequent convenience, we usually use a remote connection, so install the ssh server first

Start the ssh service on ubuntu and test it on kali

Then start the ssh service on the raspberry pie and you can remotely. The picture below shows me kali remotely to ubuntu and then remotely to raspberry pie.

Or you can access book raspberry pie remotely on kali.

Since we basically connect remotely through ssh, we use the following command to enable raspberry pie to boot up the ssh service

Raspberry pie is displayed in a graphical interface by default. If you want to start it in command line mode, follow these steps

Enter sudoraspi-config to enter the settings page and select bootoption as follows

Then select desktop/cli

Then select consoleautologin

Finally, restart it.

This is what the restarted interface looks like.

Using df-hl at this time, you can see that 3.9g of space is now 3.6g.

In order to meet a rainy day, we need to expand the capacity by installing the following steps

Turn off the raspberry pie first.

Copy a copy of the original image file first

Then expand the capacity of the new image file.

Next, boot the new image after expansion as the second hard disk.

Enter the command and enter the following interface

Delete sdb2 selected in the following figure

Then create a new partition from freespace, select from the following figure

Check write to write

Enter yes to confirm

Will prompt that the write was successful

Then you can quit.

Next, use fsck to check the file system for errors

You can see that there is no error.

Then turn off the raspberry pie.

Next, we only need to use the new image in the command to start the raspberry pie with qemu.

The command is shown in the figure

In this way, all the work is finished.

These are all the contents of the article "how to build a raspberry pie environment in QEMU". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report