Skip to content

Commit b6830ca

Browse files
committed
resources: Update documentation for building base disk images
1 parent f26c38b commit b6830ca

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

src/ubuntu-generic-diskimages/BUILDING.md

+32-13
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ This document provides instructions for creating the **x86-ubuntu** and **arm-ub
1515

1616
After building the Dockerfile, you can retrieve the kernel and modules on your host using the `copy_modules_to_host.sh` script.
1717
- **`scripts/`**: Contains scripts that run on the disk image after installation.
18-
- **`disable-network.sh`**: Disables networking by renaming the Netplan configuration file (`.yaml``.yaml.bak`) and disabling network services in systemd.
18+
- **`disable-network.sh`**: Disables networking by renaming the Netplan configuration file (`.yaml``.yaml.bak`) and disabling network services in systemd. Disabling network decreases boot time by removing the 2 minute wait for network service to get online in systemd.
1919
- **`disable-systemd-services-x86.sh`**: Disables non-essential systemd services for x86 disk images to reduce boot time in gem5 simulations.
2020
- **`extract-x86-kernel.sh`**: Extracts the kernel from the x86 disk image and moves it to `/home/gem5`. Packer then copies the extracted kernel from the disk image to the host.
2121
- **`increase-system-entropy-for-arm-disk.sh`**: Uses `haveged` to increase system entropy for ARM disk images, reducing boot delays caused by low entropy.
2222
- **`install-common-packages.sh`**: Installs necessary packages common to all disk images.
23-
- **`install-gem5-bridge.sh`**: Clones and builds `gem5-bridge`, allowing the disk image to use `m5ops` commands.
23+
- **`install-gem5-bridge.sh`**: Clones and builds `gem5-bridge`, allowing the disk image to use `m5ops` commands. For more information about using `m5ops` you can take a look at <https://bootcamp.gem5.org/#02-Using-gem5/03-running-in-gem5>.
2424
- **`install-user-benchmarks.sh`**: User-editable script for installing custom benchmarks.
2525
- **`install-user-packages.sh`**: User-editable script for installing additional packages beyond those in `install-common-packages.sh`.
26-
- **`update-gem5-init.sh`**: Updates the `init` file with `gem5_init.sh` from the `files` directory.
26+
- **`update-gem5-init.sh`**: Updates the `init` file with `gem5_init.sh` from the `files` directory. The `gem5_init.sh` script updates the `init` script that is run when ubuntu boots to include the `no_systemd` kernel arg, initialize the `gem5-bridge` driver and call an exit event indicating that the kernel has booted.
2727
- **`update-modules-arm-22.04.sh`**: Installs kernel modules built via the Dockerfile in `kernel-and-modules/arm-ubuntu-22.04` for the ARM 22.04 disk image.
2828
- **`update-modules-arm-24.04.sh`**: Installs kernel modules built via the Dockerfile in `kernel-and-modules/arm-ubuntu-24.04` for the ARM 24.04 disk image.
2929

@@ -66,22 +66,20 @@ Since the ARM disk image requires the `gem5-bridge` module to enable running `ge
6666
3. **Verify the Output Directory**
6767
After running the script, a directory named **`my-arm-<kernel_version>-kernel`** will be created in the `kernel-and-modules` directory. This directory contains:
6868

69-
- `vmlinux`: The built kernel (**used in gem5 simulations but not copied to the disk**).
69+
- `vmlinux`: The built kernel (**used in gem5 simulations but not copied onto the built disk image**).
7070
- A subdirectory containing all kernel modules, including `gem5-bridge`.
7171

7272
### **Generating the EFI Boot File**
7373

74-
The ARM disk image requires an **EFI file** to boot in qemu. This is provided as `flash0.img` in the Packer configuration.
74+
The ARM disk image requires an **EFI file** to boot in qemu. Running `build-arm.sh` automatically generates this file.This is provided as `flash0.img` in the Packer configuration.
7575

76-
To generate `flash0.img`, run the following commands in the `files/` directory:
76+
To generate `flash0.img` manually, run the following commands in the `files/` directory:
7777

7878
```bash
7979
dd if=/dev/zero of=flash0.img bs=1M count=64
8080
dd if=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd of=flash0.img conv=notrunc
8181
```
8282

83-
**Note:** Running `build-arm.sh` automatically generates this file.
84-
8583
## Building the Disk Image
8684

8785
- **For x86**:
@@ -91,9 +89,23 @@ dd if=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd of=flash0.img conv=notrunc
9189
Run `build-arm.sh` with `22.04` or `24.04` to build the respective ARM disk image in `ubuntu-generic-diskimages`.
9290

9391
**ARM Build Assumption**:
94-
The build assumes execution on an **ARM machine**, as it uses KVM for virtualization. If running on a non-ARM host, update `build-arm.sh` by setting `"use_kvm=false"` in the `./packer build` command.
92+
The build assumes execution on an **ARM machine**, as it uses KVM for virtualization. If running on a non-ARM host, update `build-arm.sh` by setting `"use_kvm=false"` in the `./packer build` command:
93+
94+
```bash
95+
./packer build -var "use_kvm=false" -var "ubuntu_version=${ubuntu_version}" ./packer-scripts/arm-ubuntu.pkr.hcl
96+
```
97+
98+
You would also need to update the isa of the packer binary being downloaded in the `build-arm.sh` file. To download the `amd64` packer binary you can update the section that downloads the packer binary in `build-arm.sh` file to the following:
9599

96-
This script downloads the Packer binary, initializes Packer, and builds the disk image.
100+
```bash
101+
if [ ! -f ./packer ]; then
102+
wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip;
103+
unzip packer_${PACKER_VERSION}_linux_amd64.zip;
104+
rm packer_${PACKER_VERSION}_linux_amd64.zip;
105+
fi
106+
```
107+
108+
The `build-arm.sh` script downloads the Packer binary, initializes Packer, and builds the disk image.
97109

98110
## Kernel Extraction (x86 Only)
99111

@@ -125,6 +137,7 @@ This kernel can be used as a resource for **gem5 simulations** and is not restri
125137
- **gem5-Bridge (`m5`)**:
126138
- Installed at `/usr/local/bin/gem5-bridge` with a symlink to `m5` for compatibility.
127139
- `libm5` is installed in `/usr/local/lib/`, and headers are placed in `/usr/local/include/m5`.
140+
- Add more packages by modifying `scripts/install-user-packages.sh`. Install benchmarks onto the base disk image by modifying `scripts/install-user-benchmarks.sh`.
128141

129142
## Extending the Disk Image
130143

@@ -138,15 +151,15 @@ This kernel can be used as a resource for **gem5 simulations** and is not restri
138151
}
139152
```
140153

141-
If you need to increase the size of the image when adding more libraries and files to the image update the size of the partition in the respective `http/*/user-data` file. Also, update the `disk_size` parameter in `post-installation.sh` to be at least one mega byte more than the size you defined in the `user-data` file.
154+
If you need to increase the size of the image when adding more libraries and files to the image update the size of the partition in the respective `http/*/user-data` file. Also, update the `disk_size` parameter in the packer file to be at least one mega byte more than the size you defined in the `user-data` file.
142155

143-
**NOTE:** You can extend this disk image by modifying the `post-installation.sh` script, but it requires building the image from scratch.
156+
**NOTE:** You can extend this disk image by modifying the `install-user-benchmarks` and `install-user-packages.sh` script, but it requires building the image from scratch.
144157

145158
To take a pre-built image and add new files or packages, take a look at the following [documentation](https://www.gem5.org/documentation/gem5-stdlib/extending-disk-images).
146159

147160
## Troubleshooting
148161

149-
- **Enable Packer Logs**:
162+
- **Enable Packer Logs**: This causes Packer to print additional debug messages.
150163

151164
```sh
152165
PACKER_LOG=INFO ./build.sh
@@ -158,6 +171,12 @@ To take a pre-built image and add new files or packages, take a look at the foll
158171

159172
- **Monitor Installation**:
160173
- Use a **VNC viewer** to watch installation. The port is displayed in the terminal.
174+
The output may appear as follows:
175+
176+
```bash
177+
==> qemu.initialize: Waiting 10s for boot...
178+
==> qemu.initialize: Connecting to VM via VNC (127.0.0.1:5995)
179+
```
161180

162181
For further details, refer to:
163182
[Ubuntu Autoinstall Documentation](https://ubuntu.com/server/docs/install/autoinstall).

0 commit comments

Comments
 (0)