Andyroo
Posts: 3755
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Mac users - booting Buster from SD + HDD

Sun Jul 07, 2019 4:59 pm

I've had a bit of fun today getting Buster to boot from HD on a Pi 3B+ (with OTP bit set) with some cheap (£1.99) USB to Sata interfaces.

None of the cheap ones I was trying would boot either Buster or Stretch direct though they have been fine for normal HDD use, so I thought I would set up a mixed boot with /boot on the SD and everything on the HDD.

I hit a problem with the SD card being formatted on the Mac (Sierra version 10.12.6) under MBR / MS-DOS FAT but worked out a fix as follows:

1) Download Buster zip file to the Mac and check the SHA is OK
2) Make sure you have NO SD card in the MAC and put the HDD in using the adapter you plan to use on the Pi
3) Write the zip to the HDD using Etcher (version 1.5.30 Mac)
4) Copy the cmdline.txt from the HDD to the Mac
5) Eject the HDD from the Mac and unplug the drive - only then insert the SD card - DO NOT FORMAT IT (use ignore if prompted)
6) Write the zip file to the SD card
7) Copy the cmdline.txt to the SD card overwriting the one present
8) Put the HDD and SD into the Pi and power up

This will then boot from the SD / HDD combination ready to change fstab (and optionally the SD card) as follows:

a) Use blkid to identify the SD boot partition UUID (/dev/mmcblk0p1 in my case)
b) Use sudo nano /etc/fstab and change the /boot line to have this UUID rather than the HDD UUID
c) Use sudo fdisk to delete the Linux partition off the SD card (I used sudo disk /dev/mmcblk0 and pd2dw) - THIS IS OPTIONAL
d) Reboot
e) apt update and upgrade
f) Configure Pi as required

In the end I tracked my issue down to the rename of the SD card - I could not get it boot with anything other than 'boot' as the name BUT the OS writes the card name as BOOT (despite accepting the lower case value) BUT you only see this when you re-insert the card into the Mac :twisted: :roll: :twisted:

Not sure what my Mac is doing to the poor card but this may save a little heartache for some users

I do know that you used to be able to just put bootcode.bin on the SD but only found my note after a few hours messing around :lol: and not tested it as I'm out of Pi machines again :o :( Maybe next weekend or one early morning...
Need Pi spray - these things are breeding in my house...

fbe
Posts: 483
Joined: Thu Aug 17, 2017 9:08 pm

Re: Mac users - booting Buster from SD + HDD

Sun Jul 07, 2019 6:24 pm

If you write the same image to both devices you don't need to copy the cmdline.txt from HDD to SD card. :?
How do you make sure that the root filesystem is mounted from the HDD and not from SD card?

Andyroo
Posts: 3755
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Mac users - booting Buster from SD + HDD

Sun Jul 07, 2019 6:47 pm

The cmdline.txt (on the SD) has the entry to say what disk the root is on

Code: Select all

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=567cccc3-02 rootfstype=ext4 elevator=deadline fsck.repair=yes ipv6.disable=1 rootwait
TBH I did not check what the SD card had - just overwrote it. I think Etcher creates a new partition ID each time it runs as I've just checked 5 SD cards and HHDs and they are all different. A quick check on Discourse does not show anything and the source is way beyond me to understand it.

So before changing anything:

Code: Select all

cat /etc/fstab 
proc            /proc           proc    defaults          0       0
PARTUUID=567cccc3-01  /boot           vfat    defaults          0       2
PARTUUID=567cccc3-02  /               ext4    defaults,noatime  0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
based on

Code: Select all

blkid
/dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="CD28-6C97" TYPE="vfat" PARTUUID="bd1bcc8b-01"
/dev/mmcblk0p2: LABEL="rootfs" UUID="26992cbf-74a1-4b6d-84eb-802b70f9fd9c" TYPE="ext4" PARTUUID="bd1bcc8b-02"
/dev/sda1: LABEL_FATBOOT="boot" LABEL="boot" UUID="CD28-6C97" TYPE="vfat" PARTUUID="567cccc3-01"
/dev/sda2: LABEL="rootfs" UUID="26992cbf-74a1-4b6d-84eb-802b70f9fd9c" TYPE="ext4" PARTUUID="567cccc3-02"
After edits:

Code: Select all

blkid
/dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="CD28-6C97" TYPE="vfat" PARTUUID="bd1bcc8b-01"
/dev/sda1: LABEL_FATBOOT="boot" LABEL="boot" UUID="CD28-6C97" TYPE="vfat" PARTUUID="567cccc3-01"
/dev/sda2: LABEL="rootfs" UUID="26992cbf-74a1-4b6d-84eb-802b70f9fd9c" TYPE="ext4" PARTUUID="567cccc3-02"

Code: Select all

cat /etc/fstab
proc            /proc           proc    defaults          0       0
PARTUUID=bd1bcc8b-01  /boot           vfat    defaults          0       2
PARTUUID=567cccc3-02  /               ext4    defaults,noatime  0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
and

Code: Select all

lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 465.8G  0 disk 
├─sda1        8:1    0   256M  0 part 
└─sda2        8:2    0 465.5G  0 part /
mmcblk0     179:0    0   7.4G  0 disk 
└─mmcblk0p1 179:1    0   256M  0 part /boot
This way any updates to /boot get written to the SD card not the HDD (sda1) - not perfect but this machine may not get a new USB adapter for a year or so and then maybe rebuilt from scratch anyway :lol:
Need Pi spray - these things are breeding in my house...

fbe
Posts: 483
Joined: Thu Aug 17, 2017 9:08 pm

Re: Mac users - booting Buster from SD + HDD

Sun Jul 07, 2019 7:51 pm

Is this the cmdline.txt as saved on your Mac? The "init=/usr/lib/raspi-config/init_resize.sh" is missing here too, that is commonly present on the original image.
Is the root filesystem extended to use the whole disk by etcher already, or do you need to do it later?

Andyroo
Posts: 3755
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Mac users - booting Buster from SD + HDD

Sun Jul 07, 2019 10:20 pm

fbe wrote:
Sun Jul 07, 2019 7:51 pm
Is this the cmdline.txt as saved on your Mac? The "init=/usr/lib/raspi-config/init_resize.sh" is missing here too, that is commonly present on the original image.
Is the root filesystem extended to use the whole disk by etcher already, or do you need to do it later?
The cmdline above was pulled off the Pi after the machine was set up - never thought to keep the original

A newly cut SD version of cmdline.txt from Buster does have the init_resize:

Code: Select all

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=bd1bcc8b-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh splash plymouth.ignore-serial-consoles
Interestingly - this write (different card) has the same partition UUID as the first card I created / am using.

You cannot expand the root filesystem using raspi-config on any HDD as that just throws an error:
sda2 is not an SD card. Don't know how to expand
and looking at the disk - the file system is expanded currently:

Code: Select all

df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       459G  4.7G  436G   2% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           464M     0  464M   0% /dev/shm
tmpfs           464M   13M  451M   3% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           464M     0  464M   0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   41M  213M  16% /boot
tmpfs            93M     0   93M   0% /run/user/1000
I know I have not done that but, unfortunately, I was more interested in getting the process rather than the data and only having one drive and no spare Pi made it a bit hit and miss rather than a detailed examination (some of that would be beyond me anyway).
Need Pi spray - these things are breeding in my house...

Return to “Beginners”