[kwlug-disc] Booting the Raspberry Pi from a hard disk

Khalid Baheyeldin kb at 2bits.com
Sun Feb 10 18:41:42 EST 2019


I am looking to replace the SD card in the Pi with an external USB hard
drive, because
of how using the SD card as the regular filesystem, kills it quick if the
Raspberry Pi is busy.

The disk in question is a 2.5" HDD in an unpowered SATA to USB enclosure.

What is on the web is that the Raspberry Pi does not provide enough current
to power on
regular hard drives. One overcomes this by having the following line in
/boot/config.txt:

max_usb_current=1

And now the Pi will provide enough current for some disks to work.

I plugged in the 2.5" USB disk into an old Pi 2, and I got this:

[1915663.656110] *Under-voltage detected!* (0x00050005)
[1915665.896054] usb 1-1.2: new high-speed USB device number 6 using dwc_otg
[1915666.027408] usb 1-1.2: New USB device found, idVendor=152d,
idProduct=0539
[1915666.027426] usb 1-1.2: New USB device strings: Mfr=10, Product=11,
SerialNumber=3
[1915666.027437] usb 1-1.2: Product: USB to ATA/ATAPI Bridge
[1915666.027448] usb 1-1.2: Manufacturer: JMicron
[1915666.027458] usb 1-1.2: SerialNumber: 00A1234568BF
[1915666.028810] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[1915666.034242] scsi host0: usb-storage 1-1.2:1.0
[1915667.097004] scsi 0:0:0:0: Direct-Access     FUJITSU  zzzzz        0100
PQ: 0 ANSI: 6
[1915667.098779] sd 0:0:0:0: [sda] 488397168 512-byte logical blocks: (250
GB/233 GiB)
[1915667.099523] sd 0:0:0:0: [sda] Write Protect is off
[1915667.099542] sd 0:0:0:0: [sda] Mode Sense: 67 00 10 08
[1915667.100531] sd 0:0:0:0: [sda] Write cache: enabled, read cache:
enabled, supports DPO and FUA
[1915667.126638] sd 0:0:0:0: Attached scsi generic sg0 type 0
[1915667.167254]  sda: sda1 sda2 < sda5 >
[1915667.171010] sd 0:0:0:0: [sda] Attached SCSI disk
[1915669.896159] *Voltage normalised* (0x00000000)
[1915765.621420]  sda: sda1 sda2 < sda5 >
[1915802.971527] EXT4-fs (sda1): mounted filesystem with ordered data mode.
Opts: (null)

I was able to mount filesystems from the hard disk, even without the above
max current parameter.
So, it seems that this step is not necessary anymore.

But then I saw these in dmesg:

[1919494.831934] usb 1-1.2: reset high-speed USB device number 72 using
dwc_otg
[1919499.991904] usb 1-1.2: device descriptor read/64, error -110
[1919515.351869] usb 1-1.2: device descriptor read/64, error -110
[1919515.571861] usb 1-1.2: reset high-speed USB device number 72 using
dwc_otg
[1919520.711888] usb 1-1.2: device descriptor read/64, error -110
[1919536.071810] usb 1-1.2: device descriptor read/64, error -110
[1919536.291810] usb 1-1.2: reset high-speed USB device number 72 using
dwc_otg
[1919546.831810] usb 1-1.2: device not accepting address 72, error -110
[1919546.931778] usb 1-1.2: reset high-speed USB device number 72 using
dwc_otg
[1919557.471762] usb 1-1.2: device not accepting address 72, error -110
[1919557.472224] usb 1-1.2: USB disconnect, device number 72
[1919557.490276] sd 1:0:0:0: [sdb] Synchronizing SCSI cache
[1919557.492644] sd 1:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result:
hostbyte=0x01 driverbyte=0x00
[1919557.492687] sd 1:0:0:0: [sdb] tag#0 CDB: opcode=0x28 28 00 1c 9c b8 00
00 00 08 00
[1919557.492703] print_req_error: I/O error, dev sdb, sector 480032768
[1919557.492841] sd 1:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result:
hostbyte=0x01 driverbyte=0x00
[1919557.492863] sd 1:0:0:0: [sdb] tag#0 CDB: opcode=0x28 28 00 00 00 08 18
00 00 08 00
[1919557.492874] print_req_error: I/O error, dev sdb, sector 2072
[1919557.492916] blk_partition_remap: fail for partition 5
[1919557.492936] Buffer I/O error on dev sdb5, logical block 256, async
page read
[1919557.493019] blk_partition_remap: fail for partition 1
[1919557.493032] Buffer I/O error on dev sdb1, logical block 3, async page
read
[1919557.495651] sd 1:0:0:0: [sdb] Synchronize Cache(10) failed: Result:
hostbyte=0x01 driverbyte=0x00
[1919557.741765] usb 1-1.2: new high-speed USB device number 73 using
dwc_otg
[1919562.871741] usb 1-1.2: device descriptor read/64, error -110
[1919578.231704] usb 1-1.2: device descriptor read/64, error -110
[1919578.451696] usb 1-1.2: new high-speed USB device number 74 using
dwc_otg
[1919583.591696] usb 1-1.2: device descriptor read/64, error -110

Perhaps power saving on the USB ports or by the enclosure's electronics?

The other thing is telling the Pi to boot from that USB disk. This requires
adding this line to config.txt
while still running from the SD card:

program_usb_boot_mode=1

Then rebooting, and the Pi should boot from the hard disk.

However, this is not the whole story.

I always installed Raspian on the Pi's using NOOBS. You download a .zip
file, extract it to an SD
card that is formatted as vfat, and off you go. Very easy.

Eventually, I want to copy the running system's SD card to the hard disk to
continue from where
it is now.

I could not find information on how to install Raspian (or NOOBS) to a hard
disk, nor how to have
the disk partition properly for Raspbian.

For example, in this article
<https://www.maketecheasier.com/boot-up-raspberry-pi-3-external-hard-disk/>,
the author walks through the steps of copying the existing running SD
card to the hard disk, but he copies to /dev/sda (the entire disk, not a
specific partition on it).

So questions:

1. How do I install NOOBS to the hard disk? Do I just format it as vfat and
copy the contents of
the NOOBS zip to it?

2. How to partition the hard disk for Raspbian?

3. How to make sure that power saving mode would not affect the USB disk?
-- 
Khalid M. Baheyeldin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20190210/68187a15/attachment-0001.html>


More information about the kwlug-disc mailing list