2018-09-06 01:35:33 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#Install PrawnOS to the internal emmc, this will partition the internal emmc
|
|
|
|
#and erase ALL data on it
|
|
|
|
|
|
|
|
|
2018-10-11 22:09:25 +02:00
|
|
|
# This file is part of PrawnOS (http://www.prawnos.com)
|
|
|
|
# Copyright (c) 2018 Hal Emmerich <hal@halemmerich.com>
|
|
|
|
|
|
|
|
# PrawnOS is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
# PrawnOS is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2018-09-06 01:35:33 +02:00
|
|
|
RESOURCES=/InstallResources
|
|
|
|
|
|
|
|
read -p "This will ERASE ALL DATA ON THE INTERNAL STORAGE (EMMC) and reboot when finished, do you want to continue? [Y/n]" -n 1 -r
|
|
|
|
echo
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
2018-10-24 23:22:45 +02:00
|
|
|
#disable dmesg, writing the partition map tries to write the the first gpt table, which is unmodifiable
|
|
|
|
dmesg -D
|
|
|
|
echo Writing partition map
|
2019-01-11 00:35:26 +01:00
|
|
|
DISK_SZ="$(blockdev --getsz /dev/mmcblk2)"
|
|
|
|
echo Total disk size is: $DISK_SZ
|
|
|
|
if [ $DISK_SZ = 30785536 ]
|
|
|
|
then
|
|
|
|
echo Detected Emmc Type 1
|
|
|
|
sfdisk /dev/mmcblk2 < $RESOURCES/mmc.partmap
|
|
|
|
|
|
|
|
elif [ $DISK_SZ = 30777344 ]
|
|
|
|
then
|
|
|
|
echo Detected Emmc Type 2
|
|
|
|
sfdisk /dev/mmcblk2 < $RESOURCES/mmc_type2.partmap
|
|
|
|
else
|
|
|
|
echo ERROR! Not a known EMMC type, please open an issue on github or send SolidHal an email with the Total disk size reported above
|
|
|
|
echo Try a fallback value? This will allow installation to continue, at the cost of a very small amoutnt of disk space. This may not work.
|
|
|
|
read -p "[Y/n]" -n 1 -r
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
|
|
|
echo Trying Emmc Type 2
|
|
|
|
sfdisk /dev/mmcblk2 < $RESOURCES/mmc_type2.partmap
|
|
|
|
else
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
2018-10-24 23:22:45 +02:00
|
|
|
dmesg -E
|
2018-09-06 01:35:33 +02:00
|
|
|
echo Writing kernel partition
|
|
|
|
dd if=/dev/sda1 of=/dev/mmcblk2p1
|
2018-09-07 01:55:46 +02:00
|
|
|
echo Writing Filesystem, this will take about 4 minutes...
|
2018-11-05 00:51:54 +01:00
|
|
|
mkfs.ext4 -F -b 1024 -m 0 -O ^has_journal /dev/mmcblk2p2
|
|
|
|
mkdir -p /mnt/mmc/
|
2018-11-07 22:24:57 +01:00
|
|
|
mount /dev/mmcblk2p2 /mnt/mmc
|
2018-11-05 00:51:54 +01:00
|
|
|
rsync -ah --info=progress2 --info=name0 --numeric-ids -x / /mnt/mmc/
|
2018-11-05 01:11:20 +01:00
|
|
|
#Install a base fstab
|
2018-11-07 18:54:17 +01:00
|
|
|
echo "/dev/mmcblk2p2 / ext4 defaults,noatime 0 1" > /mnt/mmc/etc/fstab
|
2018-11-05 00:51:54 +01:00
|
|
|
umount /dev/mmcblk2
|
|
|
|
echo Running fsck
|
2018-09-07 01:55:46 +02:00
|
|
|
e2fsck -p -f /dev/mmcblk2p2
|
2018-09-06 01:35:33 +02:00
|
|
|
echo Rebooting... Please remove the usb drive once shutdown is complete
|
2018-09-06 04:39:57 +02:00
|
|
|
reboot
|
2018-09-06 01:35:33 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo Exiting
|