Re: Problem with TinyCore Linux in Bhyve in TrueNas

From: George Hartzell <hartzell_at_alerce.com>
Date: Sun, 21 Jul 2024 19:44:41 UTC
George Hartzell writes:
 > 
 > I have a TrueNAS Core system running TrueNAS-13.0-U6.1.
 > 
 > I'm trying to install TinyCore Linux in a VM.  [...]

Just wanted to follow up with a few notes after working all this out.
It's mostly straight-forward, do what you think you should, and _etc_.

The key bits are:

- Use the [TinyCorePure64] iso, it has the UEFI bits needed to boot
  up.
- Connect via VNC
- In grub, choose `core`, the window-system version (tc) would boot
  but I could never get the mouse/keyboard to respond in the VNC
  window.
- Use the virtio network device, not the Intel device.  The Intel
  device works for a bit, but when I would try to reconnect a VNC
  session the entire VM would get a sig 6 or 11.

For my future self's sake (and completeness), my notes boil down to:

## Set up a VM

- Grab a copy of the x86 Pure 64 port iso.  E.g. the [Core Pure 64
  Latest Build] and then [TinyCorePure64].  You need the
  `TinyCorePure64` ISO, not the `CorePure64...` ISO, the former
  includes necessary UEFI boot bits.

- Set up a VM using the TrueNAS GUI.  Most of the choices are
  "obvious", but definitely should have...
  - Guest Operating System: Linux
  - Boot Method: UEFI
  - [x] Enable VNC
  - NEXT
  - CPU bits, whatever, I took the defaults
  - NEXT
  - Create a new disk image, provide a ZVOL storage location and a
    size.
  - NEXT
  - Networking bits
    - Choose the virtio adapter, not the Intel.  The intel seems to
      cause the vm to crash when (at least) VNC reconnects.
  - NEXT
  - boot from the e.g. TinyCorePure64-15.0.iso image.  You might need
    to upload it from your laptop or otherwise get it into the TrueNAS
    filesystem.
  - NEXT
  - SUBMIT

## Start the VM

- Start it
- Choose the VNC console
- In grub, choose `core` (the `tc` choice sets up an X desktop, I
  couldn't figure out how to get it to listen to input...).
- You should now be at a shell prompt

## Load some useful tools (might not be minimal...)

- `tce-load -wi e2fsprogs dosfstools grub2-multi efibootmgr`

- `sudo fdisk /dev/sda` ...
- `sudo fdisk /dev/sda` -- goal is to create two partitions, first is a
  type `ef` (EFI) of ~0.5G, then a type `83` (linux) that uses the
  rest of the disk.

- Create some filesystems:
  - `sudo mkfs.vfat /dev/sda1`
  - `sudo mkfs.ext4 /dev/sda2`

- Mount them
  - `sudo rebuildfstab`
  - `sudo mount /dev/sda1`
  - `sudo mount /dev/sda2`

- Install the boot loader
  - `sudo grub-install --target=x86_64-efi --boot-directory=/mnt/sda1/EFI/BOOT --efi-directory=/mnt/sda1 --removable`

- Set up the tinycore bits
  - `mkdir /mnt/sda1/boot`
  - `mount /dev/sr0`
  - `cp /mnt/sr0/boot/* /mnt/sda1/boot`  # ignore warning about omitting a directory
  - `cp /mnt/sr0/EFI/BOOT/grub/grub.cfg /mnt/sda1/EFI/BOOT/grub/grub.cfg`
  - (optional) edit the `grub.cfg`, I removed useless entries... and
    added a `default=core` and `timeout=5`
  - `mkdir /mnt/sda1/tce`
  - `touch /mnt/sda1/tce/mydata.tgz`

- `sudo halt`

- Stop the VM, remove the CD device from the VM, then start it and reconnect to VNC.

- Et, viola!


[TinyCorePure64]: http://tinycorelinux.net/15.x/x86_64/release/TinyCorePure64-15.0.iso