From Fedora Project Wiki
No edit summary
Line 81: Line 81:
= Disk image is too large/too small =
= Disk image is too large/too small =


The disk image has a large <b>virtual</b> size.  It is shipped as a [https://en.wikipedia.org/wiki/Sparse_file sparse file] so it will only use a small fraction of this space on the host.  Make sure you use commands and filesystems which preserve sparseness, such as <code>tar</code>, <code>xz</code>, <code>cp --sparse=always</code>.
The disk image has a large <b>virtual</b> size.  It is shipped as a [https://en.wikipedia.org/wiki/Sparse_file sparse file] so it will only use a small fraction of this space on the host.  Make sure you use commands and filesystems which preserve sparseness, such as <code>tar</code>, <code>xz</code>, <code>cp --sparse=always</code>, and the common Linux filesystems.


If the image is too large (or too small) to fit on external media, use the [https://linux.die.net/man/8/resize2fs resize2fs] command to resize it.
If the image is too large (or too small) to fit on external media, use the [https://linux.die.net/man/8/resize2fs resize2fs] command to resize it.

Revision as of 08:06, 17 October 2016

All about the RISC-V disk images.

Latest image

The stage4 disk image is built cleanly from RPMs with no broken dependencies and only a tiny number of modifications.

https://fedorapeople.org/groups/risc-v/disk-images/

The disk image does not include a bootloader, kernel or emulator.

Booting on Fedora QEMU

Download the vmlinux (kernel) from the same directory. Install the bootloader and QEMU:

# dnf copr enable rjones/riscv
# dnf install riscv-qemu riscv-pk

Boot the disk image:

$ qemu-system-riscv -m 4G -kernel /usr/bin/bbl \
     -append vmlinux \
     -drive file=stage4-disk.img,format=raw -nographic

Booting in other places

You will most likely need to compile your own kernel and/or bootloader. Note that the kernel will need to include many features required by systemd and other parts of Fedora. For suggestions on what to configure, see this file.

Installing extra packages inside the VM

The disk image only has a basic set of packages installed. We build many more. To install them you will need to use the dnf command. However you will need to configure it, and configuration is different depending on whether your RISC-V machine has network access or not.

Installing packages with a working network

Edit /etc/yum.repos.d/local.repo, uncomment the https baseurl and comment out the file baseurl. DNF should be able to download packages from our public repo.

Installing packages without a working network

Fedora's QEMU does not support networking. Therefore you have to download all the RPMS from https://fedorapeople.org/groups/risc-v/RPMS/ (eg. using a recursive wget or rsync) and copy them into the disk image. Simply placing the whole RPMS directory under /var/tmp will work:

$ guestfish -a stage4-disk.img -m /dev/sda
><fs> copy-in /your/copy/of/RPMS /var/tmp
><fs> exit

DNF groups

DNF groups should work, eg:

# dnf install @buildsys-build

Note about DNF caching

DNF aggressively caches, even local file repositories. Therefore if you get strange errors about missing packages when the packages are obviously there, do this command first:

# dnf clean all

Using systemd or not using systemd

The disk image boots using systemd as the init system. /init inside the disk image is a symlink to systemd.

You will need a kernel which supports all the features required by systemd. If you want to change how the system boots, you will need to add systemd units.

If you prefer not to use systemd, then modify the disk image:

  • Remove the /init symlink.
  • Add your own /init shell script (or binary).
  • Ensure the /init script is executable.

The /init script needs to remount the root filesystem as rw and a few other things. Look at the code of the Fedora autobuilder for an example.

Power off

If you are using systemd, run:

# poweroff

If you are not using systemd, run:

# sync
# poweroff -f

Disk image is too large/too small

The disk image has a large virtual size. It is shipped as a sparse file so it will only use a small fraction of this space on the host. Make sure you use commands and filesystems which preserve sparseness, such as tar, xz, cp --sparse=always, and the common Linux filesystems.

If the image is too large (or too small) to fit on external media, use the resize2fs command to resize it.

Sources

https://fedorapeople.org/groups/risc-v/SRPMS/
Fedora sources.
https://github.com/rwmjones/fedora-riscv-kernel
Kernel build scripts, kernel config, and a link to the kernel sources we use.
https://github.com/rwmjones/fedora-riscv-stage4
Scripts used to build the stage4 disk image.
https://github.com/rwmjones/fedora-riscv-stage4/blob/master/stage4-build-init.sh
How the RPMs were installed in the stage4, and any subsequent modifications made.
https://fedoraproject.org/wiki/Architectures/RISC-V
Links to all other documentation.