### Enable BIOS boot on USB device

By default, USB device can only boot on UEFI (Unified Extensible Firmware Interface)
firmware. For old devices, hybrid boot UEFI + BIOS (Basic Input Output System)
also named CSM (Compatibility Support Module) can be enabled.

#### Usage

```sh
build-live-system.sh --bios device
```

#### Example

```sh
build-live-system.sh --bios /dev/sdx
```


### Manual setup for live USB system

**Warning: this operation destroys all USB device data**.

To manually setup a bootable USB device (without using previous `--usb` action),
it must be GPT partitionned and have a Fat-32 formatted partition containing
the `efi` folder and the live-system files. Installing the live system is
just a regular copy.

The optional data partition must be ext4 formatted.

- The following example partitions and formats the USB device, with 8GiB space
for the live-system (and extra storage), and a persistent data partition:

```sh
LIVELABEL="LiveSystem"
LIVEDIR="linomad"
HOMELABEL="LiveData"
sgdisk -Z /dev/sdx
sgdisk -o -n 1::+8G -t 1:ef00  -n 2:: /dev/sdx
mkfs.vfat -n $LIVELABEL /dev/sdx1
mkfs.ext4 -F -L $HOMELABEL -O ^has_journal /dev/sdx2
```
- If the live system files resides in an ISO image, mount it:

```sh
mkdir live; mount -o loop live.iso live/
```
- The following commands copy the files on the USB device:

```sh
mkdir usb; mount /dev/sdx1 usb/
cp -r live/{efi,$LIVEDIR} usb/
umount usb; rmdir usb
```
- Optionally, to enable BIOS / legacy boot, an additional BIOS boot partition
(EF02) and an hybrid GPT + MBR (Master Boot Record) are required before installing GRUB:

```sh
sgdisk -n 128:34:2047 -t 128:ef02 -h 2 /dev/sdx
mkdir usb; mount /dev/sdx1 usb/
grub-install --target i386-pc --boot-directory usb/bios $installdevice
echo "configfile /efi/boot/grub.cfg" > usb/bios/grub/grub.cfg
umount usb; rmdir usb
```
