mirror of
https://bitbucket.org/gwenhael/cubietruck-slackware.git
synced 2025-01-18 22:26:12 +01:00
NAND install script for Cubietruck Debian
This commit is contained in:
parent
83dc617453
commit
0d0daf3c22
1 changed files with 85 additions and 0 deletions
85
scripts/nand-install.sh
Normal file
85
scripts/nand-install.sh
Normal file
|
@ -0,0 +1,85 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check if user is root
|
||||
if [ $(id -u) != "0" ]; then
|
||||
echo "Error: You must be root to run this script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat > .install-exclude <<EOF
|
||||
/dev/*
|
||||
/proc/*
|
||||
/sys/*
|
||||
/media/*
|
||||
/mnt/*
|
||||
/run/*
|
||||
/tmp/*
|
||||
EOF
|
||||
|
||||
exec 2>/dev/null
|
||||
umount /mnt
|
||||
exec 2>&1
|
||||
|
||||
clear_console
|
||||
echo "
|
||||
|
||||
|
||||
# # ## ##### # # # # # ####
|
||||
# # # # # # ## # # ## # # #
|
||||
# # # # # # # # # # # # # #
|
||||
# ## # ###### ##### # # # # # # # # ###
|
||||
## ## # # # # # ## # # ## # #
|
||||
# # # # # # # # # # # ####
|
||||
|
||||
|
||||
|
||||
This script will NUKE / erase your NAND partition and copy content of SD card to it
|
||||
|
||||
"
|
||||
|
||||
echo -n "Proceed (y/n)? (default: y): "
|
||||
read nandinst
|
||||
|
||||
if [ "$nandinst" == "n" ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
FLAG=".reboot-nand-install.pid"
|
||||
|
||||
if [ ! -f $FLAG ]; then
|
||||
echo "Partitioning"
|
||||
apt-get -y -qq install dosfstools
|
||||
(echo y;) | nand-part /dev/nand 32768 'bootloader 32768' 'rootfs 0' >> /dev/null || true
|
||||
echo "
|
||||
Press a key to reboot than run this script again!
|
||||
"
|
||||
touch $FLAG
|
||||
read zagon
|
||||
reboot
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Formatting and optimizing NAND rootfs ... up to 30 sec"
|
||||
mkfs.vfat /dev/nand1 >> /dev/null
|
||||
mkfs.ext4 /dev/nand2 >> /dev/null
|
||||
tune2fs -o journal_data_writeback /dev/nand2 >> /dev/null
|
||||
tune2fs -O ^has_journal /dev/nand2 >> /dev/null
|
||||
e2fsck -f /dev/nand2
|
||||
|
||||
echo "Creating NAND bootfs ... few seconds"
|
||||
mount /dev/nand1 /mnt
|
||||
tar xfz nand1-urejen.tgz -C /mnt/
|
||||
cp /boot/* /mnt/
|
||||
sed -e 's/root=\/dev\/mmcblk0p1/nand_root=\/dev\/nand2/g' /boot/uEnv.txt > /mnt/uEnv.txt
|
||||
umount /mnt
|
||||
|
||||
echo "Creating NAND rootfs ... up to 5 min"
|
||||
mount /dev/nand2 /mnt
|
||||
rsync -aH --exclude-from=.install-exclude / /mnt
|
||||
umount /mnt
|
||||
echo "All done. Press a key to power off, than remove SD and boot from NAND"
|
||||
rm $FLAG
|
||||
rm .install-exclude
|
||||
read konec
|
||||
poweroff
|
Loading…
Reference in a new issue