Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
Change the UUID of the root volume on first boot. Fixes #40
Browse files Browse the repository at this point in the history
  • Loading branch information
andsens committed Nov 18, 2012
1 parent 5b8ef8c commit d0c3fbd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
### 2012-11-18 Anders Ingemann <[email protected]> ###

#### Major changes: ####
* Add `change-root-uuid` script
(see [this issue for more info](https://github.com/andsens/ec2debian-build-ami/issues/40))
* Remove contrib and non-free from apt/sources.list
(thanks to zack for finding this and James for the patch)

Expand Down
28 changes: 28 additions & 0 deletions init.d/change-root-uuid
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: change-root-uuid
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Description: Changes the UUID of the root volume
### END INIT INFO

prog=$(basename $0)
logger="logger -t $prog"

device_path="/dev/xvda1"

filesystem=`blkid | grep $device_path | sed 's#\(.*\):.*TYPE="\(.*\)".*#\2#'`

case $filesystem in
ext2) tune2fs -U random $device_path ;;
ext3) tune2fs -U random $device_path ;;
ext4) tune2fs -U random $device_path ;;
*) $logger "The filesystem $filesystem was not recognized. Unable to change its UUID." ;;
esac

# Disable this script, it may only run once
insserv -r $0
8 changes: 8 additions & 0 deletions tasks/50-ec2-scripts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ init_scripts+=("$scriptdir/init.d/generate-ssh-hostkeys")
init_scripts+=("$scriptdir/init.d/ec2-get-credentials")
init_scripts+=("$scriptdir/init.d/ec2-run-user-data")
init_scripts+=("$scriptdir/init.d/expand-volume")

case $filesystem in
# xfs cannot change the UUID on mounted volumes
xfs) ;;
ext2) init_scripts+=("$scriptdir/init.d/change-root-uuid") ;;
ext3) init_scripts+=("$scriptdir/init.d/change-root-uuid") ;;
ext4) init_scripts+=("$scriptdir/init.d/change-root-uuid") ;;
esac

0 comments on commit d0c3fbd

Please sign in to comment.