mirror of
https://github.com/rancher/os.git
synced 2025-09-15 22:49:08 +00:00
add rancher/os (os-installer) Dockerfile
and installer scripts
This commit is contained in:
43
scripts/installer/set-disk-partitions
Executable file
43
scripts/installer/set-disk-partitions
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
DEVICE=${1}
|
||||
|
||||
if [[ -z $DEVICE ]]; then
|
||||
echo "Need to Pass a device name as arg1." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PARTITION_COUNT=$(grep $(echo $DEVICE | cut -d '/' -f3) /proc/partitions | wc -l)
|
||||
if [ "$PARTITION_COUNT" -gt "1" ]; then
|
||||
echo "Device ${DEVICE} already partitioned!"
|
||||
echo "Checking to see if it is mounted"
|
||||
|
||||
# Check this container first...
|
||||
if grep -q "${DEVICE}" /proc/mounts; then
|
||||
echo "Device is mounted, we can not repartition" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check other system containers...
|
||||
for container in $(system-docker ps -q); do
|
||||
if system-docker exec $container grep -q "${DEVICE}" /proc/mounts; then
|
||||
echo "Device is mounted in system container ${container}, we can not repartition" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
dd if=/dev/zero of=${DEVICE} bs=512 count=1
|
||||
partprobe ${DEVICE}
|
||||
fi
|
||||
|
||||
fdisk ${DEVICE} <<EOF
|
||||
n
|
||||
p
|
||||
1
|
||||
|
||||
|
||||
w
|
||||
EOF
|
Reference in New Issue
Block a user