RobertCNelson / boot-scripts

Just a bunch of useful scripts placed under /opt/scripts/
124 stars 131 forks source link

added conf_rootfs_partition_size #124

Closed jallwine closed 3 years ago

jallwine commented 3 years ago

Setting the conf_rootfs_partition_size variable allows for better control over the size of the microSD card necessary to house the resulting image when running the beaglebone-black-make-microSD-flasher-from-eMMC.sh script. For example, you might be working with a 32GB microSD card image, but want to generate an image that would also fit on a 4GB microSD card, so you could do the following:

sudo conf_rootfs_partition_size=7462912 /opt/scripts/tools/eMMC/beaglebone-black-make-microSD-flasher-from-eMMC.sh

Which would specify the size as 7462912 sectors, which is the size of the eMMC rootfs partition (at least on the one I was testing on). After making the flasher you could then use dd to get the image off the microSD card for flashing onto other microSD cards:

sudo dd if=<path to microSD card device> of=<your image name> bs=512 count=7471104

7471104 can be determined by the output from fdisk -l (one more than the End sector, or 8192 more than the size of the rootfs partition):

Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk0p1 *     8192 7471103 7462912  3.6G 83 Linux

You may be able to speed up the dd command by using a bigger blocksize and adjusting the count accordingly (using a 4MB block size):

sudo dd if=<path to microSD card device> of=<your image name> bs=419430 count=912
RobertCNelson commented 3 years ago

Looks good, merged!

alanqli commented 1 year ago

Hi, John, i followed the first step of the procedure you clearly outlined here using the updated functions.sh with conf_rootfs_partition_size=7462912, and the first step went smoothly and seems having generated the new flash image on eMMC, but the second step of getting the image off the microSD card is puzzling because the flasher image seems residing on the eMMC card, not on the 32G microSD card I have booted from which is what I want to shrink to 4G as you were trying to do as I understand, so my question is for the second step of using dd to get out the image, what argument i should use for if=/dev/mmcblk0p1 or if=/dev/mmcblk1p1. thanks much for your help/comments.

Here is the fdisk -l from my BBB, debian@beaglebone:~$ sudo fdisk -l [sudo] password for debian: Disk /dev/mmcblk0: 29.8 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: 0xf26f8da3

Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 * 8192 62333951 62325760 29.7G 83 Linux

Disk /dev/mmcblk1: 3.6 GiB, 3825205248 bytes, 7471104 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: 0x3cc1f16e

Device Boot Start End Sectors Size Id Type /dev/mmcblk1p1 * 8192 7471103 7462912 3.6G 83 Linux

jallwine commented 1 year ago

The beaglebone-black-make-microSD-flasher-from-eMMC.sh script makes a flasher image on your microSD card from the image on the eMMC. The only way I've ever used this script is when booting into the eMMC, inserting a microSD card to copy the eMMC image to and running the beaglebone-black-make-microSD-flasher-from-eMMC.sh script. The addition of the conf_rootfs_partition_size allowed for limiting the size of the generated image in the event the microSD card is bigger than the eMMC. Doing so allows the image to be copied from a larger microSD card to a smaller one, for example. Making the image smaller also saves write time.

alanqli commented 1 year ago

Thanks for clarification. Now I retry this by first booting my BBB from eMMC, and then insert an empty 32G microSD card and run the command: sudo conf_rootfs_partition_size=7462912 /opt/scripts/tools/eMMC/beaglebone-black-make-microSD-flasher-from-eMMC.sh, The problem is I didn't see the flasher image anywhere on my microSD at all, looks like the script just re-flash itself (eMMC) again. This doesn't make sense, does it?

jallwine commented 1 year ago

The script makes a flasher image on the microSD card. When you insert the microSD card into another BeagleBone it will flash the image to its eMMC. Taking the microSD card out will then allow booting from the eMMC and it will be functionally the same system as the original BeagleBone.