Open main menu

CDOT Wiki β

Changes

Pidora-2014-Reformating-Boot-Script

193 bytes added, 13:29, 27 August 2014
Pidora 2014 Reformating Boot Partition Script
<pre>
#!/usr/bin/env bash
#
# Script to take an SD card image created by Livemedia-Creator (such as for a
# Raspberry Pi) with a an ext4 boot partition and reformat it to vfat.
#
# To use this script, provide the image name as
# kpartx (kpartx)
#
# Version 1.0 20131 2014-0408-0527
#
# Authors:
# Andrew Greene, Seneca College 2013-04-05# Christopher Markieta, Seneca College 2014-08-27
#
set -e
MY_DIR=$(dirname $0)
# partition loopdev=if [ $(kpartx id -u) -av ne 0 ]; then echo "Root privileges are required for running $10." | awk 'NR== exit 1 {print elif [ -z $3}') 1 ]; then echo -e "Usage: $loopdev0 [image]" exit 1fi
# You loopdev=$(kpartx -avs "$1" | awk 'NR==1 {print $3}')sleep 3echo "$loopdev"
#create temp dirsmkdir . "$MY_DIR"/temp/mkdir -p ."$MY_DIR"/tmp/boot/
# mount boot partition
mount -o rw /dev/mapper/$loopdev "$MY_DIR"/temp/
## mount boot partitionmount cp -o rw r "$MY_DIR"/temp/dev* "$MY_DIR"/mappertmp/$loopdev .boot/temp
## copy Rename kernel.img workaround for boot data to temp dircp "$MY_DIR"/tmp/boot/kernel-r 3./temp/* ."$MY_DIR"/tmp/boot/kernel.img
#rename kernel.img work around for boot cp .umount "$MY_DIR"/tmptemp/boot/kernel-3.* ./tmp/boot/kernel.img
#unmount temp format boot dirumount ./temp #reformat boot parttions parttion to vfat
mkfs -t vfat -n boot /dev/mapper/$loopdev
sleep 3
# update partition fs info
3
w
" | fdisk /dev/"${loopdev::5}1"
sleep 3## re-mount boot partitionmount -o rw /dev/mapper/$loopdev ."$MY_DIR"/temp
#cp orginal copy original boot data to new vfat partitioncp -r ."$MY_DIR"/tmp/boot/* ./tempsleep 10# umount tmp boot againumount ."$MY_DIR"/temp
sync # remove partions and loopback devsumount "$MY_DIR"/temp
kpartx -dv "$1"
sleep 3 # cleanuprmdir "$MY_DIR"/temp/dmsetup remove rm -rf "$loopdevsleep 2MY_DIR"/tmp/</pre>
rm -rf Source: https://github.com/Markieta/temprm raspberrypi-rf .reformat/blob/tmp<master/pre>revfat