The Raspberry Pi family typically boots from an SD card plugged to the system. To avoid SD card lifetime issues, these systems can run from an connected USB resp. USB disk stick or – on some Pi derivatives – from an onboard eMMC flash memory.
Lifetime issues may occur from the fact that the number of write cycles to SD cards are much lower than to USB sticks/disks or eMMC. Additionally, systems often boot quicker from USB resp. eMMC compared to a plugged SD card.

At best, you can start with the USB device resp. a removable eMMC card) by flashing DietPi directly to this.
In case of an already running system, there may be the need of moving this running system to a different location: This blog describes how to move your system to a USB stick/disk or to the onboard eMMC.
The description below is focused on a DietPi system, but – with minor changes – generally also works for other distributions.
Introduction
DietPi supports various types of SBCs (see there), some of theses hardware variants contain onboard eMMC memory or a connector for an eMMC memory module.
These devices e.g. are:
- ODROID N2+, C2, C4, XU4(Q)
- NanoPi M4, M4B, M4v2, NEO4, K2, M1, M1+, R1
- NanoPC T4
- Pine A64, H64, ROCK64, ROCKPro64
- ROCK Pi 4, Radxa Zero
- Sparky SBC
- ASUS Tinker Board S
All these boards can boot from this eMMC, some boards, like the ODROID N2+, contain a switch to select the boot media (onboard, SD card).
In addition, most of the systems can boot from a USB connected device, like e.g.
- Raspberry Pi 4, 400
- Raspberry Pi 3B, 3B+ (maybe needed to be activated via
dietpi-config -> Advanced Options
) - Many derivates like ODROID C4, XU4, N2+, ASUS Tinker Board, many of the NanoPi boards
Therefore, it is a good practice to move the SBCs system to such an eMMC or USB device.
Basically, only the dd
command is needed to copy the SD cards contents to the USB device resp. eMMC and reboot. That’s all.
But life is not this easy in all cases…
Preconditions
The following preconditions must be checked to go on:
- A running DietPi system
- The size of the eMMC memory resp. USB memory stick/disk
The following procedures are given as the user ‘root’. If the shell runs without root privileges, the ‘sudo’ prefix shall be set in front of the given commands.
Running DietPi system
We assume a DietPi system running from an SD card which shall be moved completely (all SD card partitions) to the USB/eMMC.
To obtain a good performance, the USB device should be plugged into a USB3 connector. There are devices, like the Raspberry Pi 4, which have both USB2 and USB3 connectors onboard.
Size of the eMMC memory resp. USB memory device
The USB/eMMC memory must be larger than the actual needed storage on the SD card. Otherwise the SD card partitions need to be shrinked (e.g. using the gparted program, see below).
Step 1: Check filesystem size
Whether the USB/eMMC memory is larger than the actual needed storage on the SD card can be checked via lsblk
which may give (example 1):
root@Pi4:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 1 115.5G 0 disk
mmcblk0 179:0 0 14.9G 0 disk
├─mmcblk0p1 179:1 0 256M 0 part /boot
└─mmcblk0p2 179:2 0 14.6G 0 part /
The example 1 shows a 128 GB USB stick (/dev/sda
) and a 16 GB SD card (/dev/mmcblk0
).
A different situation may occur, if the size of the SD card used is larger than the USB device resp. eMMC capacity (example 2):
root@Pi4:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 1 3.9G 0 disk
mmcblk0 179:0 0 14.9G 0 disk
├─mmcblk0p1 179:1 0 256M 0 part /boot
└─mmcblk0p2 179:2 0 14.6G 0 part /
As can be seen in example 2, the size of the USB stick (/dev/sda
) is 4 GB and is smaller than the SD card (/dev/mmcblk0
) capacity of 16 GB. In this case, the SD card needs to be shrunk (e.g. using the gparted
program, see below).
In another example 3, the size of the eMMC is smaller than the SD card (example was done on a NanoPi M1+ with eMMC soldered onboard):
root@M1plus:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk0 179:0 0 29.8G 0 disk
└─mmcblk0p1 179:1 0 29.8G 0 part /
mmcblk2 179:8 0 7.3G 0 disk
└─mmcblk2p1 179:9 0 7.3G 0 part
mmcblk2boot0 179:16 0 4M 1 disk
mmcblk2boot1 179:24 0 4M 1 disk
As can be seen, there are two block devices: mmcblk0
and mmcblk2
. The device mmcblk2
is the onboard eMMC flash (size 8 GiB), this can be deducted from the additional boot partitions mmcblk2boot0
and mmcblk2boot1
.
Additionally the output shows that the active root partition (SD card) is mounted to the mount point /
.
In example 1 and 2, the final goal is to copy the SD card mmcblk0
to the USB stick sda
.
In example 3, the final goal is to copy SD card mmcblk0
to the onboard eMMC flash mmcblk2
.
Step 2: Shrink filesystem size
This step 2 can be skipped in the case that the USB device / eMMC capacity is larger than the SD card size.
The example given below is based on the above example 3 which was a NanoPi M1+ with onboard eMMC.
See above example 3: As can be seen, the SD card on /dev/mmcblk0
has a size of 29.8 GiB. This partition needs to be resized to a value smaller than the 7.3 GiB of the onboard eMMC.
As a requirement, the data on the SD card needs to be less than the 7.3 GiB. If this cannot be achieved, we won’t be able to clone the drive and hence won’t be able to boot from eMMC.
The resizing of the SD cards partition can be done with various tools. One of them is the graphical tool GParted on a (different) Linux system with an X11 desktop.
Before the partition is shrunk, the SD cards partitions are shown like this (select the appropriate device, here /dev/sdb
):

The resizing is done via the Partition menu entry:

In the next dialog, drag the partition size quite near the minimum possible size:

Press the button Resize/Move, afterwards do an Edit->Apply All Operations. After the resizing is finished, the SD cards partitions looks like this:

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:
root@M1plus:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk0 179:0 0 29.8G 0 disk
└─mmcblk0p1 179:1 0 3.8G 0 part /
mmcblk2 179:8 0 7.3G 0 disk
└─mmcblk2p1 179:9 0 4.7G 0 part
mmcblk2boot0 179:16 0 4M 1 disk
mmcblk2boot1 179:24 0 4M 1 disk
As can be seen the size of the partition mmcblk0p1
was shrunk from 29.8 GiB down to 3.8 GiB which is less than the 7.3 GiB of the onboard eMMC.
Step 3: Move operating system to USB stick resp. eMMC
The basic command to do this is dd
.
To ensure that during the OS copy process no other processes change the filesystem, it is changed to read-only mode via:
dietpi-services stop
swapoff -a
mount -o remount,ro /
In case of an error message like “mount point is busy” at the mount command (last line), you need to manually set the root filesystem to read only. This can be achieved via
sed -i '\|[[:blank:]]/[[:blank:]]|s|,rw|,ro|' /etc/fstab
reboot
which changes the root filesystem in the /etc/fstab
to read only, then reboots the system.
Then the SD card is copied to the USB device resp. eMMC.
For example 1 and 2 this is done via:
dd if=/dev/mmcblk0 of=/dev/sda bs=1M status=progress
For example 3 this is done via:
dd if=/dev/mmcblk0 of=/dev/mmcblk2 bs=1M status=progress
The option bs=1M
speeds up by copying larger chunks. The option status=progress
gives an output at the command line to be able to track the operation. The copy process will take some time.
After the execution of the copy process the system can be shutdown, the SD card is removed and the system is rebooted.
As a final step, you need to change the root filesystem back to read/write via:
sed -i '\|[[:blank:]]/[[:blank:]]|s|,ro|,rw|' /etc/fstab
mount -o remount,rw /
Another options to move the SD card contents to your target device may be to use
- balenaEtcher or Rufus (graphical user interface option)
gnome-disks
(graphical user interface option)
These are options which typically are executed on a different system.
Step 4: Finalize
If the system is booted from the USB device / eMMC, the system looks like this (example onboard eMMC from example 3):
root@M1plus:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk2 179:0 0 7.3G 0 disk
└─mmcblk2p1 179:1 0 4.7G 0 part /
mmcblk2boot0 179:8 0 4M 1 disk
mmcblk2boot1 179:16 0 4M 1 disk
The size of the partition mmcblk2p1
(4.7 GiB) in this status is smaller than the whole onboard eMMC size (7.3 GiB). To be able to use the rest of the onboard flash, start the dietpi-drive_manager
to resize the partition to maximum size (Remark: The start of the dietpi-drive_manager
may take a longer time for this procedure).
Select the disk containing the root (/
) partition and press Enter
.

In the following dialog select Resize
to go on:

After this procedure the disk partition sizes are:
root@M1plus:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk2 179:0 0 7.3G 0 disk
└─mmcblk2p1 179:1 0 7.3G 0 part /
mmcblk2boot0 179:8 0 4M 1 disk
mmcblk2boot1 179:16 0 4M 1 disk
Now, the partition size is now enlarged to 7.3 GiB and the complete operating system move is finished.
Tataa! You have reached your target.
Troubleshooting
If your Raspberry Pi does not boot from the USB stick you can also check this instruction: How to Boot Raspberry Pi 4 / 400 From a USB SSD or Flash Drive.
Further information
- LOGIN TechBlog, Holger: DietPi: System im laufenden Betrieb auf externe USB-Disk / Stick / SSD übertragen
- PiMyLifeUp, Gus: Raspberry Pi Boot from USB
Very good article, but the word is “shrunk”, not “shrinked”.
Many thanks! Found and fixed some other typos, and switched to English decimal separator :).
Thanks for the great article.
Is this article still valid for DietPi 8.11 on Debian Bullseye (RPi4)?
Thanks for your kind feedback. Yes it is generally still valid.
The instructions worked perfectly!
Just a note to step 3: if you need to put the filesystem in to read-only mode, you need access to the console. In short: next steps can’t be done via SSH. 🙂
Tried it with a PINE A64+. Won’t boot from USB-SSD. Any hint/advise please?
Not every SBC supports USB boot. Some only do with dedicated SPI bootloader enabled. Not sure in case of PINE A64 tbh, but the dedicated “bootable” at the micro SD info of PINE64 wiki article is an indicator that USB booting is not possible: https://wiki.pine64.org/wiki/PINE_A64#Storage
Thx a lot. Works on PINE A64 with SD used for boot and Systemruns from USB-SSD.
It is working, thanks for sharing.
But before making it working I need to put
BOOT_ORDER=0xf41 (before this it was 0x1, so only sd card was checked for boot)
Where
1 = Check SD card
4 = Check USB drive
f = Start again
And it is executed/red from right to left.
With the command :
sudo -E rpi-eeprom-config –edit
Now, my Diet-Pi check SD Card, then USB, then retry.
I now use a M3 SSD disk with Aragon M2 Case, it is working well.