Auto resize SD card after dd copy


I initially started with a 32G SD card when I purchased my Nano. Now I purchased a 128G SD card and I was able to dd between cards. What is the best method to resize my partition? Preferably on the first boot like it is done after the initial SD card image? Or maybe someone wrote such a script and could share?

Would you test his script? (1.8 KB)

Extract it first and run.
Keep in mind that you should check how many partitions you have.
It will handle 14 partitions of JetPack 4.4 by default.


Before I test your script, I was wondering if you spotted a “reverse” script that takes an SD card and created a minimum image? I was able to uninstall a lot of stuff that I will not use. Looks like I am down to a little over 3G used on my SD cards out of 32G. So I did try normal router I did "compacting it with dd to image, mount it as a loop device, resize with gparted and finally use truncate utility.

This does not work with NVIDIA images. Looks like there are few posts about that I did not check earlier.
I also found this post that I am trying to see if it works.

Did you spot any script that would automate machining minimal image and then use your resize script in a first boot?

Actually, can your resize script be executed on the first run rc.local?
Or is it meant for resizing it on another host?
Are you running it after booting? Or you insert an SD card to your workstation and then run the script on /dev/sd* ?


When I flash my 64GB microSD cards from sd_image file for developer kits, I need this script.
Pre-built SD image was for 32GB capacity microSD. But I need whole space 64GB.

To use it, simply run the script with sudo on the Jetson Nano Devkit.
Definitely, Jetson Nano should boot with microSD.


Just wondering… Since default sdk image does expend on first first boot did you write your script before that was available and wanted to make entire SD card useful?
I am working on slight different scenario. I start with sdk image. I install it, resize on first try if it is larger then 32G. I remove what I do not need. Then like to make very small image file that then I can expand to any size SD card. I have my own scripts that installs various packages based on project. Did you ever successfully made very small backup image file. So far I could get to 5G? I do have my own script I did while back that makes small image and also inject resize script on first boot. But this does not work with sdk images. So is gparged not working as well.

Hi oxoocoffee,

I used the script with the pre-built SD image ‘sometimes’.
From time to time, partition table was not fit to microSD.

When it comes to small backup image, I do not have any chance to test.