Difference between revisions of "Pidora-2014-Reformating-Boot-Script"

From CDOT Wiki
Jump to: navigation, search
(Created page with '== Pidora 2014 Reformating Boot Partition Script == #!/bin/bash # # Script to take an SD card image created by Livemedia-Creator (such as for a # Raspberry Pi) with a ext4 boot …')
(No difference)

Revision as of 10:13, 14 August 2014

Pidora 2014 Reformating Boot Partition Script

  1. !/bin/bash
  2. Script to take an SD card image created by Livemedia-Creator (such as for a
  3. Raspberry Pi) with a ext4 boot partition and reformat it vfat.
  4. To use this script, provide the image name as
  5. the first argument.
  6. Example "./revfat image-name.img"
  7. Requirements (Fedora 17 package):
  8. bash (bash)
  9. fdisk (util-linux)
  10. kpartx (kpartx)
  11. Version 1.0 2013-04-05
  12. Authors:
  13. Andrew Greene, Seneca College 2013-04-05


  1. partition

kpartx -av "$1"

  1. You

sleep 3

  1. create temp dirs

mkdir /media/temp mkdir /tmp/boot

    1. mount boot partition

mount -o rw /dev/mapper/loop0p1 /media/temp/

    1. copy boot data to temp dir

cp -r /media/temp/* /tmp/boot

  1. rename kernel.img work around for boot

cp /tmp/boot/kernel-3.* /tmp/boot/kernel.img

  1. unmount temp boot dir

umount /media/temp

  1. reformat boot parttions to vfat

mkfs -t vfat -n boot /dev/mapper/loop0p1 sleep 3

  1. update partition fs info

echo "t 1 c d 3 w " | fdisk /dev/loop0

sleep 3

    1. re-mount boot partition

mount -o rw /dev/mapper/loop0p1 /media/temp

  1. cp orginal boot data to new vfat partition

cp -r /tmp/boot/* /media/temp/ sleep 10

  1. umount tmp boot again

umount /media/temp

sync

  1. remove partions and loopback devs

kpartx -dv "$1"

sleep 3

  1. cleanup

dmsetup remove loop0p3 sleep 2 rm -rf /media/temp rm -rf /tmp/boot