code.fastix.org

Dateiansicht:

Datei:Projekte -> Linux:ubuntu-for-raspberry-installer -> rpi2-create-image.sh
md5:19f53025aaa4fe15a43ab5c7cb341b7a
sha1:6ae13aca781a9a0625f1b18bf9be4d29276322a5
  1. #!/usr/bin/sudo /bin/sh
  2.  
  3. set -x
  4. if [ -z "$BUILD_HOSTNAME" ]; then
  5. . ./rpi2-settings.sh
  6. fi
  7.  
  8. export DATE="$(date +%Y-%m-%d)"
  9.  
  10. dd if=/dev/zero of="${BASEDIR}/${DATE}-ubuntu-${RELEASE}.img" bs=1024 count=7340032
  11. cat rpi2-create-fdisk-keys_with_swap | fdisk "${BASEDIR}/${DATE}-ubuntu-${RELEASE}.img"
  12. VFAT_LOOP="$(losetup -o 1M --sizelimit 64M -f --show ${BASEDIR}/${DATE}-ubuntu-${RELEASE}.img)"
  13. mkfs.vfat "${VFAT_LOOP}"
  14. EXT4_LOOP="$(losetup -o 65M --sizelimit 8000000000 -f --show ${BASEDIR}/${DATE}-ubuntu-${RELEASE}.img)"
  15. mkfs.ext4 "${EXT4_LOOP}"
  16. MOUNTDIR="${BUILDDIR}/mount"
  17. mkdir -p "${MOUNTDIR}"
  18. mount "${EXT4_LOOP}" "${MOUNTDIR}"
  19. mkdir -p "${MOUNTDIR}/boot/firmware"
  20. mount "${VFAT_LOOP}" "${MOUNTDIR}/boot/firmware"
  21. rsync -a "$R/" "${MOUNTDIR}/"
  22. df -h "${EXT4_LOOP}"
  23. umount "${MOUNTDIR}/boot/firmware"
  24. umount "${MOUNTDIR}"
  25. losetup -d "${EXT4_LOOP}"
  26. losetup -d "${VFAT_LOOP}"
  27. if which bmaptool; then
  28.   bmaptool create -o "${BASEDIR}/${DATE}-ubuntu-${RELEASE}.bmap" "${BASEDIR}/${DATE}-ubuntu-${RELEASE}.img"
  29. fi
  30. ls -lh "${BASEDIR}"
  31. set +x
  32. echo ""
  33. echo "Done. Image created:"
  34. echo "p" | fdisk -u  "${BASEDIR}/${DATE}-ubuntu-${RELEASE}.img"
  35. echo ""
  36. echo "Now you can use:"
  37. echo ""
  38. echo "sudo  bmaptool copy --bmap \"${BASEDIR}/${DATE}-ubuntu-${RELEASE}.bmap\" \"${BASEDIR}/${DATE}-ubuntu-${RELEASE}.img\" /dev/mmcblk0"
  39. echo ""
  40. echo "... to create the card. If the card is greater then 8GB, then you shold use"
  41. echo ""
  42. echo "cat rpi2-resize-ext4-fdisk-keys_with_swap | sudo fdisk /dev/mmcblk0"
  43. echo ""
  44. echo "and"
  45. echo "resize2fs /dev/mmcblk0p3"
  46. echo "fsck.ext4 -p -y  /dev/mmcblk0p3"
  47. echo ""
  48. echo "to resize the linux-partition."
  49. echo ""
  50.  
  51. # Done!