Raspberry Pi Custom Installation/Raspbian

From JMK Wiki
Jump to: navigation, search

Download and unzip the latest raspbian image

root@localhost ~ # wget -O raspbian_latest.zip https://downloads.raspberrypi.org/raspbian_latest
root@localhost ~ # unzip raspbian_latest.zip

Check the partitions within the image

root@localhost ~ # fdisk -l 2018-03-13-raspbian-stretch.img
Disk 2018-03-13-raspbian-stretch.img: 4.6 GiB, 4949278720 bytes, 9666560 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: 0x15ca46a5

Device                           Boot Start     End Sectors  Size Id Type
2018-03-13-raspbian-stretch.img1       8192   93802   85611 41.8M  c W95 FAT32 (LBA)
2018-03-13-raspbian-stretch.img2      98304 9666559 9568256  4.6G 83 Linux

Calculate the partition beginnings

boot: 8192 * 512 = 4194304
root: 98304 * 512 = 50331648

Mount and copy the boot partition from the image to the SD card

root@localhost ~ # mkdir -p /mnt/raspbian/boot
root@localhost ~ # mkdir -p /mnt/rpi/boot
root@localhost ~ # mount 2018-03-13-raspbian-stretch.img -o loop,offset=4194304 /mnt/raspbian/boot
root@localhost ~ # mount /dev/mmcblk0p1 /mnt/rpi/boot
root@localhost ~ # cp -a /mnt/raspbian/boot/* /mnt/rpi/boot
root@localhost ~ # umount /mnt/raspbian/boot /mnt/rpi/boot

Mount and copy the boot partition from the image to the SD card

root@localhost ~ # mkdir -p /mnt/raspbian/root
root@localhost ~ # mkdir -p /mnt/rpi/root
root@localhost ~ # mount 2018-03-13-raspbian-stretch.img -o loop,offset=50331648 /mnt/raspbian/root
root@localhost ~ # mount /dev/rpi/raspbian /mnt/rpi/raspbian
root@localhost ~ # cp -a /mnt/raspbian/root/* /mnt/rpi/raspbian
root@localhost ~ # umount /mnt/raspbian/root /mnt/rpi/raspbian