mmcinstall: new script to install running root filesystem to internal mmc of devices
This commit is contained in:
parent
ac5eb6b06c
commit
f769a9a240
1
Makefile
1
Makefile
@ -57,6 +57,7 @@ install: install-dirs install-locales
|
||||
$(INSTALL_PROGRAM) src/usbinstall.py $(DESTDIR)$(mambadir)/usbinstall/usbinstall.py
|
||||
$(INSTALL_SCRIPT) src/usbinstall.sh $(DESTDIR)$(sbindir)/usbinstall
|
||||
$(INSTALL_SCRIPT) src/rootfsinstall.sh $(DESTDIR)$(sbindir)/rootfsinstall
|
||||
$(INSTALL_SCRIPT) src/mmcinstall.sh $(DESTDIR)$(sbindir)/mmcinstall
|
||||
$(INSTALL_DATA) src/img/*.png $(DESTDIR)$(mambadir)/usbinstall/img/
|
||||
$(INSTALL_DATA) src/org.openmamba.usbinstall.policy $(DESTDIR)$(polkitdir)/org.openmamba.usbinstall.policy
|
||||
$(INSTALL_DATA) src/org.openmamba.usbinstall.conf $(DESTDIR)$(dbussystemdir)/org.openmamba.usbinstall.conf
|
||||
|
58
src/mmcinstall.sh
Executable file
58
src/mmcinstall.sh
Executable file
@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
echo "mmcinstall - Copy system partition to internal mmc device"
|
||||
echo "Copyright (C) 2013 by Silvan Calarco <silvan.calarco@mambasoft.it>"
|
||||
echo
|
||||
SOURCEPART=`cat /proc/cmdline | sed "s|root=\([^[:space:]]*\).*|\1|"`
|
||||
[ "$SOURCEPART" ] || {
|
||||
echo "ERROR: unable to detect root device; aborting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
cnt=0
|
||||
grep mmcblk0p /proc/partitions | while read line; do
|
||||
set -- $line
|
||||
cnt=$((cnt + 1))
|
||||
size=$(($3 / 1024))
|
||||
echo "$cnt) $4 ($size MB)"
|
||||
done
|
||||
|
||||
echo
|
||||
while [ ! "$ans" ]; do
|
||||
echo -n "Please select target partition: "
|
||||
read ans
|
||||
done
|
||||
|
||||
if [ "$ans" ]; then
|
||||
set -- `grep mmcblk0p /proc/partitions | tail -n +$ans | head -n 1`
|
||||
DESTPART="/dev/$4"
|
||||
fi
|
||||
|
||||
[ -e $DESTPART ] || {
|
||||
echo "Error: destination device $DESTPART missing; aborting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo
|
||||
echo -e -n "Ok to copy system from $SOURCEPART to $DESTPART?\nWARNING: all data on $DESTPART will be lost!\nPlease enter 'Y' to proceed: "
|
||||
read ans
|
||||
|
||||
[ "$ans" = "Y" ] || exit 1
|
||||
|
||||
echo "Formatting $DESTPART"
|
||||
mkfs.ext4 -L project $DESTPART || {
|
||||
echo "Error formatting $DESTPART; aborting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo -n "Copying $SOURCEPART filesystem to $DESTPART..."
|
||||
mkdir -p /mnt/project-source
|
||||
mount $SOURCEPART /mnt/project-source
|
||||
mkdir -p /mnt/project
|
||||
mount $DESTPART /mnt/project
|
||||
cp -a /mnt/project-source/* /mnt/project/
|
||||
umount $DESTPART
|
||||
umount $SOURCEPART
|
||||
rmdir /mnt/project-source
|
||||
rmdir /mnt/project
|
||||
echo
|
||||
echo "Done."
|
Loading…
Reference in New Issue
Block a user