Changes

Jump to: navigation, search

Pidora-2014-Reformating-Boot-Script

1,360 bytes added, 10:13, 14 August 2014
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 …'
== 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 partition and reformat it vfat.
#
# To use this script, provide the image name as
# the first argument.
# Example "./revfat image-name.img"
#
# Requirements (Fedora 17 package):
# bash (bash)
# fdisk (util-linux)
# kpartx (kpartx)
#
# Version 1.0 2013-04-05
#
# Authors:
# Andrew Greene, Seneca College 2013-04-05
#



# partition
kpartx -av "$1"

# You
sleep 3

#create temp dirs
mkdir /media/temp
mkdir /tmp/boot

## mount boot partition
mount -o rw /dev/mapper/loop0p1 /media/temp/

## copy boot data to temp dir
cp -r /media/temp/* /tmp/boot

#rename kernel.img work around for boot
cp /tmp/boot/kernel-3.* /tmp/boot/kernel.img

#unmount temp boot dir
umount /media/temp

#reformat boot parttions to vfat
mkfs -t vfat -n boot /dev/mapper/loop0p1
sleep 3

# update partition fs info
echo "t
1
c
d
3
w
" | fdisk /dev/loop0

sleep 3
## re-mount boot partition
mount -o rw /dev/mapper/loop0p1 /media/temp

#cp orginal boot data to new vfat partition
cp -r /tmp/boot/* /media/temp/
sleep 10
# umount tmp boot again
umount /media/temp

sync

# remove partions and loopback devs
kpartx -dv "$1"

sleep 3

# cleanup
dmsetup remove loop0p3
sleep 2
rm -rf /media/temp
rm -rf /tmp/boot
1
edit

Navigation menu