save2image 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. #(c) 2003/4 Barry kauler
  3. #2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
  4. echo "This script was written for the particular situation of Puppy"
  5. echo "installed on a USB memory device, usually a Flash card, and"
  6. echo "you want to edit the file image.gz"
  7. echo "The installation of Puppy on a Flash card is such that image.gz"
  8. echo "is just a file on the card, along with vmlinuz and all the files"
  9. echo "and folders of your home directory."
  10. echo "When Puppy is booted, the Flash card is mounted on /root, and"
  11. echo "image.gz can be found at /root/image.gz"
  12. echo " "
  13. RAMDSKSIZE="`cat /etc/ramdisksize`"
  14. # the home device, probably sda1, was saved into /tmp/homedevice
  15. # during bootup, by /etc/rc.d/rc.sysinit
  16. # if mounted successfully, otherwise the file doesn't exist...
  17. if [ -e /tmp/homedevice ];then
  18. SDX1="`cat /tmp/homedevice`"
  19. echo "Your home device is $SDX1"
  20. else
  21. echo "Home device not accessable. Exiting."
  22. exit 0
  23. fi
  24. # The flash card has image.gz, which has the compressed Puppy
  25. # root filesystem. This script enables you to copy any files
  26. # to it, making them a permanent part of Puppy.
  27. echo "Uncompressing image.gz to /dev/ram1..."
  28. gunzip -c /root/image.gz | dd of=/dev/ram1
  29. echo "Need to be a bit cautious here. Older versions of Puppy, before"
  30. echo "v0.7.6 I think, used the minix filesystem for image.gz, whereas"
  31. echo "Puppy is now using ext2."
  32. echo "this script assumes that image.gz is a ext2 filesystem -- if it"
  33. echo "is minix or something else, you will need to edit this script."
  34. echo '(be careful, the filesystem used for image.gz is not necessarily'
  35. echo ' the same as the filesystem of the partition mounted on /root!)'
  36. echo " "
  37. echo "Mounting /dev/ram1 on /mnt/ram1..."
  38. mount -t ext2 /dev/ram1 /mnt/ram1
  39. echo "Use a file-manager such as Rox to copy any files to"
  40. echo "/mnt/ram1. When finished, Press ENTER key to continue..."
  41. echo -n '(or CTRL-C to abort): '
  42. read VAL1
  43. cd /
  44. umount -f /mnt/ram1
  45. echo "Copying /dev/ram1 to home device..."
  46. # /dev/sda1 mounted at /root during boot...
  47. dd if=/dev/ram1 bs=1k count=$RAMDSKSIZE | gzip - > /root/image.gz
  48. sync
  49. echo " "
  50. echo "Freeing memory used for /dev/ram1..."
  51. freeramdisk /dev/ram1
  52. echo "Done"