Create a USB-Bootable aarch64 openSUSE Raspberry Pi-3

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:

  1. 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).
  2. 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

  1. Install those update files:
zypper in raspberrypi-firmware*

If you reboot now, your openSUSE will be using the new firmware during the boot process.

  1. 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.
  2. 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
>
  1. 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
  1. 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.

  1. 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
/ #
  1. 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 "
  1. 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"
  1. 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
  1. Activate those configuration changes:
/ # grub2-mkconfig -o /boot/grub2/grub.cfg
/ # mkinitrd
/ # sync
  1. 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
  1. 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.

Subsequent to writing up this How-To, the “non-upstream” branch of openSUSE Tumbleweed was modified to incorporate changes that make the distribution image USB-bootable (!).

At least as of 1 March, the process is now as simple as:

  • Download an openSUSE image
  • Copy it to a USB drive (thumbdrive or SATA hard-drive/USB drive connected by SATA-USB adapter) with dd
  • Connect a USB-prepared Raspberry Pi-3 to that drive via USB and power up.

Look here http://download.opensuse.org/repositories/devel:/ARM:/Factory:/Contrib:/RaspberryPi3/images/ for images. Follow the install instructions for installing 64-bit openSUSE from here: https://en.opensuse.org/HCL:Raspberry_Pi3 .

Note that these are non-upstream images: updates (“zypper up”) won’t update kernel or broadcom drivers. So this approach is probably best for those who just want to explore SUSE Linux and/or explore the aarch64 ARMv8 architecture in a low-overhead manner rather than for those who want to implement a production server that must be stable and updated over a longer period of time.

On Thu 02 Mar 2017 02:46:02 AM CST, hdtodd wrote:

Subsequent to writing up this How-To, the “non-upstream” branch of
openSUSE Tumbleweed was modified to incorporate changes that make the
distribution image USB-bootable (!).

At least as of 1 March, the process is now as simple as:

  • Download an openSUSE image
  • Copy it to a USB drive (thumbdrive or SATA hard-drive/USB drive
    connected by SATA-USB adapter) with dd
  • Connect a USB-prepared Raspberry Pi-3 to that drive via USB and
    power up.

Look here http://tinyurl.com/jqhsdd7 for images. Follow the install
instructions for installing 64-bit openSUSE from here:
https://en.opensuse.org/HCL:Raspberry_Pi3 .

Note that these are non-upstream images: updates (“zypper up”) won’t
update kernel or broadcom drivers. So this approach is probably best
for those who just want to explore SUSE Linux and/or explore the aarch64
ARMv8 architecture in a low-overhead manner rather than for those who
want to implement a production server that must be stable and updated
over a longer period of time.

Hi
I’m assuming the steps to set the USB boot flag via Raspbian OS is
still required though?


Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
openSUSE Leap 42.1|GNOME 3.16.2|4.1.36-44-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

GM, Malcolm,

Yes, my fault: I was trying to be succinct (for a change). The “USB-prepared Raspberry Pi-3” was shorthand to say that the Pi-3 must have already been prepared with the one-time steps documented here for Raspbian: https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md

That only has to be done once, and if you’ve done it for Raspbian already, you can just plug in the openSUSE USB drive and boot!

Thanks for the catch!

David

If you use a microSD card that also plugs in to a USB adapter and would like to be able to boot from that microSD from either the MMC slot or a USB slot, the procedure above can be modified slightly to let you do that.

The key is to label the file systems in the three partitions. It’s easiest to do that while creating the partitions and file systems, as step II.5 in the procedure shows (labels EFI, ROOT, and SWAP for the sda1, sda2, and sda3 in that case). You can also label them after populating them – probably not while running from that drive, though – with dosfslabel, tune2fs, and mkswap (the latter recreates the swap partition structure).

With the file systems labeled, you can edit the line in /etc/default/grub to read:

GRUB_CMDLINE_LINUX=" root=LABEL=ROOT plymouth.enable=0 console=ttyS0,115200n8 quiet"

and the contents of /etc/fstab to read:

LABEL=ROOT    /      ext4 noatime,nobarrier 1 1
LABEL=EFI    /boot/efi vfat defaults 0 0
LABEL=SWAP    swap       swap defaults 0 0

Then proceed with the procedure at III.5.

The key is to label the file systems in the three partitions. It’s easiest to do that while creating the partitions and file systems, as step II.5 in the procedure shows (labels EFI, ROOT, and SWAP for the sda1, sda2, and sda3 in that case). You can also label them after populating them – probably not while running from that drive, though – with dosfslabel, tune2fs, and mkswap (the latter recreates the swap partition structure).

With the file systems labeled, you can edit the line in /etc/default/grub to read:

GRUB_CMDLINE_LINUX=" root=LABEL=ROOT plymouth.enable=0 console=ttyS0,115200n8 quiet"

Also, you can tell the initrd to use labels instead of device names. Instead of issuing mkinitrd, issue dracut --persistient-policy by-label. Mostly, I wanted to add this as I saw your comment in the other thread, about mkinitrd using the current cmdline a la /proc/cmdline.

If watch closely when the initrd is being built, many of the modules are skipped by default. cmdline is one of them. You have to manually specify them with dracut. (mkinitrd is more or less a wrapper around dracut now)