SlideShare une entreprise Scribd logo
1  sur  14
Qemu in Chroot
Make it easy
QEMU is a hosted virtual machine
monitor: It emulates central processing
units through dynamic binary translation
and provides a set of device models,
enabling it to run a variety of unmodified
guest operating systems.
Qemu
A chroot on Unix operating
systems is an operation that
changes the apparent root
directory for the current running
process and its children.
Chroot
The Raspberry Pi has a
Broadcom BCM2835 system on
a chip (SoC),[3] which includes
an ARM1176JZF-S 700 MHz
processor
Raspberry Pi
What about speed?
pi@raspberrypi:~$ cat /proc/cpuinfo | grep MIPS
BogoMIPS

: 697.95

pi@raspberrypi:~$ cat /proc/cpuinfo | grep MIPS
BogoMIPS

Not good!

: 565.24
Qemu compilation
ARM1176JZF-S

#
#
#
#

git clone http://git.qemu.org/git/qemu.git
./configure --target-list="arm-softmmu arm-linux-user" --enable-sdl --static
make
sudo make install
Preparation
●
●

Download the latest version of Raspbian (link)
Download the linux kernel for Qemu (link)

# qemu-system -kernel kernel-qemu -cpu arm1176 -M versatilepb -no-reboot -append
"root=/dev/sda2 panic=0 ro single" -hda XXXXX-raspbian.img
# mount / -o remount,rw

●
●

Edit fstab and change mmcblk0p1 and mmcblk0p2 to sda1
and sda2 respectively
Create /etc/udev/rules.d/90-qemu.rules

KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n",

●

Comment everything in /etc/ld.so.preload
Enlarge it!

# cp XXXXX-raspbian.img raspbian.img
# qemu-img resize raspbian.img +6G
# qemu-system -kernel kernel-qemu -cpu arm1176 -M versatilepb -no-reboot -append "root=/dev/sda2 panic=1"
-hda XXXXX-raspbian.img -hdb raspbian.img
# sudo cfdisk /dev/sdb

●Delete the second partition and create a new partition with all space
# sudo resize2fs /dev/sdb2
# sudo fsck -f /dev/sdb2
# sudo halt
# qemu-system -kernel kernel-qemu -cpu arm1176 -M versatilepb -no-reboot -append "root=/dev/sda2 panic=1"
-hda raspbian.img
Chroot it
# sudo kpartx -a -v 2012-12-16-wheezy-raspbian.img
add map loop0p1 (252:8): 0 114688 linear /dev/loop0 8192
add map loop0p2 (252:9): 0 5763072 linear /dev/loop0 122880
# sudo mount /dev/mapper/loop0p2 /mnt/temp# sudo mount -o bind /dev /mnt/temp/dev
# sudo mount -o bind /proc /mnt/temp/proc
# sudo mount -o bind /sys /mnt/temp/sys

Don’t forget to copy the qemu-arm binary to the image
# sudo cp /usr/bin/qemu-arm /mnt/temp/usr/bin

# cat /usr/share/binfmts/qemu-arm
package qemu-user-static
interpreter /usr/bin/qemu-arm-static
credentials yes
offset 0
magic x7fELFx01x01x01x00x00x00x00x00x00x00x00x00x02x00x28x00
mask xffxffxffxffxffxffxffx00xffxffxffxffxffxffxffxffxfexffxffxff

Run sudo update-binfmts --import qemu-arm two times (yes, two times)
And we are good to go

Now, you should be able to chroot
# sudo chroot /mnt/temp

Let’s check if it’s working
# uname -a
Linux localhost 2.6.32 #58-Ubuntu SMP Thu Jan 24 15:28:10 UTC 2013 armv7l GNU/Linux

Contenu connexe

Tendances

Asus WL500gP USB Serial
Asus WL500gP USB SerialAsus WL500gP USB Serial
Asus WL500gP USB Serial
guestac21b8
 
Androidx86 Installation For Virtualbox
Androidx86 Installation For VirtualboxAndroidx86 Installation For Virtualbox
Androidx86 Installation For Virtualbox
PingLun Liao
 
1. openvpn simple
1. openvpn simple1. openvpn simple
1. openvpn simple
khanh02l1
 

Tendances (20)

Multi-GPU MapReduce on GPU Clusters
Multi-GPU MapReduce on GPU ClustersMulti-GPU MapReduce on GPU Clusters
Multi-GPU MapReduce on GPU Clusters
 
NetBSD on Google Compute Engine (en)
NetBSD on Google Compute Engine (en)NetBSD on Google Compute Engine (en)
NetBSD on Google Compute Engine (en)
 
My First BCC
My First BCCMy First BCC
My First BCC
 
Kvm optimizations
Kvm optimizationsKvm optimizations
Kvm optimizations
 
SiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingSiteGround Tech TeamBuilding
SiteGround Tech TeamBuilding
 
Control-M 800 - Infrastructure Example
Control-M 800 - Infrastructure ExampleControl-M 800 - Infrastructure Example
Control-M 800 - Infrastructure Example
 
Asus WL500gP USB Serial
Asus WL500gP USB SerialAsus WL500gP USB Serial
Asus WL500gP USB Serial
 
Trivadis TechEvent 2016 cgroups im Einsatz von Florian Feicht
Trivadis TechEvent 2016 cgroups im Einsatz von Florian FeichtTrivadis TechEvent 2016 cgroups im Einsatz von Florian Feicht
Trivadis TechEvent 2016 cgroups im Einsatz von Florian Feicht
 
Linux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System RescueLinux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System Rescue
 
Nvprof um 1
Nvprof um 1Nvprof um 1
Nvprof um 1
 
coreboot@Budapest 10.2009 Meetup
coreboot@Budapest 10.2009 Meetupcoreboot@Budapest 10.2009 Meetup
coreboot@Budapest 10.2009 Meetup
 
Androidx86 Installation For Virtualbox
Androidx86 Installation For VirtualboxAndroidx86 Installation For Virtualbox
Androidx86 Installation For Virtualbox
 
DataStax: 7 Deadly Sins for Cassandra Ops
DataStax: 7 Deadly Sins for Cassandra OpsDataStax: 7 Deadly Sins for Cassandra Ops
DataStax: 7 Deadly Sins for Cassandra Ops
 
1. openvpn simple
1. openvpn simple1. openvpn simple
1. openvpn simple
 
Troubleshooting linux booting process
Troubleshooting linux booting processTroubleshooting linux booting process
Troubleshooting linux booting process
 
redis-benchmark with AMD RYZEN 1800X memo
redis-benchmark with AMD RYZEN 1800X memoredis-benchmark with AMD RYZEN 1800X memo
redis-benchmark with AMD RYZEN 1800X memo
 
Linux: Hardware Settings
Linux: Hardware SettingsLinux: Hardware Settings
Linux: Hardware Settings
 
testing-nfs
testing-nfstesting-nfs
testing-nfs
 
Comparison of-foss-distributed-storage
Comparison of-foss-distributed-storageComparison of-foss-distributed-storage
Comparison of-foss-distributed-storage
 
Nvvp streams-2
Nvvp streams-2Nvvp streams-2
Nvvp streams-2
 

Similaire à Qemu - Raspberry | while42 Singapore #2

Cacti安装手册
Cacti安装手册Cacti安装手册
Cacti安装手册
Yiwei Ma
 

Similaire à Qemu - Raspberry | while42 Singapore #2 (20)

3. configuring a compute node for nfv
3. configuring a compute node for nfv3. configuring a compute node for nfv
3. configuring a compute node for nfv
 
Raspberry Pi tutorial
Raspberry Pi tutorialRaspberry Pi tutorial
Raspberry Pi tutorial
 
Linux Containers From Scratch
Linux Containers From ScratchLinux Containers From Scratch
Linux Containers From Scratch
 
Kernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysisKernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysis
 
x86_64 Hardware Deep dive
x86_64 Hardware Deep divex86_64 Hardware Deep dive
x86_64 Hardware Deep dive
 
Qt native built for raspberry zero
Qt native built for  raspberry zeroQt native built for  raspberry zero
Qt native built for raspberry zero
 
Cacti安装手册
Cacti安装手册Cacti安装手册
Cacti安装手册
 
9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training
 
NFD9 - Matt Peterson, Data Center Operations
NFD9 - Matt Peterson, Data Center OperationsNFD9 - Matt Peterson, Data Center Operations
NFD9 - Matt Peterson, Data Center Operations
 
MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
Linux Tracing Superpowers by Eugene Pirogov
Linux Tracing Superpowers by Eugene PirogovLinux Tracing Superpowers by Eugene Pirogov
Linux Tracing Superpowers by Eugene Pirogov
 
CloudStack hands-on workshop @ DevOpsDays Amsterdam 2015
CloudStack hands-on workshop @ DevOpsDays Amsterdam 2015CloudStack hands-on workshop @ DevOpsDays Amsterdam 2015
CloudStack hands-on workshop @ DevOpsDays Amsterdam 2015
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22
 
Dev ops
Dev opsDev ops
Dev ops
 
Linux Crash Dump Capture and Analysis
Linux Crash Dump Capture and AnalysisLinux Crash Dump Capture and Analysis
Linux Crash Dump Capture and Analysis
 
How to Burn Multi-GPUs using CUDA stress test memo
How to Burn Multi-GPUs using CUDA stress test memoHow to Burn Multi-GPUs using CUDA stress test memo
How to Burn Multi-GPUs using CUDA stress test memo
 
Docker practice
Docker practiceDocker practice
Docker practice
 
NetBSD workshop
NetBSD workshopNetBSD workshop
NetBSD workshop
 
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
 

Plus de While42

Singapore chapitre #4 - You don't know
Singapore chapitre #4 - You don't knowSingapore chapitre #4 - You don't know
Singapore chapitre #4 - You don't know
While42
 

Plus de While42 (15)

2 membres de while42 dans Programmez!
2 membres de while42 dans Programmez!2 membres de while42 dans Programmez!
2 membres de while42 dans Programmez!
 
while42 Marseille #1
while42 Marseille #1while42 Marseille #1
while42 Marseille #1
 
The Immigration reform
The Immigration reformThe Immigration reform
The Immigration reform
 
42 (school) at 2 years of while42
42 (school) at 2 years of while4242 (school) at 2 years of while42
42 (school) at 2 years of while42
 
La Silicon Valley vue par Camille Despringhere
La Silicon Valley vue par Camille DespringhereLa Silicon Valley vue par Camille Despringhere
La Silicon Valley vue par Camille Despringhere
 
Singapore chapitre #4 - You don't know
Singapore chapitre #4 - You don't knowSingapore chapitre #4 - You don't know
Singapore chapitre #4 - You don't know
 
Singapore chapitre #4 - Presentation
Singapore chapitre #4 - PresentationSingapore chapitre #4 - Presentation
Singapore chapitre #4 - Presentation
 
while42 mentionné dans la version papier du quotidien "Le Monde"
while42 mentionné dans la version papier du quotidien "Le Monde"while42 mentionné dans la version papier du quotidien "Le Monde"
while42 mentionné dans la version papier du quotidien "Le Monde"
 
Javascript sucks & frontend challenges @ClearSlide | while42 SF #7
Javascript sucks & frontend challenges @ClearSlide | while42 SF #7Javascript sucks & frontend challenges @ClearSlide | while42 SF #7
Javascript sucks & frontend challenges @ClearSlide | while42 SF #7
 
While42 SF presentation | w42 #7 at ClearSlide
While42 SF presentation | w42 #7 at ClearSlideWhile42 SF presentation | w42 #7 at ClearSlide
While42 SF presentation | w42 #7 at ClearSlide
 
while42 Montreal #0 @ wajam
while42 Montreal #0 @ wajamwhile42 Montreal #0 @ wajam
while42 Montreal #0 @ wajam
 
Bugs from Outer Space | while42 SF #6
Bugs from Outer Space | while42 SF #6Bugs from Outer Space | while42 SF #6
Bugs from Outer Space | while42 SF #6
 
While42 SF #6: introducing while42 to Girls in Tech and Kwarter
While42 SF #6: introducing while42 to Girls in Tech and KwarterWhile42 SF #6: introducing while42 to Girls in Tech and Kwarter
While42 SF #6: introducing while42 to Girls in Tech and Kwarter
 
While42 Paris #1 - Presentation de while42
While42 Paris #1 - Presentation de while42While42 Paris #1 - Presentation de while42
While42 Paris #1 - Presentation de while42
 
Hack le droid
Hack le droidHack le droid
Hack le droid
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Qemu - Raspberry | while42 Singapore #2

  • 2.
  • 3. QEMU is a hosted virtual machine monitor: It emulates central processing units through dynamic binary translation and provides a set of device models, enabling it to run a variety of unmodified guest operating systems.
  • 5. A chroot on Unix operating systems is an operation that changes the apparent root directory for the current running process and its children.
  • 7. The Raspberry Pi has a Broadcom BCM2835 system on a chip (SoC),[3] which includes an ARM1176JZF-S 700 MHz processor
  • 9. What about speed? pi@raspberrypi:~$ cat /proc/cpuinfo | grep MIPS BogoMIPS : 697.95 pi@raspberrypi:~$ cat /proc/cpuinfo | grep MIPS BogoMIPS Not good! : 565.24
  • 10. Qemu compilation ARM1176JZF-S # # # # git clone http://git.qemu.org/git/qemu.git ./configure --target-list="arm-softmmu arm-linux-user" --enable-sdl --static make sudo make install
  • 11. Preparation ● ● Download the latest version of Raspbian (link) Download the linux kernel for Qemu (link) # qemu-system -kernel kernel-qemu -cpu arm1176 -M versatilepb -no-reboot -append "root=/dev/sda2 panic=0 ro single" -hda XXXXX-raspbian.img # mount / -o remount,rw ● ● Edit fstab and change mmcblk0p1 and mmcblk0p2 to sda1 and sda2 respectively Create /etc/udev/rules.d/90-qemu.rules KERNEL=="sda", SYMLINK+="mmcblk0" KERNEL=="sda?", SYMLINK+="mmcblk0p%n", ● Comment everything in /etc/ld.so.preload
  • 12. Enlarge it! # cp XXXXX-raspbian.img raspbian.img # qemu-img resize raspbian.img +6G # qemu-system -kernel kernel-qemu -cpu arm1176 -M versatilepb -no-reboot -append "root=/dev/sda2 panic=1" -hda XXXXX-raspbian.img -hdb raspbian.img # sudo cfdisk /dev/sdb ●Delete the second partition and create a new partition with all space # sudo resize2fs /dev/sdb2 # sudo fsck -f /dev/sdb2 # sudo halt # qemu-system -kernel kernel-qemu -cpu arm1176 -M versatilepb -no-reboot -append "root=/dev/sda2 panic=1" -hda raspbian.img
  • 13. Chroot it # sudo kpartx -a -v 2012-12-16-wheezy-raspbian.img add map loop0p1 (252:8): 0 114688 linear /dev/loop0 8192 add map loop0p2 (252:9): 0 5763072 linear /dev/loop0 122880 # sudo mount /dev/mapper/loop0p2 /mnt/temp# sudo mount -o bind /dev /mnt/temp/dev # sudo mount -o bind /proc /mnt/temp/proc # sudo mount -o bind /sys /mnt/temp/sys Don’t forget to copy the qemu-arm binary to the image # sudo cp /usr/bin/qemu-arm /mnt/temp/usr/bin # cat /usr/share/binfmts/qemu-arm package qemu-user-static interpreter /usr/bin/qemu-arm-static credentials yes offset 0 magic x7fELFx01x01x01x00x00x00x00x00x00x00x00x00x02x00x28x00 mask xffxffxffxffxffxffxffx00xffxffxffxffxffxffxffxffxfexffxffxff Run sudo update-binfmts --import qemu-arm two times (yes, two times)
  • 14. And we are good to go Now, you should be able to chroot # sudo chroot /mnt/temp Let’s check if it’s working # uname -a Linux localhost 2.6.32 #58-Ubuntu SMP Thu Jan 24 15:28:10 UTC 2013 armv7l GNU/Linux