Extend boot partition of rasperry
Extend boot partition of rasperry
Download the Raspbian Lite image, and extract/unzip
Code:
1
kpartx -u -v /Downloads/2018-06-27-raspbian-stretch-lite.img
(Change as appropriate image for image name, and assume that it created loop0, loop0p1 & loop0p2 )
Code:
1
fdisk -l /dev/loop0
Disk /dev/loop0: 1.8 GiB, 1862270976 bytes, 3637248 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4d3ee428Device Boot Start End Sectors Size Id Type
/dev/loop0p1 8192 96663 $88472$ 43.2M c W95 FAT32 (LBA)
/dev/loop0p2 98304 3637247 $3538944$ 1.7G 83 LinuxThe important part here is the number of sectors for the
linux/ext4partition number 2 ($3538944$ above), will be used in creating partition 2 below.Code:
1
blkid /dev/loop0
Look for the PTUID value, like the below, to be used in fdisk below.
/dev/loop0: PTUUID=”4d3ee428” PTTYPE=”dos”
insert SD card and locate the sd? device name/number, in my case it was /dev/sdd
Code:
1
fdisk /dev/sdd
delete any/all partitions and start with a
MBRpartition tablecreate the
bootpartition (primary 1) with the needed size. with the start $8192$ (I’m not sure if it makes a diffference, but rather keep that !'t'(type) and set it as'c'(Win Fat32 lba)print the table using the
'p'commandcreate the 2nd primary partition
use the last sector number of the first partition as start,
'fdisk'will barf on it, but then it’ll give a more “appropriate” start than $2048$.use the size of the loop0p2 partition’s number af sectors to define the end, by prepending a
+to the number, like:Code:
1
+3538944
using my values from
fdisk -l /dev/loop0above.go to expert mode using:
'x'set the disk identifier using the
'i'commandusing the above example/information:
0x4d3ee428(remember the0xinfront !)exit to normal mode:
'r'write the partition table to disk
'w'Code:
1
mkfs.fat -n "boot " -F 32 /dev/sdd1
the extra spaces is what is/was in the original (find that with
file -Ls /dev/loop0)Code:
1
2
3mkdir /tmp/sd1 /tmp/lp1
mount /dev/mapper/loop0p1 /tmp/lp1
mount /dev/sdd1 /tmp/sd1Now we’ve mounted the partitions to copy data from
Code:
1
rsync -vaP /tmp/lp1/ /tmp/sd1/
and this copies the boot partition’s data
Code:
1
2dd if=/dev/mapper/loop0p2 of=/dev/sdd2 status=progress bs=4M
This copies the Raspbian linux FS to the SD card
Code:
1
2vi /tmp/sd1/cmdline.txt
remove the quiet portion to see atleast if the kernel is booting, and double check the
root=PARTUUID=4d3ee428-2part, and you’ll read it as the device ID appended with a dash (-) and the partition number of the root FS. If thedevice ID/partuuidchanges, you’ll also need to fix some other stuff inside the root FS (like the/usr/lib/raspi_config/init_resize.shand/etc/fstab) that depends on that specificPARTUUIDvalue(s), so I’d rather fix it before we hit thatCode:
1
2
3
4umount /tmp/lp1
umount /tmp/sd1
syncremove SD card, and try to boot…. should be working as it does for me with a bigger boot FS for extra kernels