Development:Setting up RootFS

From FEX-Emu Wiki
Revision as of 06:04, 17 March 2021 by Sonicadvance1 (talk | contribs) (Created page with "= Setting up a RootFS = '''For AArch64 hosts you are required to have an x86-64 rootfs'''. With or without 32bit compatibility libraries. This isn't strictly required for tes...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Setting up a RootFS

For AArch64 hosts you are required to have an x86-64 rootfs. With or without 32bit compatibility libraries.

This isn't strictly required for testing on x86-64 host environments but is useful for ensuring correct behaviour there.

Prereqs

An x86-64 PC OR qemu for chrooting

Getting Started

The easiest way to get started is to just download a prebuilt x86-64 rootfs from your favourite distribution and extract it to where you want.

Using chroot you can then enter the rootfs and install applications that you desire for testing purposes

Cross architecture chroot

If you don't have binfmt_misc setup to run x86/x86-64 binaries on your AArch64 host, then you need to install and copy over qemu-static to the rootfs.

  • sudo apt-get install qemu-user-static
  • cp /usr/bin/qemu-x86_64-static ${ROOTFS}/usr/bin/
  • sudo chroot ubuntu_rootfs qemu-x86_64-static /bin/bash

Additional TmpFS folders

Depending on what you're doing in the chroot, you may need or want some tmpfs folders that applications are expecting

  • sudo mount -t proc /proc ${ROOTFS}/proc/
  • sudo mount --rbind --make-rslave /sys ${ROOTFS}/sys/
  • sudo mount --rbind --make-rslave /dev ${ROOTFS}/dev/

You may or may not need another /dev/pts location as as well

  • sudo mount --rbind --make-rslave /dev/pts ${ROOTFS}/dev/pts/

Then of course, make sure to unmount these partitions when you're done

  • sudo umount ${ROOTFS}/proc/
  • sudo umount -R ${ROOTFS}/sys/
  • sudo umount -R ${ROOTFS}/dev/
  • sudo umount -R ${ROOTFS}/dev/pts/

Additional Steps

Running under WSL1

/etc/hosts and /etc/resolv.conf change on the host side. You'll need to copy those over to the rootfs if you want network functionality to work.

Ubuntu rootfs bad ld link

Ubuntu has a link at /lib64/x86_64-linux-gnu/ld-linux-x86-64.so.2 that is an absolute path link to /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2. This link needs to be changed to a relative link to the ld-linux-x86-64.so.2 link in the same /lib64 directory

  • cd ${ROOTFS}
  • ln -s -f ../../usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 lib64/

Ubuntu packages to install

Sample packages to install in the rootfs

  • apt-get install pulseaudio libgles1 libgles2 libglx-mesa0 libgl1-mesa-dri libgl1-mesa-glx mesa-utils mesa-utils-extra

Pulseaudio specifically is required so pulseaudio will work when talking to the host pulseaudio