InstallToInternal.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. #Install PrawnOS to the internal emmc, this will partition the internal emmc
  3. #and erase ALL data on it
  4. # This file is part of PrawnOS (http://www.prawnos.com)
  5. # Copyright (c) 2018 Hal Emmerich <hal@halemmerich.com>
  6. # PrawnOS is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License version 2
  8. # as published by the Free Software Foundation.
  9. # PrawnOS is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
  15. RESOURCES=/InstallResources
  16. 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
  17. echo
  18. if [[ $REPLY =~ ^[Yy]$ ]]
  19. then
  20. #disable dmesg, writing the partition map tries to write the the first gpt table, which is unmodifiable
  21. dmesg -D
  22. echo Writing partition map
  23. sfdisk /dev/mmcblk2 < $RESOURCES/mmc.partmap
  24. dmesg -E
  25. echo Writing kernel partition
  26. dd if=/dev/sda1 of=/dev/mmcblk2p1
  27. echo Writing Filesystem, this will take about 4 minutes...
  28. mkfs.ext4 -F -b 1024 -m 0 -O ^has_journal /dev/mmcblk2p2
  29. mkdir -p /mnt/mmc/
  30. mount /dev/mmcblk2p2 /mnt/mmc
  31. rsync -ah --info=progress2 --info=name0 --numeric-ids -x / /mnt/mmc/
  32. #Install a base fstab
  33. echo "/dev/mmcblk2p2 / ext4 defaults,noatime 0 1" > /mnt/mmc/etc/fstab
  34. umount /dev/mmcblk2
  35. echo Running fsck
  36. e2fsck -p -f /dev/mmcblk2p2
  37. echo Rebooting... Please remove the usb drive once shutdown is complete
  38. reboot
  39. fi
  40. echo Exiting