Skip to content

Instantly share code, notes, and snippets.

@eduardocereto
Forked from fairchild/bundle-to-ebs.sh
Created December 18, 2009 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardocereto/259646 to your computer and use it in GitHub Desktop.
Save eduardocereto/259646 to your computer and use it in GitHub Desktop.
bundle s3 AMI to EBS
#!/bin/bash
mkdir /mnt/ebs
mkfs.ext3 ${EBS_DEVICE}
mount ${EBS_DEVICE} /mnt/ebs
mkdir /mnt/tmp
rsync -av --exclude=/mnt/ --exclude=/proc/ / /mnt/tmp/
rm /mnt/tmp/root/.bash_history
rm /mnt/tmp/home/*/.bash_history
rm /mnt/tmp/etc/ssh/ssh_host_*
rm /mnt/tmp/etc/ssh/moduli
rm /mnt/tmp/etc/udev/rules.d/*persistent-net.rules
#ensure that ami init scripts will be run
chmod u+x /mnt/ebs/etc/init.d/ec2-init-user-data
rm /mnt/ebs/var/lib/ec2
#clear out log files
cd /mnt/tmp/var/log
for i in `ls ./**/*`; do
echo $i && echo -n> $i
done
# rsync --stats -avx --exclude-from=excludes.txt / /mnt/ebs/
cd /mnt/tmp
# tar cpS ./ | cpipe -vt -b 1024 | gzip -c | tar zxpS -C /mnt/ebs/
tar -cSf - -C ./ . | tar xvf - -C /mnt/ebs/
mv /mnt/ebs/mnt/tmp/* /mnt/ebs/ #FIX THIS UGLYNESS
umount /mnt/ebs
echo ''
echo "
sudo -s
mkdir /mnt/ebs
mkfs.ext3 ${EBS_DEVICE}
mount ${EBS_DEVICE} /mnt/ebs
mkdir /mnt/tmp
rsync -av --exclude=/mnt/ --exclude=/proc/ / /mnt/tmp/
rm /mnt/tmp/root/.bash_history
rm /mnt/tmp/home/*/.bash_history
rm /mnt/tmp/etc/ssh/ssh_host_*
rm /mnt/tmp/etc/ssh/moduli
rm /mnt/tmp/etc/udev/rules.d/*persistent-net.rules
#ensure that ami init scripts will be run
chmod u+x /mnt/ebs/etc/init.d/ec2-init-user-data
rm /mnt/ebs/var/lib/ec2
#clear out log files
cd /mnt/tmp/var/log
for i in `ls ./**/*`; do
echo $i && echo -n> $i
done
# rsync --stats -avx --exclude-from=excludes.txt / /mnt/ebs/
cd /mnt/tmp
# tar cpS ./ | cpipe -vt -b 1024 | gzip -c | tar zxpS -C /mnt/ebs/
tar -cSf - -C ./ . | tar xvf - -C /mnt/ebs/
mv /mnt/ebs/mnt/tmp/* /mnt/ebs/ #FIX THIS UGLYNESS
umount /mnt/ebs
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment