home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 August - Disc 1 / PCNET_CD_2006_08_1.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / sbin / save2image < prev    next >
Encoding:
Text File  |  2003-12-20  |  2.7 KB  |  86 lines

  1. #!/bin/sh
  2. #(c) 2003/4 Barry kauler www.goosee.com/puppy
  3.  
  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.  
  14. #RAMDSKSIZE=49152
  15. #RAMDSKSIZE=36864
  16. RAMDSKSIZE="`cat /etc/ramdisksize`"
  17.  
  18. # the home device, probably sda1, was saved into /tmp/homedevice
  19. # during bootup, by /etc/rc.d/rc.sysinit
  20. # if mounted successfully, otherwise the file doesn't exist...
  21. if [ -e /tmp/homedevice ];then
  22.  SDX1="`cat /tmp/homedevice`"
  23.  echo "Your home device is $SDX1"
  24. else
  25.  echo "Home device not accessable. Exiting."
  26.  exit 0
  27. fi
  28.  
  29. # The flash card has image.gz, which has the compressed Puppy
  30. # root filesystem. This script enables you to copy any files
  31. # to it, making them a permanent part of Puppy.
  32.  
  33. # echo "Loading kernel modules for USB Flash..."
  34. # modprobe usb-storage
  35. # modprobe usb-uhci
  36. # ...already done in /etc/rc.d/rc.modules.
  37.  
  38. # echo "Making 48M minix f.s. on /dev/ram1..."
  39. # mkfs.minix -c /dev/ram1 49152
  40.  
  41. #Puppy now mounts at boot, onto /root...
  42. #echo "Mounting flash card /dev/sda1 on /mnt/flash..."
  43. #mount -t umsdos /dev/sda1 /mnt/flash
  44. #if [ "$?" -ne 0 ];then
  45. #echo "FLASH CARD NOT AT /dev/sda1, CANNOT MOUNT"
  46. #exit 0
  47. #fi
  48. #umssync /mnt/flash
  49.  
  50. echo "Uncompressing image.gz to /dev/ram1..."
  51. gunzip -c /root/image.gz | dd of=/dev/ram1
  52.  
  53. echo "Need to be a bit cautious here. Older versions of Puppy, before"
  54. echo "v0.7.6 I think, used the minix filesystem for image.gz, whereas"
  55. echo "Puppy is now using ext2."
  56. echo "this script assumes that image.gz is a ext2 filesystem -- if it"
  57. echo "is minix or something else, you will need to edit this script."
  58. echo '(be careful, the filesystem used for image.gz is not necessarily'
  59. echo ' the same as the filesystem of the partition mounted on /root!)'
  60. echo " "
  61.  
  62. echo "Mounting /dev/ram1 on /mnt/ram1..."
  63. mount -t ext2 /dev/ram1 /mnt/ram1
  64.  
  65. echo "Use a file-manager such as Rox to copy any files to"
  66. echo "/mnt/ram1. When finished, Press ENTER key to continue..."
  67. echo -n '(or CTRL-C to abort): '
  68. read VAL1
  69.  
  70. cd /
  71. umount -f /mnt/ram1
  72. echo "Copying /dev/ram1 to home device..."
  73. # /dev/sda1 mounted at /root during boot...
  74. dd if=/dev/ram1 bs=1k count=$RAMDSKSIZE | gzip - > /root/image.gz
  75. sync
  76. #umount /mnt/flash
  77.  
  78. # echo "Removing USB kernel modules..."
  79. # rmmod usb-uhci
  80. # rmmod usb-storage
  81.  
  82. echo " "
  83. echo "Freeing memory used for /dev/ram1..."
  84. freeramdisk /dev/ram1
  85. echo "Done"
  86.