Comments (2)
Currently, the file will look as follows:
root@minishift:~# cat /etc/rc.d/automount
#!/bin/sh
echo "automount ...";
LABEL=boot2docker-data
MAGIC="boot2docker, please format-me"
# If there is a partition with `boot2docker-data` as its label, use it and be
# very happy. Thus, you can come along if you feel like a room without a roof.
BOOT2DOCKER_DATA=`blkid -o device -l -t LABEL=$LABEL`
echo $BOOT2DOCKER_DATA
if [ ! -n "$BOOT2DOCKER_DATA" ]; then
echo "Is the disk unpartitioned?, test for the 'boot2docker format-me' string"
# Is the disk unpartitioned?, test for the 'boot2docker format-me' string
UNPARTITIONED_HD=`fdisk -l | grep "doesn't contain a valid partition table" | head -n 1 | sed 's/Disk \(.*\) doesn.*/\1/'`
if [ -n "$UNPARTITIONED_HD" ]; then
# Test for our magic string (it means that the disk was made by ./boot2docker init)
HEADER=`dd if=$UNPARTITIONED_HD bs=1 count=${#MAGIC} 2>/dev/null`
if [ "$HEADER" = "$MAGIC" ]; then
# save the preload userdata.tar file
dd if=$UNPARTITIONED_HD of=/userdata.tar bs=1 count=4096 2>/dev/null
# Create the partition, format it and then mount it
echo "NEW boot2docker managed disk image ($UNPARTITIONED_HD): formatting it for use"
echo "NEW boot2docker managed disk image ($UNPARTITIONED_HD): formatting it for use" > /home/docker/log.log
# Add a swap partition (so Docker doesn't complain about it missing)
(echo n; echo p; echo 2; echo ; echo +1000M ; echo w) | fdisk $UNPARTITIONED_HD
# Let kernel re-read partition table
partprobe
(echo t; echo 82; echo w) | fdisk $UNPARTITIONED_HD
# Let kernel re-read partition table
partprobe
# wait for the partition to actually exist, timeout after about 5 seconds
local timer=0
while [ "$timer" -lt 10 -a ! -b "${UNPARTITIONED_HD}2" ]; do
timer=$((timer + 1))
sleep 0.5
done
mkswap "${UNPARTITIONED_HD}2"
# Add the data partition
(echo n; echo p; echo 1; echo ; echo ; echo w) | fdisk $UNPARTITIONED_HD
# Let kernel re-read partition table
partprobe
# wait for the partition to actually exist, timeout after about 5 seconds
timer=0
while [ "$timer" -lt 10 -a ! -b "${UNPARTITIONED_HD}1" ]; do
timer=$((timer + 1))
sleep 0.5
done
BOOT2DOCKER_DATA=`echo "${UNPARTITIONED_HD}1"`
mkfs.ext4 -i 8192 -L $LABEL $BOOT2DOCKER_DATA
swapon "${UNPARTITIONED_HD}2"
fi
DISK_VENDOR=$(cat /sys/class/block/$(basename $UNPARTITIONED_HD /dev/)/device/vendor /sys/class/block/$(basename $UNPARTITIONED_HD /dev/)/device/model | tr -d "\n")
# Test if disk is "VMware, VMware Virtual S" and empty.
if [ "$DISK_VENDOR" = "VMware, VMware Virtual S" ] || [ "$DISK_VENDOR" = "VMware Virtual disk " ]; then
# Check whether the disk has any known partitions on it
blkid -o device $UNPARTITIONED_HD
if [ $? == 2 ]; then
# As there are no partitions, let's make sure the disk is empty for real
dd if=$UNPARTITIONED_HD of=device_test_file bs=1k count=256 > /dev/null 2>&1
NON_NUL=$(<device_test_file tr -d '\0\n' | wc -c)
if [ $NON_NUL == 0 ]; then
# Create the partition, format it and then mount it
echo "NEW VMware boot2docker managed disk image ($UNPARTITIONED_HD): formatting it for use"
echo "NEW VMware boot2docker managed disk image ($UNPARTITIONED_HD): formatting it for use" > /home/docker/log.log
# Add a swap partition (so Docker doesn't complain about it missing)
(echo n; echo p; echo 2; echo ; echo +1000M ; echo w) | fdisk $UNPARTITIONED_HD
(echo t; echo 82) | fdisk $UNPARTITIONED_HD
mkswap "${UNPARTITIONED_HD}2"
# Add the data partition
(echo n; echo p; echo 1; echo ; echo ; echo w) | fdisk $UNPARTITIONED_HD
BOOT2DOCKER_DATA=`echo "${UNPARTITIONED_HD}1"`
mkfs.ext4 -i 8192 -L $LABEL $BOOT2DOCKER_DATA
swapon "${UNPARTITIONED_HD}2"
else
echo "Disk unpartitioned but something is there... not doing anything"
fi
else
echo "Partition table found on disk, not doing anything"
fi
fi
else
# Pick the first ext4 as a fallback
# TODO: mount all Linux partitions and look for a /var/lib/docker...
BOOT2DOCKER_DATA=`blkid | grep -e 'TYPE="btrfs"' -e 'TYPE="ext4"' | head -n 1 | sed 's/:.*//'`
fi
fi
echo $BOOT2DOCKER_DATA
if [ -n "$BOOT2DOCKER_DATA" ]; then
PARTNAME=`echo "$BOOT2DOCKER_DATA" | sed 's/.*\///'`
echo "mount p:$PARTNAME ..."
mkdir -p /mnt/$PARTNAME
if ! mount $BOOT2DOCKER_DATA /mnt/$PARTNAME 2>/dev/null; then
# for some reason, mount doesn't like to modprobe btrfs
BOOT2DOCKER_FSTYPE=`blkid -o export $BOOT2DOCKER_DATA | grep TYPE= | cut -d= -f2`
modprobe $BOOT2DOCKER_FSTYPE || true
umount -f /mnt/$PARTNAME || true
mount $BOOT2DOCKER_DATA /mnt/$PARTNAME
fi
# Just in case, the links will fail if not
umount -f /var/lib/docker || true
rm -rf /var/lib/docker /var/lib/boot2docker
if [ -d /mnt/$PARTNAME/vm ]; then
# The old behavior - use the entire disk for boot2docker data
ln -s /mnt/$PARTNAME /var/lib/docker
# Give us a link to the new cusomisation location
ln -s /var/lib/docker/vm /var/lib/boot2docker
else
# Detected a disk with a normal linux install (/var/lib/docker + more))
mkdir -p /var/lib
mkdir -p /mnt/$PARTNAME/var/lib/docker
ln -s /mnt/$PARTNAME/var/lib/docker /var/lib/docker
mkdir -p /mnt/$PARTNAME/var/lib/boot2docker
ln -s /mnt/$PARTNAME/var/lib/boot2docker /var/lib/boot2docker
fi
# Make sure /tmp is on the disk too too
rm -rf /mnt/$PARTNAME/tmp || true
mv /tmp /mnt/$PARTNAME/tmp
ln -fs /mnt/$PARTNAME/tmp /tmp
if [ -e "/userdata.tar" ]; then
mv /userdata.tar /var/lib/boot2docker/
fi
ls -l /mnt/$PARTNAME
fi
# /etc dirs are initialised from /usr/local, to allow the user/admin to customise
mkdir -p /var/lib/boot2docker/etc/
echo "automount over."
#!/bin/bash
# Copyright (C) 2016 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Setup a persistent directory for /var/lib/openshift
BOOT2DOCKER_DATA=`blkid -o device -l -t LABEL=boot2docker-data`
PARTNAME=`echo "$BOOT2DOCKER_DATA" | sed 's/.*\///'`
mkdir -p /mnt/$PARTNAME/var/lib/minishift
ln -s /mnt/$PARTNAME/var/lib/minishift /var/lib/minishift
mkdir -p /mnt/$PARTNAME/data
ln -s /mnt/$PARTNAME/data /data
from minishift-b2d-iso.
Resolved by #63
from minishift-b2d-iso.
Related Issues (20)
- Relocate/symlink /opt to /mnt/sda1/opt
- Document release process HOT 1
- Update docker version to sync with our CentOS Docker version HOT 4
- Add GitLab CI runner HOT 1
- Enable NFS installation test HOT 2
- Use bind mounts for persisting /var/lib/docker HOT 1
- Add script to allow IP address to be assigned HOT 4
- Use cached images for socat, ethtool, and conntrack HOT 2
- Refactor automount script to be consistent with handle-user-data
- Oops
- Update test to force delete minishift instance HOT 3
- Update downloading of minishift binary to handle tar.gz subdirectory change HOT 1
- Replace avocado based tests with shell script based
- Upgrade to boot2docker v17.09.0-ce HOT 7
- Update tests to be run in macOS HOT 1
- Create release job
- Cannot find make_iso.sh HOT 6
- Create bind mount for `/var/lib/origin` to persistent volume. HOT 4
- make iso error out during intermediate container build HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minishift-b2d-iso.