Using pivot_root and chroot to change the root directory upon bootup
I am using Amazon Web Services EC2 EBS (elastic block storage), which just came out. This provides a means of making a permanent file system for a cloud computing server but in order to do this it is necessary to mount a new filesystem and then to change the root directory to that filesystem. In order to do this, so far I have gathered that something like this may work (replacing the original /sbin/init file with a shell script containing the code below):
mount /dev/sdi /real_root
pivot_root . old_root
exec chroot . /sbin/init
I have tried this but I lose the machine (instance), so far I have been unable to figure out what is going wrong, I would appreciate if anyone has any advice.