friendlyarm / sd-fuse_rk3588

43 stars 13 forks source link

How to clone SD card to image file(s) for building a new version of SD card image file(s)? #9

Open samiux opened 1 year ago

samiux commented 1 year ago

I burn debian-bullseye-core-arm64 to SD card in order to install some packages. After that, I would like to clone the SD card to image file(s) in order to get a smaller size image file and it can be burn to any disk size SD card.

However, I do not know how to do that. Would you mind telling me how to do that?

Thank you.

friendlyarm commented 1 year ago

Use RAW_SIZE_MB env, for example, create a 4g image:

RAW_SIZE_MB=4000 ./mk-sd-image.sh debian-bullseye-core-arm64

samiux commented 1 year ago

However, how can I get the userdata.img from the SD card that I created and installed some packages? The SD card image is created with overlay FS.

friendlyarm commented 1 year ago

you may disable overlay fs, please refer to this wiki page: https://wiki.friendlyelec.com/wiki/index.php/How_to_use_overlayfs_on_Linux#Disable_OverlayFS_feature

or backup rootfs using the following command:

sudo passwd root
su root
cd /
tar -cvpzf /rootfs.tar.gz \
    --exclude=/rootfs.tar.gz --exclude=/var/lib/docker/runtimes \
    --exclude=/etc/firstuser --exclude=/etc/friendlyelec-release \
    --exclude=/usr/local/first_boot_flag --one-file-system /
samiux commented 1 year ago

By the way, how to make parameters.txt in order to build a new sd image?

friendlyarm commented 1 year ago

parameters.txt is generated using a template (https://github.com/friendlyarm/sd-fuse_rk3588/blob/master/prebuilt/parameter.template) that will populate the relevant fields (partition size, offset location, etc.) based on your rootfs size