Best way in 2022 to clone DietPi SdCard to smaller SDcard


I’ve been looking for a while now for the best way to make an exact copy of an installation of DietPi onto a smaller SD card.

On the forum there is often a link to a script that no longer exists:

However, I have only seen once the solution which seems to me the simplest which can be summed up like this (I have not tried it yet):

dietpi-services stop # better don’t have many services running in the meantime
resize2fs -M /dev/mmcblk0p2 # minimize filesystem
df / # check new size

The guide ends there and I can only guess that if my SD card is 128gb it will be minimized in size and I can just use Win32Imager on my PC to make a small image of it that I can copy to my card 32gb or 64gb with Balena? (How do I scale it back to the maximum available size then?)

Otherwise, as the publications that I found are rather old, I would like to know if simpler or more reliable techniques exist and or even if the new backup tool already present in DietPi would not already do the trick?

For information, I’m on Raspberry Pi 4 with 1gb with a 128gb SD card. I did the “DietPi_RPi-ARMv8-Bullseye” install on July 3 with the most recent version available.

Thank you in advance and good day.

Welcome to our community

The script has been moved to a new place

Another option is to have a look at following blog post Running DietPi from an USB stick or an onboard eMMC

1 Like

Hi i’m trying the step by step guide of the blog post link but i’m not sure about this part :

" You see that the partition is shrunk to 3.82 GiB. As next, eject the SD card, put it back to your system and boot. There the SD card /dev/mmcblk0 may look like this: "

Did all the steps are made on the dietPI running system?

In other words, do I need a second computer to make parts of those steps? (I’m confused because how can you “eject” the SD card when your system is still running on it)

Thank you very much.

Chapter 2 is showing the usage of the tool GParted. It can be started as LiveCD on nearly every computer. There you could shrink partitions on a graphical interface. For this the SD card would need to be placed on a desktop computer.

Thank you! I did well to ask :slight_smile:

Would you recommend a good distro to use as liveCD (Usb boot)?

Something with all those useful apps already install?

Have a nice day.

Gparted can be downloaded as ready-to-use image. GParted Live on USB


Lets says that you would like a linux usb boot drive, what distro would you like to have?

This means it’s like a distro, you can flash this image to a USB drive, stick it into your pi and boot from it and just follow the guide you posted earlier.

So I would be able to install any other programm I might need on that live Usb?

No it’s just the Gparted application. There you can’t install anything. And it would need to be a regular computer. I don’t think it’s working on a SBC.

Anyway what exactly you are looking for? Is this a general question on what LiveCD would be a good one? Or any relationship to this question?

I think I didn’t express myself very well.

The proposed solution, gparted, responds well to my need for my initial question.

Nevertheless, I don’t have any other “linux PC” and the research I did before publishing shows me that it can be practical to have 1 linux pc, in addition to the Raspberry, to do certain manipulations.

So, I was wondering, as far as making a new bootable usb key with only Gparted, if you had a good recommendation of a complete and bootable distro that could contain pretty much all the interesting tools to fix or improve DietPi. (including gParted of course)

So it is indeed linked to the original question, but I push the reasoning further. (Maybe even too far ;))

I used to have an Ubuntu key that allowed me to boot into the GUI and use it like a near-normal OS with the package manager.

In the end, in 2022, which distribution would you advise me to make a bootable key containing the useful tools to help me with DietPi in the future?

You could also flash the DietPi Native PC image onto a stick, install a desktop (or the X server only) and apt install gparted.

Or use a VM. If you have a USB SD card adapter, it is very easy to mount it into the VM, e.g. with VMware or VirtualBox.

1 Like

Yes did that test today and flashed the x86 image an a USB stick. Was not the fastest system on earth but was working well using LXDE + Gparted

1 Like

Hi guys,

I come with news.

I finally only flashed Gparted on a usb key and I was ready to do the steps on my PC, but I was a little afraid of screwing everything up with a steps error so I did a test before using Gparted on my SdCard.

Indeed, I have 2 sdCard of 128go so I made a backup of my main card (the one with my system configured well that I would like to transfer to my 64go card). I used Win32 diskimager to do the backup.

Then I used balenaEtcher to flash my second 128 card, same company, same capacity, same range with the backup I just made

The whole save and copy process went well, but the few tests I did with the “new card” were quite disappointing. It’s super slow and sometimes the system takes 15 to 30 seconds to respond.

Even in direct SSH connection, launching the ls -l command on a directory can take me 30s to 1min. It’s really strange. Then I could work well for 30 second to 1min and then start being slow or unresponsive.

I tried removing the card and inserting it again, same thing. If I put the “original” back it works fine, super fast as before.

I’ll have to do more research on this tonight, did I miss a step? Are the tools I used not adequate?

Thanks for your help.

Did you expend partition and filesystem again on the new SD card? E.g.:

systemctl enable dietpi-fs_partition_resize

Otherwise having a look into last system logs or kernel logs might give a hint whether interrupts time out or such:

journalctl -e | tail -10
dmesg -l emerg,alert,crit,err

For the first questions, I’m still testing in the “best condition” going from 128gb to 128gb sdCard so I didn’t edited the partition yet with Gparted at all.

For the command I will try them on my lunch brake and come back to you.



Finally I decided to try the modification with Gparted to reduce the size of the 128gb anyway as in the example of the link of the first publication of Joulinar.

Downsizing seems to have worked well at this level. The partition is really shrunk and the system boots fine and I can see the size reduction.

However, when I’m on my PC to make an image with Win32imager it gives me a 128gb image that it is not possible to put on the 64gb card with belena.

Is it normal? I understand that I’m not doing exactly the same procedure as the given example, but my case I don’t understand when I’m going to succeed in copying that to the 64gb card.

I must be missing something.

To summarize, I now have a 126gb card with my primary partition shrunk to around 18gb which I would like to “clone” to my 64gb card and then run a command there to increase the size to the maximum available on the 64gb card.

Thanks for your help.

I guess this is expected. If I’m not mistaken, Win32imager will create an image of the entire card and not just the used space.

Question: Are you able to connect the 64gb card to your SBC using a USB to SD card connector? Means to boot from the 128gb and connect the 64gb card to USB?