DietPi is just a great distribution. If you haven’t tried it, do.
There is a function within the system called dietpi-drivemanager and it does what it says on the tin, manages drives. For me I wanted to move the rootfs to an SSD. Easily done with DietPi.
Once I had done that, I wanted to reclaim the 16GB SD Card for other things and reuse an old 2GB card. This turned out to be quite easy as well.
From the top – I inserted the smaller SDCard into a USB adapter and plugged it into the Pi.
The smaller card shows up as sdb with lsblk command. First, format the smaller card and create a new partition (taken from this item).
1 2 3 4 5 6 7 8 9 10 11 12 13 |
root@DietPi:~# fdisk /dev/sdb Command (m for help): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): p Partition number (1,3,4, default 1): 1 First sector (2048-15407103, default 2048): 8192 Last sector, +sectors or +size{K,M,G,T,P} (8192-122879, default nnnnnnnn): 122879 Created a new partition 1 of type 'Linux' and of size 56 MiB. Command (m for help): w |
Remember the last command to actually make the changes.
Format the partition as fat
1 |
root@DietPi:~# mkfs.fat /dev/sda1 |
Once the filesystem is made you’re ready to copy – I used dd
1 |
root@DietPi:~# dd if=/dev/mmcblk0p1 of=/dev/sdb1 |
Next, you need to edit the /etc/fstab file.
You need to edit this line and insert the right PARTUUID for the new boot partition. Use the blkid command to get the value. Remember, it will still be shown as the PARTUUID for /dev/sdb1
1 |
PARTUUID=cb7b86f7-01 /boot vfat noatime,lazytime 0 1 |
I then un-mounted the /boot partition, removed the card and inserted the smaller card before rebooting.
As the boot partition is not mentioned in the cmdline.txt file, I did not find a need to edit it.
Bingo! I now have the boot on an otherwise redundant 2GB card and free up a 16GB card for other things. Reduce, reuse recycle.
by