Andy Bavier | 188aff1 | 2018-05-18 05:43:55 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright 2017-present Open Networking Foundation |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | ############################################### |
| 18 | # Disk setup and symlinks for a CloudLab node # |
| 19 | ############################################### |
| 20 | |
| 21 | # Don't do anything if not a CloudLab node |
| 22 | [ ! -d /usr/local/etc/emulab ] && return |
| 23 | |
| 24 | # Mount extra space, if haven't already |
| 25 | if [ ! -d /mnt/extra ] |
| 26 | then |
| 27 | sudo mkdir -p /mnt/extra |
| 28 | |
| 29 | # for NVME SSD on Utah Cloudlab, not supported by mkextrafs |
| 30 | if df | grep -q nvme0n1p1 && [ -e /usr/testbed/bin/mkextrafs ] |
| 31 | then |
| 32 | # set partition type of 4th partition to Linux, ignore errors |
| 33 | echo -e "t\\n4\\n82\\np\\nw\\nq" | sudo fdisk /dev/nvme0n1 || true |
| 34 | |
| 35 | sudo mkfs.ext4 /dev/nvme0n1p4 |
| 36 | echo "/dev/nvme0n1p4 /mnt/extra/ ext4 defaults 0 0" | sudo tee -a /etc/fstab |
| 37 | sudo mount /mnt/extra |
| 38 | mount | grep nvme0n1p4 || (echo "ERROR: NVME mkfs/mount failed, exiting!" && exit 1) |
| 39 | |
| 40 | elif [ -e /usr/testbed/bin/mkextrafs ] # if on Clemson/Wisconsin Cloudlab |
| 41 | then |
| 42 | # Sometimes this command fails on the first try |
| 43 | sudo /usr/testbed/bin/mkextrafs -s 1 -r /dev/sdb -qf "/mnt/extra/" || sudo /usr/testbed/bin/mkextrafs -s 1 -r /dev/sdb -qf "/mnt/extra/" |
| 44 | |
| 45 | # Check that the mount succeeded (sometimes mkextrafs succeeds but device not mounted) |
| 46 | mount | grep sdb || (echo "ERROR: mkextrafs failed, exiting!" && exit 1) |
| 47 | fi |
| 48 | fi |
| 49 | |
| 50 | for DIR in docker kubelet openstack-helm nova |
| 51 | do |
| 52 | sudo mkdir -p /mnt/extra/$DIR |
| 53 | sudo chmod -R a+rwx /mnt/extra/$DIR |
| 54 | [ ! -e /var/lib/$DIR ] && sudo ln -s /mnt/extra/$DIR /var/lib/$DIR |
| 55 | done |