Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ $# != 2 ]; then
- echo ""
- echo "cim \"Create IMage\" or \"c I'm too lazy to use fsarchiver properly!\""
- echo "v1.1 - Super-simple CLI imaging of single NTFS partitions via fsarchiver"
- echo "by Dan MacDonald aka danboid 2011"
- echo ""
- echo "USAGE: cim <device/path> name.fsa"
- echo ""
- echo "Substitute <device/path> for the device or NFS share to save to eg /dev/sdb1 or hostname:/images"
- echo "and name.fsa for the image name to be saved to the fsas folder"
- echo ""
- echo "cim MUST be run with root priviledges and the source drive will always be /dev/sda1!"
- echo ""
- echo "Note for Windows 7: Make sure you create your single NTFS partition before you install"
- echo "otherwise the W7 installer will create a hidden boot partition which cim/im doesn't deal with"
- echo "Windows 7 installs have to be fixed by the repair tool on the Windows 7 install DVD to get"
- echo "them to boot properly if you haven't prepared it for imaging with sysprep beforehand."
- else
- echo "Ensure /dev/sda1 is unmounted"
- umount /dev/sda1
- FSTYPE=$(fdisk -l | grep $1 | awk '{ print $6 }')
- if [ ${FSTYPE} = "HPFS/NTFS" ]
- then
- echo "Mounting NTFS target drive"
- mount -t ntfs-3g $1 /mnt/ -o force
- else
- echo "Starting rpcbind (NFS) service"
- /etc/init.d/rpcbind start
- sleep 2
- echo "Mounting target location"
- mount $1 /mnt/
- sleep 8
- fi
- if [ ! -f /mnt/fsas ]
- then
- echo "Creating fsas folder on target"
- mkdir /mnt/fsas
- fi
- echo "Imaging sda1 to target"
- fsarchiver -v -s 2000 savefs /mnt/fsas/$2 /dev/sda1
- echo "Unmounting target"
- umount $1
- echo "Stopping rpcbind"
- /etc/init.d/rpcbind stop
- fi
Add Comment
Please, Sign In to add comment