# Image usage for HiFive Unmatched

## M.2 Key E W-Fi Module Compatibility

> The full `linux-firmware` package is preinstalled in the image, so common m.2 WiFi cards supported by openEuler should work flawlessly.

The following list shows the tested WLAN Cards for the image.

- Intel Corporation Wireless 7265 (rev 59)
- TODO: Add more cards

> Please be aware that the WiFi signal is weak if no antenna is attached. It's possible that you can not find ANY available WiFi network if the board is inside a metal case.

## Usage

### Boot openEuler RISC-V from the NVMe Drive

> Using an NVMe drive with the Unmatched makes a huge difference in terms of performance and usability, so it is strongly recommended to use it if possible.

- Boot from SD Card
- Copy or download the openEuler RISC-V image to the SD card
- Decompress and rename the image for ease of typing. For example, the image is now called `openEuler.img`
- Make sure the NVMe drive is present by running

```bash
ls -l /dev/nvme*
```

- For example, the NVMe drive can appear as `/dev/nvme0n1`. Now flash the image to the NVMe by running

```bash
sudo dd if=/openEuler.img of=/dev/nvme0n1 bs=1M status=progress
```

- mount the root partition on nvme drive to /mnt and chroot into it. In this case, rootfs is on the third partition `/dev/nvme0n1p3`

```bash
sudo mount /dev/nvme0n1p3 /mnt
sudo chroot /mnt
```

- Use your favorite text editor (vim and nano are available) to edit `/boot/extlinux/extlinux.conf`, change the root partition on SD Card

```bash
root=/dev/mmcblk0p3
```

to the root partition on the NVMe Drive

```bash
root=/dev/nvme0n1p3
```

- Quit the chroot, and edit `/boot/extlinux/extlinux.conf` as same as the last step.

- Voila! You now have a bootable installation of openEuler RISC-V installed on the NVMe drive of your HiFive Unmatched. Reboot the system, then it will now boot to your NVMe drive and you will have significant performance gains!

## Enlarge your root partition on NVMe Drives

> When we flash images with `dd`, there's always an empty space left on the end of storage device due to the size difference of image and device.

For openEuler RISC-V image, the root partition is set to be automaticlly resized on the first boot from SD cards to make use of the empty space.

This job is done by a script at `/usr/lib/oE-script/resize-rootfs`, however the script is written for the SD card with hardcoded value.

User can edit this script with following command to make the script also useful for NVMe drives. For example, the NVMe drive can appear as `/dev/nvme0n1`. :

```bash
sed -i 's#/dev/mmcblk0#/dev/nvme0n1#g' /usr/lib/oE-script/resize-rootfs
```

And setup an indicator for the script at the root partition on NVMe drive:

```bash
touch /.resize-rootfs
```

## Reference

- [How to install Ubuntu on RISC-V HiFive boards](https://ubuntu.com/tutorials/how-to-install-ubuntu-on-risc-v-hifive-boards)

- [Installing Debian On SiFive HiFive Unmatched](https://wiki.debian.org/InstallingDebianOn/SiFive/HiFiveUnmatched)
