Raspberry Pi 3B+: Boot from SSD reliably
The problem#
I encountered a problem while trying to boot my Raspberry Pi 3B+ from an SSD drive using a USB to SATA 2.5" enclosure (UGREEN 2.5 Inch Hard Drive Enclosure SATA HDD Caddy External USB 3.0 Hard Disk Case.
The problem that I faced was that when I rebooted the device, it would not come up. The enclosure's activity LED would stay on but not blink - indicating drive inactivity.
Also although it was a headless setup, I managed to plug it into a HDMI screen and saw that there was no video output when the problem occurred.
Keep in mind that when the device was cold-booted (pulling the power plug and re-plugging it) it would boot up fine.
Reading through the raspberrypi forums, there were some suggestions to what the problem could be and some solutions provided.
The solution#
What fixed the problem for me was to keep a microSD card connected to the device while booted from the SSD drive and
- format the microSD card to
FAT32
- mount the microSD card to the system
- get
bootcode.bin
to the microSD card - create a file named
timeout
in the microSD card
First of all we have to identify the card's name and make sure it is not mounted. Run lsblk
ilias@raspberrypi:~ $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 447.1G 0 disk
├─sda1 8:1 0 512M 0 part /boot/firmware
└─sda2 8:2 0 446.6G 0 part /
mmcblk0 179:0 0 29.7G 0 disk
└─mmcblk0p1 179:1 0 29.7G 0 part
/dev/sda
is my SSD drive/dev/mmcblk0
is the microSD card
Carrying on with the format operation
ilias@raspberrypi:~ $ sudo fdisk /dev/mmcblk0 [5/1934]
Welcome to fdisk (util-linux 2.38.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-62357503, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-62357503, default 62357503):
Created a new partition 1 of type 'Linux' and of size 29.7 GiB.
Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): L
00 Empty 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
01 FAT12 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
02 XENIX root 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
03 XENIX usr 40 Venix 80286 85 Linux extended c7 Syrinx
04 FAT16 <32M 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
05 Extended 42 SFS 87 NTFS volume set db CP/M / CTOS / .
06 FAT16 4d QNX4.x 88 Linux plaintext de Dell Utility
07 HPFS/NTFS/exFAT 4e QNX4.x 2nd part 8e Linux LVM df BootIt
08 AIX 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
09 AIX bootable 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
0a OS/2 Boot Manag 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
0b W95 FAT32 52 CP/M a0 IBM Thinkpad hi ea Linux extended
0c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
0e W95 FAT16 (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
0f W95 Ext'd (LBA) 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a9 NetBSD f1 SpeedStor
12 Compaq diagnost 61 SpeedStor ab Darwin boot f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
16 Hidden FAT16 64 Novell Netware b7 BSDI fs f8 EBBR protective
17 Hidden HPFS/NTF 65 Novell Netware b8 BSDI swap fb VMware VMFS
18 AST SmartSleep 70 DiskSecure Mult bb Boot Wizard hid fc VMware VMKCORE
1b Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fd Linux raid auto
1c Hidden W95 FAT3 80 Old Minix be Solaris boot fe LANstep
1e Hidden W95 FAT1 81 Minix / old Lin bf Solaris ff BBT
24 NEC DOS
Aliases:
linux - 83
swap - 82
extended - 05
uefi - EF
raid - FD
lvm - 8E
linuxex - 85
Hex code or alias (type L to list all): 0b
Changed type of partition 'Linux' to 'W95 FAT32'.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
ilias@raspberrypi:~ $ sudo mkfs.fat /dev/mmcblk0p1 -s 64 -F 32
mkfs.fat 4.2 (2021-01-31)
We now have formatted the microSD card to FAT32.
ilias@raspberrypi:~ $ sudo fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 29.73 GiB, 31927042048 bytes, 62357504 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: 0x6079fc31
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 62357503 62355456 29.7G b W95 FAT32
Mounting the microSD card to the system#
Create a folder:
mkdir mount_sd
Mount the empty card to our new folder:
sudo mount /dev/mmcblk0p1 mount_sd
Downloading the bootcode.bin
file#
Note
More info about the bootcode.bin
-only boot mode can be found here.
Get into the mount_sd
folder:
cd mount_sd
Download the latest bootcode.bin
file:
sudo wget https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin
Creating an empty file named timeout
#
While still being in mount_sd
folder:
sudo touch timeout
Once you've done the above procedure you can unmount the card, remove the mount_sd
folder and reboot the device:
ilias@raspberrypi:~/mount_sd $ cd ~
ilias@raspberrypi:~ $ sudo umount mount_sd
ilias@raspberrypi:~ $ rmdir mount_sd
ilias@raspberrypi:~ $ sudo reboot
The RaspberryPi 3B+ should come up online normally.