This How-To shows how to create a USB drive for your Raspberry Pi-3 that allows the Pi to boot 64-bit, aarch64 openSUSE Leap 42.x or SLES 12.2 directly from that USB drive. It documents procedures worked out by Malcolm Lewis and Alex Graf. The procedure has been verified for Raspberry Pi-3’s running Leap 42.2 JeOS and XFCE, Tumbleweed XFCE, and SLES 12.2.
The process steps are:
[LIST=I]
Prepare the Raspberry Pi to boot from a USB drive (one time)
Create a USB drive that contains the openSUSE system
Make the USB-based openSUSE USB-aware by modifying the openSUSE system on that USB drive to include USB drivers in its system initialization
Boot from that USB drive and configure the system.
[/LIST]
This procedure will not work for Pi Zero or Pi-1 since their hardware boot ROMs do not have USB-aware boot code. The procedure has not been tested on but might work with the second generation Pi-2B v 1.2 that is based upon the ARMv8 Broadcom 2837 processor. At the time this was written, the process below had only been confirmed to work with the Raspberry Pi-3B, based upon the Broadcom 2837.
Requirements
- Raspberry Pi 3 running Raspbian OS
- Either a microSD drive with a functioning openSUSE installed or a spare microSD drive with a capacity of at least 8GB
- USB thumb drive or SSD/HD with a SATA/USB adapter; drive should have a capacity of at least 8GB
- Internet access
I. Prepare the Raspberry Pi-3 to boot from a USB drive
The general concepts of Pi-3 Mass Storage Booting are documented here: https://www.raspberrypi.org/blog/pi-3-booting-part-i-usb-mass-storage-boot/
The preparation of the Pi-3 for USB booting is a one-time procedure. If you’ve already done this, you don’t need to do it again. Follow the preparation procedure documented here:https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md
through the step:
$ vcgencmd otp_dump | grep 17:
17:3020000a
to verify that your RPi-3 is configured to attempt to boot off an attached USB drive. That is, you don’t need to continue into the section "PREPARE THE USB STORAGE DEVICE’. However, if you subsequently are unable to boot SUSE off your USB drive, return to that section to create a bootable Raspbian USB drive in order to verify that your USB drive is compatible with RPi-3 for this purpose.
II. Create a USB drive that contains the openSUSE system
If you do not have a version of aarch64 openSUSE for the RPi-3 on a microSD drive from which you can boot the RPi-3, follow the instructions here to create one:https://en.opensuse.org/HCL:Raspberry_Pi3
Then:
- Boot your RPi-3 with your openSUSE microSD and connect it to the Internet (Ethernet connection if you haven’t set up WiFi on it).
- Retrieve the firmware and configuration file needed to make openSUSE USB-boot-aware:
wget -c http://download.opensuse.org/repositories/hardware/openSUSE_Leap_42.2/noarch/raspberrypi-firmware-2017.02.20-53.1.noarch.rpm
wget -c http://download.opensuse.org/repositories/hardware/openSUSE_Leap_42.2/noarch/raspberrypi-firmware-config-rpi3-2017.02.20-53.1.noarch.rpm
- Install those update files:
zypper in raspberrypi-firmware*
If you reboot now, your openSUSE will be using the new firmware during the boot process.
- Type “lsblk” and note the devices; insert your USB drive and type “lsblk” again; note the new device: that is your USB drive. If it is the only USB MSD connected to your RPi-3, it’ll likely be /dev/sda. Be very careful to reference this drive correctly in the remaining steps, since otherwise you will erase other drives that might be connected to your RPi-3.
The remaining instructions assume that your device is /dev/sda. - Create your USB drive partitions. The commands below create a partition structure like that created on the microSD by the openSUSE install procedure: /dev/sda1 is /boot/efi; /dev/sda2 is /; /dev/sda3 is /swap.
For a 32GB USB drive, leaving 1G for swapping:
# parted /dev/sda
(parted) mktable msdos
(parted) mkpart primary fat32 0% 200M
(parted) mkpart primary ext4 200M 31G
(parted) mkpart primary linux-swap 31G 100%
(parted) p
<prints partition structure, which will look something like:
Model: Lexar uSD UHS2 RDR (scsi)
Disk /dev/sda: 32.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 200MB 199MB primary lba, type=0c
2 200MB 31.0GB 30.8GB primary type=83
3 31.0GB 32.0GB 1027MB primary type=82
>
(parted) q
# zypper in dosfstools# mkfs.vfat -n EFI -F 32 /dev/sda1 # mkfs.ext4 –L ROOT /dev/sda2 # mkswap –L SWAP /dev/sda3
# fdisk –l /dev/sda
<prints partition structure, which will now look something like:
Disk /dev/sda: 29.8 GiB, 32026656768 bytes, 62552064 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000173d4
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 391167 389120 190M c W95 FAT32 (LBA)
/dev/sda2 391168 60547071 60155904 28.7G 83 Linux
/dev/sda3 60547072 62552063 2004992 979M 82 Linux swap / Solaris
>
- Install necessary utilities. You’ll need rsync. You’ll also need to do a little editing in some of the tasks ahead. If there is a particular editor you prefer to use, this would be a good time to install it. In any case, you’ll need rsync. So, for example:
# zypper in rsync nano
- Populate your USB partitions from your microSD partitions:
# cd /mnt
/mnt # mkdir /mnt/tgt
/mnt # mount /dev/sda2 tgt
/mnt # mkdir tgt/boot
/mnt # mkdir tgt/boot/efi
/mnt # mount /dev/sda1 tgt/boot/efi
/mnt # rsync -ax --progress /boot/efi/ tgt/boot/efi
/mnt # rsync -ax --progress / tgt
[Note well the “/” at the end of “/boot/efi/”, otherwise the rsync will not create the boot files the RPi needs to see in its boot directory.]
At this point, you have the openSUSE system on your USB drive, but the boot code is still configured for booting from the microSD drive (mmcblk0). We’ll fix that next.
III. Make USB-based openSUSE USB-aware during boot
The following steps change the configuration files and regenerate the boot files so that openSUSE uses the USB environment when it boots from the USB drive.
- Isolate your work on the USB drive from your boot microSD drive
/mnt # cd /mnt/tgt
/mnt/tgt # mount --bind /dev dev
/mnt/tgt # mount --bind /sys sys
/mnt/tgt # mount --bind /proc proc
/mnt/tgt # chroot /mnt/tgt
/ #
- Include the USB and WiFi drivers in your initial boot firmware by editing the list of modules to be included in initrd. Edit the file /etc/dracut.conf.d/raspberrypi_modules.conf to include as its first line:
add_drivers+=" bcm2835-sdhost bcm2835_dma sdhci_bcm2835 dwc2 usbnet uas usb_storage usbcore usb_common "
- Tell grub about your new boot configuration. Edit /etc/default/grub to look like this (may only need to change GRUB_CMDLINE_LINUX and add GRUB_DISABLE_OS_PROBER):
GRUB_DISTRIBUTOR=openSUSE
GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=0
GRUB_CMDLINE_LINUX=" root=/dev/sda2 disk=/dev/sda plymouth.enable=0 console=ttyS0,115200n8 quiet"
GRUB_TERMINAL=gfxterm
GRUB_GFXMODE=800x600
GRUB_GFXPAYLOAD_LINUX=keep
GRUB_THEME="/boot/grub2/themes/openSUSE/theme.txt"
GRUB_BACKGROUND="/boot/grub2/themes/openSUSE/background.png"
GRUB_DISABLE_OS_PROBER="true"
- Tell the USB openSUSE about the USB disk structure. Edit /etc/fstab to look like this:
/dev/sda2 / ext4 noatime,nobarrier 1 1
/dev/sda1 /boot/efi vfat defaults 0 0
/dev/sda3 swap swap defaults 0 0
- Activate those configuration changes:
/ # grub2-mkconfig -o /boot/grub2/grub.cfg
/ # mkinitrd
/ # sync
- Return to your microSD drive environment and finish up
/ # exit
/ # cd /mnt/tgt
/mnt/tgt # umount proc
/mnt/tgt # umount sys
/mnt/tgt # umount dev
/mnt/tgt # cd ~
# umount /dev/sda1
# umount /dev/sda2
# sync
# systemctl poweroff
- Try out your USB boot drive:
-
Remove power from your RPi-3
-
Remove the microSD drive
-
Powerup your RPi-3
IV. Boot from that USB drive and configure the system
You should now boot up off your USB drive into the same operating environment you had with your microSD drive. If you hadn’t activated WiFi earlier, it is now installed and available on your USB-based system. Run YaST to configure it and connect to your access point.
Proceed to install other applications or utilities as needed.
V. Potential Problems
If you have trouble booting off the USB drive, there are several factors that might be causing the problem. Here are some things to check:
- Are you booting from a Pi-3B? This procedure only works for Pi-3’s (at the time this was written).
- Have you verified that your one-time activation of USB-booting on the Pi-3 worked? Check again by booting Raspbian and checking with the command “vcgencmd otp_dump | grep 17:”
- Do you have enough power to for both your Pi-3, any other connected devices, and your USB mass storage device? In particular, if you’re using a hard drive connected to the RPi-3 with a USB/SATA adapter, you may not have enough power. Try isolating your hard drive power from the RPI-3 by using a powered USB hub between the two.
- Does your USB device respond quickly enough to allow it to boot? If you aren’t sure, install Raspbian on it per the reference above and make sure it works for Raspbian.
An openSUSE installation booting off the USB drive has been observed to generate sporadic mmc0 register dumps. While these don’t appear to indicate problems that affect performance, if they become a nuisance, insert an unformatted microSD card into the mmc slot to prevent them from occurring until a permanent fix is developed.