@@ -314,11 +314,13 @@ function fix_etc_hosts {
314314}
315315
316316function fix_disk_layout {
317- # HPCloud and Rackspace performance nodes provide no swap, but do
318- # have ephemeral disks we can use. HPCloud also doesn't have
319- # enough space on / for two devstack installs, so we partition the
320- # disk and mount it on /opt, syncing the previous contents of /opt
321- # over.
317+ # HPCloud and Rackspace performance nodes provide no swap, but do have
318+ # ephemeral disks we can use. For providers with no ephemeral disks, such
319+ # as OVH or Internap, create and use a sparse swapfile on the root
320+ # filesystem.
321+ # HPCloud also doesn't have enough space on / for two devstack installs,
322+ # so we partition the disk and mount it on /opt, syncing the previous
323+ # contents of /opt over.
322324 if [ ` grep SwapTotal /proc/meminfo | awk ' { print $2; }' ` -eq 0 ]; then
323325 if [ -b /dev/xvde ]; then
324326 DEV=' /dev/xvde'
@@ -329,6 +331,7 @@ function fix_disk_layout {
329331 fi
330332 fi
331333 if [ -n " $DEV " ]; then
334+ # If an ephemeral device is available, use it
332335 local swap=${DEV} 1
333336 local lvmvol=${DEV} 2
334337 local optdev=${DEV} 3
@@ -347,6 +350,14 @@ function fix_disk_layout {
347350 sudo find /opt/ -mindepth 1 -maxdepth 1 -exec mv {} /mnt/ \;
348351 sudo umount /mnt
349352 sudo mount ${DEV} 2 /opt
353+ else
354+ # If no ephemeral devices are available, use root filesystem
355+ local lodevice=$( sudo losetup -f)
356+ local swapfile=' /root/swapfile'
357+ sudo dd if=/dev/zero of=${swapfile} bs=1 count=0 seek=8G
358+ sudo mkswap ${swapfile}
359+ sudo losetup ${lodevice} ${swapfile}
360+ sudo swapon ${lodevice}
350361 fi
351362 fi
352363
0 commit comments