2

Rather than writing stock image to an SD card, sometimes I need to create another physical disk from my backups. My procedure is as follows:

  • detect which device to format
  • create appropriate partitions
  • format these partitions with appropriate filesystems
  • mount partitions
  • copy files from backup to these mountpoints
  • INSTALL APPROPRIATE BOOTLOADER

My current automation script is here.

How can I install the bootloader for Raspberry Pi?

1

The hardware handles the bootloading stage on the pi and knows how to boot the linux kernel without looking at the mbr record on the disk. Therefore you do not need to do anything special to boot the pi besides having all the expected files in the /boot partition.

What you are doing is similar to how the archlinuxarm image is installed, format the drives and mount the drives and then dump the contents of the root filesystem into the mount point. You should not need to do anything else.

  • I just figured out that missed the "Installation" tab in the archlinuxarm image page! They clearly explained what to do which is the same thing I learnt by examining the original rpi image disk... So, clearly you handed over the correct answer way before I found it by myself... :) Thank you... – ceremcem Apr 14 '16 at 8:17
0

It's in the /boot directory here, along with everything else that's normally in the first partition (kernels, device tree overlays, etc.)

So you can click on the little clipboard logo by the "Download ZIP" button (on the right) and

 git clone https://github.com/raspberrypi/firmware.git

Which means you can quickly and easily update it later, or you can actually "Download ZIP".

You can also download individual bits and pieces from inside the directory if you want.

0

Root of my problem was that we have to mark the first partition type as c in order to make RPi boot correctly. The correct partitioning code is as follows:

DEVICE=/dev/mmcblk0
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${DEVICE}
  o # clear the in memory partition table
  n # new partition
  p # primary partition
  1 # partition number 1
    # default - start at beginning of disk 
  +110M # boot parttion
  t # change the type (1st partition will be selected automatically)
  c # Changed type of partition 'Linux' to 'W95 FAT32 (LBA)', mandatory for RaspberryPi
  n # new partition
  p # primary partition
  2 # partion number 2
    # default, start immediately after preceding partition
    # default, extend partition to end of disk
  a # make a partition bootable
  1 # bootable partition is partition 1 -- /dev/sda1
  p # print the in-memory partition table
  w # write the partition table
  q # and we're done
EOF

Full "produce-bootable-disk" script is here: https://github.com/aktos-io/dcs-tools/blob/master/produce-bootable-disk

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.