How to make a bootable disk copy?

Hi Robert,
How to make a bootable disk copy for BBBw? I have flashed eMMC with pre-built image (buster), and installed and updated some deb packages and application programs. I would like to make it as a new pre-built image for easy production release. Any suggestions are greatly appreciated.

Thank you,
David

Hi @dzhou , there is a built-in script to do that…

Boot-up into the eMMC, insert a blank microSD, then run:

cd /opt/scripts/tools/eMMC/
./beaglebone-black-make-microSD-flasher-from-eMMC.sh

If you want to tune it to a specific size, another user just modified the script:

The docs for that change is here:

Regards,

Hi Robert,
Thank you very much for your prompt reply and approach for cloning a disk. My current boards doesn’t have SD card. I will wait for next-spin of boards and test that.

Best Regards,
David

Oh, in that case, just dd the file system to a USB Flash drive. Sync’ing it back to the eMMC will be a little fun, as the USB flash isn’t bootable* if the eMMC is blank… (not by default, but thru u-boot, you can run the correct sequence of commands…)

Regards,

Hi Robert,
I am currently flashing eMMC with BalenaEtcher. Can you give me a little more details regarding Sync-ing it back to eMMC? using dd command? The u-boot is also flashed using dd command. I am not sure that there is a way to combine u-boot and debian image into one to flash back to eMMC?

Best Regards,
David

While it’s trivial to backup the image to USB from the eMMC.

You need to boot into ‘something’ that is not the eMMC, to use dd to write back to the eMMC.

U-Boot, does support reading from USB devices. So while in U-Boot, you’ll need to init the USB Flash Drive, read the USB Flash drive, thus load the kernel/dtb and ‘boot’ into the USB… Then dd from the USB to eMMC…

Regards,

Hi Robert,
For testing, I think I can create a bootable USB, then dd from USB back to blank eMMC. ( In this case, is the u-boot automatically included/combined from the backed up image?)
Final goal is to ship the image to a vendor to flash the eMMC. Hope that image format can be used by them.

Best Regards,
David

Correct, when you ‘dd’ the whole drive is copied over… u-boot/kernel/filesystem/size of media/etc this can cause other issues…

So while dd works, you will have to fix things up, that’s why we have a special script for back’ing up and Flash’ing the eMMC.

So yeah, i don’t recommend dd’ing it, as that would cause other fun issues down the road…

Regards,

I will try it out. Appreciated for all of your inputs and help.

Best Regards,
David

Hi Robert,

I tried it out on BeagleBone Black wireless dev board by running the script:
beaglebone-black-make-microSD-flasher-from-eMMC.sh
It finished copying everything from eMMC to SD card. But after I rebooted the BBBw from the original eMMC ( I had to add root=/dev/mmcblk1p1 and remove the cmdline= in order to boot ), it seems that the original eMMC copy has corrupted:
image
And I cannot mount the SD card.

Any thing I did wrong?
Best Regards,

David

does it work if you login as root/root? (assuming only the libsudio* file was corrupted…)

Regards,

Hi Robert,

It doesn’t work either if login as root/root:
image

It also failed to start OpenBSD Secure Shell Server, and others…

Best Regards,
David

When your logged in as root, you don’t need to call sudo…

Trying to see if you can run:

apt update
apt install sudo --reinstall

Regards,

Hi Robert,

sudo ifconfig doesn’t. Wifi failed. I can reflash the BBBw with prebuild image through usb. I am ok to bring the BBBw back. I am more concerned with a successful duplicate eMMC into a SD Card image. Also, even it is duplicated into SD card, is there a way to create an image as bone-debian-10.0-iot-armhf—.img.xz file format? So the image file can be transferred?

Thank You,
David

Not in any automated or scripted way, once your copy eMMC → microSD, you’d need to dd the microSD to a file…

Regards,

Hi Robert,

I recovered BBBw and the SD card image is good from eMMC, even though eMMC got corrupted. I booted from SD card, and dd eMMC into SD card as an image file. And then converted into xz file format.

I dd-ed the entire driver mmcblk1 and only the mmcblk1p1 partition. Don’t know mmcblk1p1 partition is enough as bootable image ( u-boot is also included in that partition, I guess). I am going to test them out.

Best Regards,
David

That’s a boot partition, don’t worry about those on the am335x.

Regards,

Hi Robert,
eMMC is successfully flashed using the SD card that was created from original eMMC. Only one small issue that after eMMC is flashed, I have to edit uENV to change/set root=/dev/mmcblk1p1, otherwise, it won’t root from eMMC.

Best Regards,
David

Hi Robert,

I tried once more. And it successfully boots from eMMC flashed from the SD card. I might have done something wrong the first time. There is no need to do anything. Thank you very much.

Best Regards,
David

1 Like

Hi Robert,

The .img file created from mmcblk1p1 partition (converted to .img.xz) cannot be flashing using BalenaEtcher. It complains “no bootable partition”. I am wondering any way to add bootable partition. The script to flash eMMC from SD card must have created a bootable partition in the process, am I right?

Best Regards,
David