This document explains how to set up the required files for full system (FS) simulation on gem5. All the required files are either included in the repository or have direct download links.
Full system simulation requires two files: a Linux kernel binary and a disk image.
This repository already contains the kernel binary for version 5.4.46 which can be uses as-is. To compile the binary from scratch:
- Download and extract the source from here.
- Install the requirements by running
sudo apt install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison
- Copy
config-5.4.46
from this repository to the kernel source directory as.config.
- Run make.
After compilation, the generated vmlinux
binary is the kernel binary.
For the disk image, we will build on the linux-2.6.22.9 disk image referenced in gem5's old documentation. We will replace the image's contents with a modern Ubuntu Base distribution.
- Create a disk image by running
util/gem5img.py init linux-x86.img 4096
- Mount the disk image (linux-x86.img) by running
sudo mount -o loop,offset=32256 linux-x86.img <mount directory>
- Clear the contents of the mounted image.
- Download Ubuntu Base 20.04 files from here.
- Extract the distribution files into the image by running
tar -xvzf ubuntu-base-20.04.1-base-amd64.tar.gz -C <mount directory>
. - Copy the following files from
disk_files
in this repository to respective destinations in the image
File | Destination |
---|---|
fstab | etc/fstab |
init | bin/init |
m5 | sbin/m5 |
- Unmount the image.
At this point, the image is ready for use. The following subsections explain steps for installing additional packages using apt.
- Mount the image to a directory
- Run
sudo mount -o bind /sys <mount directory>/sys
sudo mount -o bind /dev <mount directory>/dev
sudo mount -o bind /proc <mount directory>/proc
sudo chroot <mount directory> /bin/bash
echo "nameserver 8.8.8.8" | tee /etc/resolv.conf > /dev/null
-
You can now use the
apt
to install packages just like you normally would. Two suggested packages aresoftware-properties-common
(commonly used libraries and interpreters) andkmod
(modprobe). -
After you're done, run the following and then unmount the image.
sudo umount <mount directory>/sys
sudo umount <mount directory>/proc
sudo umount <mount directory>/dev