Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

A few notes:

  • Raspbian offers an image for use with Hypervisors such as VMWare, but it won't work with packages built for ARM CPU
  • Qemu can emulate the ARM CPU to run the Raspbian OS, but its slow, limited to 256MB/s and doesn't have the advanced features like VMWare (Attaching USB, Network Functions etc). It is BARE BONES
  • This took me a LONG time to figure out over multiple articles/days and will take a long time to follow guide since rebooting Qemu/VM can take 10Minutes.

Goals:

  • Expanding Raspbian img root partition to have free space
  • Enable SSH on boot
  • Expanding SWAP from 100MB to 1GB
  • Overclock CPU
  • Change locale from GB (Great Britian) to EN-US (English US)  because the keyboards are different, typing " = @ on the GB Keyboard and vice versa
  • Create shortcut to batch file to launch Qemu
  • Things should be done in order, they are in this order for a reason!

Files Needed:

Qemu x64 or x32 @ https://qemu.weilnetz.de/w64/ I used >> qemu-w64-setup-20171217

Rasbian OS @ https://www.raspberrypi.org/downloads/raspbian/ I used >> 2017-11-29-raspbian-stretch

Kernel @ https://github.com/dhruvvyas90/qemu-rpi-kernel I used >> kernel-qemu-4.4.34-jessie

Qemu_RPI_Shortcut.7z

Folder Setup:

Extract Qemu.exe into folder qemu (No Need to install)
Extract Kernel into qemu folder and rename kernel-qemu
Extract *.img from *.zip raspbian OS into qemu folder and rename raspbian.img

Copy folder to root of C:\ eg (C:\qemu\

Expanding Raspbian img root partition to have free space:

A) Reshape Raw IMG with Qemu in CMD Prompt:

https://blog.agchapman.com/using-qemu-to-emulate-a-raspberry-pi/

Convert to QCow2

cd C:\qemu
qemu-img convert -f raw -O qcow2 raspbian.img raspbian.qcow 

Resize root partition of QCow

qemu-img.exe resize raspbian.qcow +10G

Launch Raspbian OS w/ Qemu

qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda raspbian.qcow -net user,hostfwd=tcp::2222-:22 -net nic

  • There is a LOT of flags, hence the shortcut later. I won't explain them all, google is your friend, but! Note: hostfwd=tcp::2222-:22, this allows SSH via pi@localhost:2222

Enable SSH (on boot):

  • This allows copy and paste via SSH
sudo /etc/init.d/ssh start
  • ssh into machine as pi@127.0.0.1:2222
  • The default is username “pi” password “raspberry”
sudo systemctl enable ssh	(Enable SSH on Boot)


Expanding Raspbian img root partition to have free space:

B)You only made the img larger, now you need to make the OS aware

https://www.raspberrypi.org/forums/viewtopic.php?f=26&t=44856

  • Copy and paste!
sudo cp /usr/bin/raspi-config ~
sudo sed -i 's/mmcblk0p/sda/' ~/raspi-config
sudo sed -i 's/mmcblk0/sda/' ~/raspi-config
sudo ~/raspi-config

Select "Advanced Options" >> "Expand Filesystem"

Note: You should also do some other things in "raspi-config" this is a usefull tool to learn

1. Overclock at this point, select option "Overclock", accept warning, select Max setting (Turbo)

2. Change local from GB (Great Britian) to whatever, IE: "en_US-UTF-8"

  • Select "Localisation Options" >> "Change Locale" >>  Select Local >> Select Local again >> OK 


YOU MUST NOW REBOOT!


Expanding SWAP from 100MB to 1GB:

(Don't try to do this before resizing FS or you won't have enough room for swap file~!)

https://www.raspberrypi.org/forums/viewtopic.php?f=50&t=28384

Check current setting is 100 and change to 1024 (1GB)

cat /etc/dphys-swapfile | grep CONF_SWAPSIZE
sudo sed -i 's,^\(CONF_SWAPSIZE[ ]*=\).*,\1'1024',g' /etc/dphys-swapfile
cat /etc/dphys-swapfile | grep CONF_SWAPSIZE

Check SWAP current status

free -m

Remove and Stop current SWAP

sudo /etc/init.d/dphys-swapfile stop
sudo /sbin/dphys-swapfile swapoff
sudo rm /var/swap

Check SWAP current status

free -m

Create NEW Swap:

sudo /sbin/dphys-swapfile setup
sudo mkswap /var/swap
sudo chmod 0600 /var/swap
sudo dphys-swapfile swapon

Check SWAP current status

free -m

Create shortcut to batch file to launch Qemu:

  • Extract 7zip archive with shortcut to C:\qemu

Inside will be 3 files:

  • invisible.vbs
  • rpi_qemu.cmd

    cd C:\qemu
    qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda raspbian.qcow -net user,hostfwd=tcp::2222-:22 -net nic
  • rpi_qemu_silent.cmd

    wscript.exe "C:\qemu\cmd\invisible.vbs" "C:\qemu\cmd\rpi_qemu.cmd"
  • Now create a shortcut to rpi_qemu_silent.cmd wherever you want.
  • The invisible.vbs hides the CMD window that launches Qemu, its very usefull, I use it for lots of CMDs!

Outdated, but good information @ https://blogs.msdn.microsoft.com/iliast/2016/11/10/how-to-emulate-raspberry-pi/

 

 

  • No labels

1 Comment