This is a guide on how to run x86 on ARM including wine! I have put a lot of time and effort into creating this guide along with breaking down a few older tutorials to give you guys a up to date guide on running x86 on arm (i.e raspberry pi or tinkerboard). Hope you guys appreciate this and thanks for the view!!
Equipment List
Raspberry Pi 3 ► Amazon | Ebay
Software List
Raspbian Pixel ► https://www.raspberrypi.org/downloads/
Balena Etcher ► https://www.balena.io/etcher/
POL Wine Binary ► https://www.playonlinux.com/wine/binaries/linux-x86/
Reference List
these are the references i followed
https://github.com/mikerr/RPi-QEMU-x86-wine
https://sourceforge.net/projects/pi-qemu-wine/
https://www.raspberrypi.org/forums/viewtopic.php?t=204547
https://github.com/AlbrechtL/RPi-QEMU-x86-wine
https://forum.winehq.org/viewtopic.php?f=8&t=17701&start=25#p84325
x86 on ARM (i.e. Raspberry Pi)
Step 1: Install Raspbian Pixel
First you will need to download Raspbian Pixel Desktop version.
Now we will need a piece of software called etcher to write the image onto our SD card and USB Storage device.
Step 2: Check for updates
It is always a good idea to check for updates even if it is a freshly installed OS.
$ sudo apt-get update
$ sudo apt-get upgrade
Step 2a: Compiling Kernel (needed for wine to work)
This next step is required for Wine to work under chroot and arm environment. Since Wine comes pre-compiled with support only for 3G/1G vmsplit we will need to compile our kernel to be compatible, this is only the case if your kernel is not compiled with 3G/1G. Raspberry pi come pre-compiled with 2G/2G vmsplit
Follow this guide from official raspberry pi to compile your raspberry pi kernel. (if you are not using raspberry pi, you will need to find the steps to compiling and installing there kernel)
https://www.raspberrypi.org/documentation/linux/kernel/building.md
you will need to modify the .config after the
make bcm2709_defconfig
by commenting out the
# VMSPLIT_2G=y
and remove the comment block from
# VMSPLIT_3G=y
there might be some cases (ie tinkerboard) where you will need to enable binfmt_misc so check for that as well in the .config
Step 3: Downloading Prerequisites
Open up a terminal and type
$ sudo apt-get update && apt-get install qemu qemu-user qemu-user-static binfmt-support debootstrap binutils
this should only take a few mins, once done extract the source codes with this command
Step 4: Debootstrap
We are now going to download Debian x86 environment using debootstrap and separating into two stages with this command
$ sudo debootstrap --foreign --arch i386 stretch ./chroot-stretch-i386 http://ftp.us.debian.org/debian
this should only take about 5 or so mins. then on to mounting. if you didn’t deviate from the current directory of /home/pi/ then next command is as follows
$ sudo mount -t sysfs sys ./chroot-stretch-i386/sys/
$ sudo mount -t proc proc ./chroot-stretch-i386/proc/
$ sudo mount --bind /dev ./chroot-stretch-i386/dev/
$ sudo mount --bind /dev/pts ./chroot-stretch-i386/dev/pts/
$ sudo mount --bind /dev/shm ./chroot-stretch-i386/dev/shm/
This is how the magic works…. we need to copy qemu-i386-static over to the bin folder
$ sudo cp /usr/bin/qemu-i386-static ./chroot-stretch-i386/usr/bin/
we should now be ready for stage 2 of debootstrap. this will take awhile (59min~ on pi3b+)
$ sudo chroot ./chroot-stretch-i386/ /debootstrap/debootstrap --second-stage
one that is completed we should have a freshly installed x86 debian working.
Step 5: Configuring Chroot
with our freshly created debian x86 chroot system. we will now need to test it and configure a user account
$ sudo chroot /home/pi/chroot-stretch-i386/ /bin/su -l root
we might need to setup some variables (needed for p) and would be wise to insert this to the bottom of the .bashrc file so we don’t need to type it in every time we launch our chroot root user
export LANGUAGE=”C”
export LC_ALL=”C”
export DISPLAY=:0
if you added the lines to the .bashrc file you will need to refresh it by using source
$ source ~/.bashrc
lets go ahead update the x86 debian
$ apt update
now we can create a user, in my video i have used the same user as the system user which requires us to know the uid of that user by typing in “id” in the terminal (not x86 terminal), and in our case the “pi” uid is “1000”
$ adduser -uid 1000 pi
follow the prompts and continue
before we exit root i would like to install a x86 gui application, this way it will install the requirements to run gui. so i went with something like “leafpad”
$ apt install leafpad
notice how large the installation compaired to a standard leafpad install.
with that done. we can now test our newly created user account (pi). You can either start up a new lxterminal or exit the current root terminal and use this command.
$ sudo chroot /home/pi/chroot-stretch-i386/ /bin/su -l pi
we will need to do the same as the root user and add some varibles to the .bashrc file
export LANGUAGE=”C”
export LC_ALL=”C”
export DISPLAY=:0l
$ source ~/.bashrc
if everything went well we should have no problems running “leafpad”
$ leafpad
Step 6: Setting up WINE
If you are not planning to use wine you can skip this step completely and move on to the next.
We will first need to download a precompiled binary version of wine from Play on linux. head over to there site and look for the latest version of wine, in my case the making of this video/tutorial the latest version i have found is 3.9.
using the root account of x86
$ sudo chroot /home/pi/chroot-stretch-i386/ /bin/su -l root
we can now download the wine binaries
wget https://www.playonlinux.com/wine/binaries/linux-x86/PlayOnLinux-wine-3.9-linux-x86.pol
in my case i forgot i needed bzip2 so we need to go ahead and install that as well
apt install bzip2
lets extract our wine binaries and move them over to the “/opt”
tar -jxf PlayOnLinux-wine-3.9-linux-x86.pol --strip-components=1
we need to now rename a file for wine to run correctly
mv ./3.9/bin/wine-preloader ./3.9/bin/wine-preloader.renamed
now we can move the wine folder to “/opt” and rename the folder to wine-3.9
mv ./3.9 /opt/wine-3.9/
lets export some paths so we can reach wine.
echo PATH=/opt/wine-3.9/bin/:$PATH >> ~/.bashrc
lets refresh our .bashrc file again
source ./.bashrc
since root is not able to use the exported display (“export DISPLAY=:0”) we will need to login to the user account to test wine
$ sudo chroot /home/pi/chroot-stretch-i386/ /bin/su -l pi
we now need to export the path in the pi user account as well
echo PATH=/opt/wine-3.9/bin/:$PATH >> ~/.bashrc
lets refresh our .bashrc file again
source ./.bashrc
with that all completed we can now test wine.
winecfg
at this rate you should be able to see winecfg pop up
i have an modified version of winetricks working for our x86 debian environment
http://github.com/novaspirit/winetricks
Step 7: Finalizing configs
now that we have everything tested and working lets clean stuff up and create startup services so we don’t have to keep mounting our partitions everytime we need to use chroot x86
I started by creating a fold called “/opt/chrootscript”
$ sudo mkdir /opt/chrootscript/
now in there i’m going to make our first script “chrootmount”
$ sudo nano /opt/chrootscript/chrootmount
and input the following
#!/bin/bash
mount -t sysfs sys /tmp/mnt/sys/
mount -t proc proc /tmp/mnt/proc/
mount –bind /dev /tmp/mnt/dev/
mount –bind /dev/pts /tmp/mnt/dev/pts/
mount –bind /dev/shm /tmp/mnt/dev/shm/
now we can create a service for that script so it will boot up everytime
sudo nano /etc/systemd/system/chrootmount.service
in there we need to add some properties
[Unit]
Description = mounts chroot on boot
[Service]
Type=one-shot
ExecStart=/usr/bin/chrootmount
[Install]
WantedBy=multi-user.target
we can now enable the service with this command
$ sudo systemctl enable chrootmount.service
with that in place we can make 2 scripts to start our x86 environment, one for user and one for root
$ sudo nano /opt/chrootscript/start_x86_user
input the following
#!/bin/sh
/usr/sbin/chroot /home/pi/chroot-stretch-i386/ /bin/su -l pi
and
$ sudo nano /opt/chrootscript/start_x86_root
input the following
#!/bin/sh
/usr/sbin/chroot /home/pi/chroot-stretch-i386/ /bin/su -l root
now we can generate some desktop shortcuts by right clicking on the desktop and selecting New > empty file and name it “chroot_user.desktop”
input the following
[Desktop Entry]
Type=Application
Comment=Start Wine x86 Environment
Name=Wine x86 User
Exec=lxterminal -e sudo /opt/chrootscript/start_x86_user
Icon=
Terminal=false
Categories=Utility
StartupNotify=True
and do the same for root. right click desktop and select New > empty file and name it “chroot_root.desktop”
input the following
[Desktop Entry]
Type=Application
Comment=Start Wine x86 Environment
Name=Wine x86 Root
Exec=lxterminal -e sudo /opt/chrootscript/start_x86_root
Icon=
Terminal=false
Categories=Utility
StartupNotify=True
whew!!!!! that was a lot! but now you should be all set to go in your x86 ventures.
View Comments (72)
Hello, could you share IMAGE OS with us ?
You don’t need them to supply you a image. Just search up ‘latest stretch image Raspbian’ and there should be a couple downloads archives.
Hi,
On step 3, you mention extracting source with this command, but there doesn't seem to be a command!
"STEP 3: DOWNLOADING PREREQUISITES
Open up a terminal and type
$ sudo apt-get update && apt-get install qemu qemu-user qemu-user-static binfmt-support debootstrap binutils</code
this should only take a few mins, once done extract the source codes with this command"
What would the command be?
(seems to be a small html formatting error too!)
eastcoastcutting.com Hey Look what we have an eye to you! a goodoblation
Are you in?
https://drive.google.com/file/d/1pCuKiocQSClWvnwh6SYV9WPIr5f1J-xs/preview
Look at an important promotion for winning. eastcoastcutting.com
http://bit.ly/2KBDMTV
Look at an fab cash rare against your team. eastcoastcutting.com
http://bit.ly/2NMz0WV
On the command " sudo chroot ./chroot-stretch-i386/ /debootstrap/debootstrap --second-stage"
I'm getting this error:
chroot: failed to run command «/debootstrap/debootstrap»: Exec format error
Can you help me.
Thanks,
João Martins
I had this error, but a reboot made it work for me.
Hey! Nice tutorial.
It works so far but when I try to run any GUI-App. I get "Cannot open Display"...
What can I do about it?
Thank you very much!
Write this command in normal user(no chroot)
echo $DISPLAY
and change display in chroot
I must change to:
export DISPLAY=:10.0
i got this error :
root@raspberrypi:~# export LC_ALL=”C”
bash: warning: setlocale: LC_ALL: cannot change locale (”C”)
on step 5 :-/
i am usin a raspberrypi 4b 2gb ram. any help pls ???? :(
I'm getting the same error!
Hi Don,
thank you so much for this great tutorial!
Since i updated my OS on the RPi3b to raspbian buster, I'd like to update my chroot environment to buster as well. As you mentioned in the video it is possible to use any other distro. I adapted your code as shown below:
sudo debootstrap --foreign --arch i386 buster ./chroot-buster-i386 http://ftp.us.debian.org/debian
sudo mount -t sysfs sys ./chroot-buster-i386/sys/
sudo mount -t proc proc ./chroot-buster-i386/proc/
sudo mount --bind /dev ./chroot-buster-i386/dev/
sudo mount --bind /dev/pts ./chroot-buster-i386/dev/pts/
sudo mount --bind /dev/shm ./chroot-buster-i386/dev/shm/
sudo cp /usr/bin/qemu-i386-static ./chroot-buster-i386/usr/bin/
sudo chroot ./chroot-buster-i386/ /debootstrap/debootstrap --second-stage
After that command I receive an error message:
W: Failure trying to run: /sbin/ldconfig
W: See //debootstrap/debootstrap.log for details
I checked the debootstrap/debootstrap.log:
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault
Is this an error related to qemu, debootstrap or raspbian? And is there a way to get this working?
Thank you,
Andi
Same here. If anyone finds a solution, that would be neat
Same issue here. Only with Buster, Stretch works fine.
Also experiencing this issue.
Same here on a Zero.
Can you help me?
pi@pi:~$ winecfg
Bus error
I have the same.
Pi 4b, Built Raspbian from source on 15/08. Managed to build everything and get leafpad x86 running. But wine gives "Bus error". Tried wine-3.9 and wine-3.20.
Exactly the same problem as Levi (Bus error when trying to launch 'wine').
has anyone been able to solve this? afaik reverting the os stretch of not an option as rpi4 needs buster?
someone also posted bus error with stretch as well..
the buss error for RPI4,s seams to come from the older and slightly buggy qemu-i386-static file included in the raspbian repository. It cleared up once I downloaded it and copied it into the the correct folder I downloaded it from here https://github.com/multiarch/qemu-user-static/releases/
Whats the correct folder???
Get the same error. RPi4b with 4 GB.