multiple bootable partitions on a microSD card

99 views
Skip to first unread message

John Allwine

unread,
Sep 18, 2020, 10:47:03 AM9/18/20
to BeagleBoard
Has anyone partitioned a microSD card such that it can be booted into different partitions on a Beaglebone Black or AI? How would I go about doing something like that? I'd like to avoid needing to physically take out the microSD card and potentially add bootable partitions over time. Would that be doable from the Beaglebone itself?

Robert Nelson

unread,
Sep 18, 2020, 10:55:48 AM9/18/20
to Beagle Board
On Fri, Sep 18, 2020 at 9:47 AM John Allwine <jo...@pocketnc.com> wrote:
>
> Has anyone partitioned a microSD card such that it can be booted into different partitions on a Beaglebone Black or AI? How would I go about doing something like that? I'd like to avoid needing to physically take out the microSD card and potentially add bootable partitions over time. Would that be doable from the Beaglebone itself?

We use "/boot/uEnv.txt" as a trigger file..

Take an existing partition, shrink it to half, (dont' touch the 4mb
hole), then clone that partition to the empy space (and update it's
/etc/fstab)..

On startup, u-boot will search the first 4 partitions for
"/boot/uEnv.txt" so either rename the one on the first partition to
the boot the second/etc..

There's probably a better way, but this will just work with the
existing setup with the fewest mod's..

Regards,

--
Robert Nelson
https://rcn-ee.com/

John Allwine

unread,
Sep 18, 2020, 12:50:08 PM9/18/20
to BeagleBoard
Thanks Robert! I'll give it a try. It sounds like 4 different images would be the limit using that strategy? Let's say I had a 256GB microSD card with 10 different partitions. Any idea on what I would have to change to be able to select one besides one of the first 4?

John Allwine

unread,
Sep 18, 2020, 1:01:14 PM9/18/20
to Beagle Board
The ultimate goal here would be to be able to essentially flash a board, but always be able to revert to a previously installed firmware. So rather than always flash the eMMC, leverage a much larger microSD card that could have several different images and instead of ever overwriting them, allocate spare space to a new partition and change whatever setting is necessary to default to booting to that partition (and provide some interface for reverting to any previous one).

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/15487b80-ad54-40df-9079-e12f60368419n%40googlegroups.com.

Robert Nelson

unread,
Sep 18, 2020, 1:25:36 PM9/18/20
to Beagle Board
Correction, first 7 partitions..

This was written before the mmc greater then 8 partitions layer came out


echo Checking for: /boot/uEnv.txt ...;" \
+ "for i in 1 2 3 4 5 6 7 ; do " \
+ "setenv mmcpart ${i};" \
+ "setenv bootpart ${mmcdev}:${mmcpart};" \
+ "if test -e ${devtype} ${bootpart} /boot/uEnv.txt; then " \



I think a better way is extlinux.conf and grub efi, but that'll take some work to implement, vs my quick hack today.

Robert Nelson

unread,
Sep 18, 2020, 1:26:05 PM9/18/20
to Beagle Board
Wait, that's btrfs snapshots, which also works today..

On Fri, Sep 18, 2020, 12:01 PM John Allwine <jo...@pocketnc.com> wrote:

John Allwine

unread,
Sep 21, 2020, 11:15:12 AM9/21/20
to BeagleBoard
I like the idea of using btrfs. How difficult would it be to modify the script that generates the MachineKit images to use a btrfs filesystem rather than ext4? For starters I guess, how do you generate the MachineKit images and how might I do that myself?

Robert Nelson

unread,
Sep 21, 2020, 11:44:30 AM9/21/20
to Beagle Board
On Mon, Sep 21, 2020 at 10:15 AM John Allwine <jo...@pocketnc.com> wrote:
>
> I like the idea of using btrfs. How difficult would it be to modify the script that generates the MachineKit images to use a btrfs filesystem rather than ext4? For starters I guess, how do you generate the MachineKit images and how might I do that myself?

It's actually been fully supported for about a year or two.

When you call "setup_sdcard.sh" just issue:

--rootfs btrfs

(default is ext4)

John Allwine

unread,
Sep 21, 2020, 11:58:16 AM9/21/20
to Beagle Board
Thanks Robert! It sounds like it's straight forward, but I'm not familiar with the image creation process at all. When and where would I call setup_sdcard.sh?

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

Robert Nelson

unread,
Sep 21, 2020, 12:04:27 PM9/21/20
to Beagle Board
On Mon, Sep 21, 2020 at 10:58 AM John Allwine <jo...@pocketnc.com> wrote:
>
> Thanks Robert! It sounds like it's straight forward, but I'm not familiar with the image creation process at all. When and where would I call setup_sdcard.sh?

For example, let's take this image:

https://rcn-ee.net/rootfs/bb.org/testing/2020-09-21/buster-iot/

if we ignore the am57xx files, there are only 2 for BBB's..

bone-debian-*.img.xz and bone-eMMC-*.img.xz

Those were both generated from inside this archive (once extracted),
setup_sdcard.sh is inside the archive:

debian-10.5-iot-armhf-2020-09-21.tar.xz

via:

sudo ./setup_sdcard.sh --img-4gb bone-debian-10.5-iot-armhf-2020-09-21
--dtb beaglebone --rootfs_label rootfs --hostname beaglebone
--enable-cape-universal --enable-uboot-pru-rproc-419ti

sudo ./setup_sdcard.sh --img-4gb
bone-eMMC-flasher-debian-10.5-iot-armhf-2020-09-21 --dtb beaglebone
--rootfs_label rootfs --hostname beaglebone --enable-cape-universal
--enable-uboot-pru-rproc-419ti --emmc-flasher

Just add "--rootfs btrfs"

John Allwine

unread,
Sep 21, 2020, 1:00:34 PM9/21/20
to Beagle Board
Ah, I see. And how does that debian-10.5-iot-armhf-2020-09-21.tar.xz file get generated?

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

John Allwine

unread,
Sep 21, 2020, 1:18:19 PM9/21/20
to Beagle Board
Also, what about the process changes for the am57xx images?

Robert Nelson

unread,
Sep 21, 2020, 1:24:17 PM9/21/20
to Beagle Board
On Mon, Sep 21, 2020 at 12:18 PM John Allwine <jo...@pocketnc.com> wrote:
>
> Also, what about the process changes for the am57xx images?

sudo ./setup_sdcard.sh --img-4gb
am57xx-debian-10.5-iot-armhf-2020-09-21 --dtb am57xx-beagle-x15
--rootfs_label rootfs --hostname beaglebone
--enable-uboot-cape-overlays

sudo ./setup_sdcard.sh --img-4gb
am57xx-eMMC-flasher-debian-10.5-iot-armhf-2020-09-21 --dtb
am57xx-beagle-x15 --rootfs_label rootfs --hostname beaglebone
--enable-uboot-cape-overlays --emmc-flasher

Robert Nelson

unread,
Sep 21, 2020, 1:25:27 PM9/21/20
to Beagle Board
On Mon, Sep 21, 2020 at 12:00 PM John Allwine <jo...@pocketnc.com> wrote:
>
> Ah, I see. And how does that debian-10.5-iot-armhf-2020-09-21.tar.xz file get generated?

git clone https://github.com/beagleboard/image-builder
cd ./image-builder/

./RootStock-NG.sh -c bb.org-debian-buster-iot-v4.19

John Allwine

unread,
Sep 21, 2020, 3:50:01 PM9/21/20
to Beagle Board
Do I run this on a Beaglebone itself, or should it be done on something beefier? Maybe a docker container on my mac? Or would I need an ARM device?

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

Robert Nelson

unread,
Sep 21, 2020, 3:56:58 PM9/21/20
to Beagle Board
On Mon, Sep 21, 2020 at 2:50 PM John Allwine <jo...@pocketnc.com> wrote:
>
> Do I run this on a Beaglebone itself, or should it be done on something beefier? Maybe a docker container on my mac? Or would I need an ARM device?

An x15, or something similar.. Or any Debian based os, it'll use qemu on x86..

John Allwine

unread,
Sep 22, 2020, 3:11:20 PM9/22/20
to Beagle Board
I'm trying to use btrfs as the rootfs, but it doesn't seem to work. 

I created two different eMMC flasher images, one that used the --rootfs btrfs arguments and one that didn't. The one that defaults to ext4 booted up and flashed the eMMC no problem. The btrfs one errors on boot with this:

mmc0 is current device

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     8192            7364608         34e7716f-01     83 Boot
Scanning mmc device 0
Checking for: /uEnv.txt ...
** Unrecognized filesystem type **
Checking for: /boot/uEnv.txt ...
** Unrecognized filesystem type **
** Invalid partition 2 **
** Invalid partition 3 **
** Invalid partition 4 **
** Invalid partition 5 **
** Invalid partition 6 **
** Invalid partition 7 **
switch to partitions #0, OK
mmc1(part 0) is current device

After that it booted using the eMMC rather than the microSD card. Any ideas?

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

Robert Nelson

unread,
Sep 22, 2020, 3:27:27 PM9/22/20
to Beagle Board
On Tue, Sep 22, 2020 at 2:11 PM John Allwine <jo...@pocketnc.com> wrote:
>
> I'm trying to use btrfs as the rootfs, but it doesn't seem to work.
>
> I created two different eMMC flasher images, one that used the --rootfs btrfs arguments and one that didn't. The one that defaults to ext4 booted up and flashed the eMMC no problem. The btrfs one errors on boot with this:
>
> mmc0 is current device
>
> Partition Map for MMC device 0 -- Partition Type: DOS
>
> Part Start Sector Num Sectors UUID Type
> 1 8192 7364608 34e7716f-01 83 Boot
> Scanning mmc device 0
> Checking for: /uEnv.txt ...
> ** Unrecognized filesystem type **
> Checking for: /boot/uEnv.txt ...
> ** Unrecognized filesystem type **
> ** Invalid partition 2 **
> ** Invalid partition 3 **
> ** Invalid partition 4 **
> ** Invalid partition 5 **
> ** Invalid partition 6 **
> ** Invalid partition 7 **
> switch to partitions #0, OK
> mmc1(part 0) is current device
>
> After that it booted using the eMMC rather than the microSD card. Any ideas?

Looking at the x15/bbai patch, i don't see btrfs added..

Yeap figures, i've only tested this with the BBB, i guess i didn't
enable btrfs on am57xx hardware yet..
Reply all
Reply to author
Forward
0 new messages