systemd wait for xvdf

215 views
Skip to first unread message

Mark Olliver

unread,
Mar 13, 2015, 11:42:57 AM3/13/15
to coreo...@googlegroups.com
I have the following stanza in my user-data for AWS

          - name: format-docker-ephemeral.service
            command: start
            content: |
              [Unit]
              Description=Formats the ephemeral drive
              After=dev-{{ data_disk }}.device
              [Service]
              Type=oneshot
              RemainAfterExit=yes
              ExecStartPre=sleep 120
              ExecStartPre=/usr/sbin/wipefs -f {{ data_disk }}
              ExecStart=/usr/sbin/mkfs.btrfs -f {{ data_disk }}
          - name: var-lib-docker.mount
            command: start
            content: |
              [Unit]
              Description=Mount ephemeral to /var/lib/docker
              After=format-docker-ephemeral.service
              Before=docker.service
              [Mount]
              What=/dev/xvdf
              Where=/var/lib/docker
              Type=btrfs


However, these two jobs fail as it appears /dev/xvdf does not get attached even though i tell it to wait for the attach and then sleep for two mins. Also docker starts up even though I have told it mount should be first. I am not so bothered by that as the restart will fix up where docker looks for data but not waiting on xvdf is a problem as I cant give the additional ebs storage space needed for docker to run.

Any ideas ?? 

I am using ami-8097d4e8 if it helps

Thanks

Mark

Spencer Brown

unread,
Mar 16, 2015, 7:32:21 PM3/16/15
to coreo...@googlegroups.com
I just solved a problem like this, my attached volume was not ephemeral so I did a ConditionFirstBoot=true so it would only run once when the instance was first created.

What is the status of your format-docker-ephemeral.service? Did it run successfully? (systemctl status) What error messages did you get?

I did not use wipefs, I'm wondering whether mkfs.btrfs would even work after wipefs erases the partition.  Don't you have to create a partition first? I used fdisk for this since parted didn't work very well in automated mode.

Michael Marineau

unread,
Mar 16, 2015, 8:06:42 PM3/16/15
to Mark Olliver, coreos-user
Off the top of my head I'm not sure what all may be an issue here but
it may help to specify `Requires=` in addition to After=, the After=
is only going to have an impact of systemd already knows about
dev-foo.device but if dev-foo.device doesn't exist just yet it will
not wait for it. Requires= will get the unit to wait for the device to
appear.
> --
> You received this message because you are subscribed to the Google Groups
> "CoreOS User" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to coreos-user...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages