Page 1 of 1

Move Boot partition to smaller SD Card

Posted: Fri Dec 27, 2019 1:21 pm
by baz123
I'm going to move the rootfs to an SDD (using drive-manager). Once I have done that, I'd like to move the boot partition to a smaller SD card.

I have seen this topic on the Raspbian forum but I wonder if there is a better way or if it could be built into the drive-manager?

Re: Move Boot partition to smaller SD Card

Posted: Sat Dec 28, 2019 4:49 pm
by baz123
I have successfully moved the rootfs using dietpi-drive_manager (fantastic feature).

I have tried to move the boot partition by inserting a smaller SD Card via an adapter, formatting it as FAT and using

Code: Select all

dd if=/dev/mmcblk0p1 of=/dev/sdb1
to move the boot partition.

This failed to reboot. Putting the old card back in reboots fine.

@MichaIng, could you suggest how I might do this? I really need the old 16Gb card ;).

Re: Move Boot partition to smaller SD Card

Posted: Sat Jan 04, 2020 9:20 am
by baz123
Anyone any suggestions as to how to move the boot partition?

Re: Move Boot partition to smaller SD Card

Posted: Sun Jan 05, 2020 10:51 am
by MichaIng
@baz123
When you pre-create the boot partition take care to adjust the PARTUUIDs in /boot/cmdline.txt and /etc/fstab files on the new partition. blkid -so PARTUUID /dev/sda1 if /dev/sda1 is the device of the new SDcard.

Re: Move Boot partition to smaller SD Card

Posted: Mon Jan 06, 2020 9:58 am
by baz123
@MichaIng

I have the SSD running fine with the dietpi-drivemanger utility to move rootfs (great facility BTW).

I now want to use a smaller SD card for the boot partition, but cannot find a method to move boot, that DietPi likes (unless I misunderstood your reply).

Re: Move Boot partition to smaller SD Card

Posted: Tue Jan 07, 2020 4:59 pm
by MichaIng
Nope there is nn native GUI method in DietPi, however this does not mean that DietPi does not "like" it. We just didn't implement it since use cases are rare. When editing the two files as mentioned it should work.

Re: Move Boot partition to smaller SD Card

Posted: Wed Jan 08, 2020 9:07 am
by baz123
Solved. I had misunderstood the response. For anyone following on it is very simple to do.

From the top - I inserted the smaller SDCard into a USB adapter and plugged it into the Pi.

It shows up as sdb with lsblk. First, format the smaller card and create a new partition (taken from this item https://www.raspberrypi.org/forums/view ... 20#p800811).

Code: Select all

[email protected]:~# 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

Code: Select all

[email protected]:~# mkfs.fat /dev/sda1
Once the filesystem is made you're ready to copy - I used dd

Code: Select all

[email protected]:~# dd if=/dev/mmcblk0p1 of=/dev/sdb1
Next is the bit I missed, 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

Code: Select all

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 8)

@MichaIng - would be really great if this function was an option in the dietpi-drivemanager.

Cheers all.