Guest User

Untitled

a guest
Apr 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #!/bin/bash
  2. if [ $# != 2 ]; then
  3. echo ""
  4. echo "cim \"Create IMage\" or \"c I'm too lazy to use fsarchiver properly!\""
  5. echo "v1.1 - Super-simple CLI imaging of single NTFS partitions via fsarchiver"
  6. echo "by Dan MacDonald aka danboid 2011"
  7. echo ""
  8. echo "USAGE: cim <device/path> name.fsa"
  9. echo ""
  10. echo "Substitute <device/path> for the device or NFS share to save to eg /dev/sdb1 or hostname:/images"
  11. echo "and name.fsa for the image name to be saved to the fsas folder"
  12. echo ""
  13. echo "cim MUST be run with root priviledges and the source drive will always be /dev/sda1!"
  14. echo ""
  15. echo "Note for Windows 7: Make sure you create your single NTFS partition before you install"
  16. echo "otherwise the W7 installer will create a hidden boot partition which cim/im doesn't deal with"
  17. echo "Windows 7 installs have to be fixed by the repair tool on the Windows 7 install DVD to get"
  18. echo "them to boot properly if you haven't prepared it for imaging with sysprep beforehand."
  19. else
  20. echo "Ensure /dev/sda1 is unmounted"
  21. umount /dev/sda1
  22. FSTYPE=$(fdisk -l | grep $1 | awk '{ print $6 }')
  23. if [ ${FSTYPE} = "HPFS/NTFS" ]
  24. then
  25. echo "Mounting NTFS target drive"
  26. mount -t ntfs-3g $1 /mnt/ -o force
  27. else
  28. echo "Starting rpcbind (NFS) service"
  29. /etc/init.d/rpcbind start
  30. sleep 2
  31. echo "Mounting target location"
  32. mount $1 /mnt/
  33. sleep 8
  34. fi
  35. if [ ! -f /mnt/fsas ]
  36. then
  37. echo "Creating fsas folder on target"
  38. mkdir /mnt/fsas
  39. fi
  40. echo "Imaging sda1 to target"
  41. fsarchiver -v -s 2000 savefs /mnt/fsas/$2 /dev/sda1
  42. echo "Unmounting target"
  43. umount $1
  44. echo "Stopping rpcbind"
  45. /etc/init.d/rpcbind stop
  46. fi
Add Comment
Please, Sign In to add comment