[ubuntu-cloud] On lucid/10.04: setting up /mnt ephemeral

Scott Moser smoser at ubuntu.com
Mon Nov 7 15:28:09 UTC 2011

On Fri, 4 Nov 2011, Daniel Farina wrote:

> Hello List,
> I have been stymied by an attempt to deterministically, correctly, and
> cleanly create a directory on the ephemeral disk on boot-up on Ubuntu
> Lucid (10.04) and set its permissions by using an additional upstart
> file in /etc/init like:
> # mounted-ephemeral-setup.conf - Set-up /mnt which is an ephemeral disk
> #
> # Sets up the layout and permissions of subdirectories in /mnt for use
> # at run-time.
> description	"Set up /mnt ephemeral"
> start on mounted MOUNTPOINT=/mnt
> task
> script
>     SUBDIR = "${MOUNTPOINT}"/adirectory
>     mkdir "${SUBDIR}"/
>     chown -R user:group "${SUBDIR}"
>     chmod go-rwx "${SUBDIR}"
> end script

I'd suggest doing:
 set -x
   date -R
   mkdir "${SUBDIR}"
 } >/root/my.log 2>&2
 end script

That will get you more debugging output.  the first thing that you will
probably find is that the 'mkdir $SUBDIR' is failing because the directory
already exists on anything other than the first boot.  That will exit the
script, as upstart scripts start with 'set -e'.

> I notice that I never seem to create the directory on a start/stop
> cycle of my instance, although an operating system level "restart"
> seems to do the trick.  I looked around for functionality in
> cloud-init, but its exact functionality and intended hooks are still
> pretty impenetrable.
> My starting point was the /tmp cleaning upstart job, which is why I
> believe this may have something to do with a ephemeral-disk specific
> problem treated by cloud-init.
> As a bonus, I'd like to format that ephemeral disk as btrfs rather
> than use the ext3 default, but right now I'm just trying to prepare
> /mnt in a non-hacky way.

You can configure cloud-init's  mounting of this device off via
cloud-config, something like:
 - [ ephemeral0, null ]

Then, cloud-init will not mount it, and you can add whatever mechanism
you'd like to mount it.  mkfs.ext3 is slow, so I never added "make the
filesystem" code to cloud-init.

More information about the Ubuntu-cloud mailing list