mirror of
https://github.com/rancher/os.git
synced 2025-08-12 12:02:22 +00:00
commit
05b8587849
20
cmd/control/install.go
Normal file → Executable file
20
cmd/control/install.go
Normal file → Executable file
@ -29,7 +29,10 @@ var installCommand = cli.Command{
|
|||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "install-type, t",
|
Name: "install-type, t",
|
||||||
Usage: `generic: (Default) Creates 1 ext4 partition and installs RancherOS
|
Usage: `generic: (Default) Creates 1 ext4 partition and installs RancherOS
|
||||||
amazon-ebs: Installs RancherOS and sets up PV-GRUB`,
|
amazon-ebs: Installs RancherOS and sets up PV-GRUB
|
||||||
|
syslinux: partition and format disk (mbr), then install RnancherOS and setup Syslinux
|
||||||
|
gptsyslinux: partition and format disk (gpt), then install RnancherOS and setup Syslinux
|
||||||
|
`,
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "cloud-config, c",
|
Name: "cloud-config, c",
|
||||||
@ -105,10 +108,19 @@ func runInstall(image, installType, cloudConfig, device, append string, force, r
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
diskType := "msdos"
|
||||||
|
if installType == "gptsyslinux" {
|
||||||
|
diskType = "gpt"
|
||||||
|
}
|
||||||
|
|
||||||
if installType == "generic" {
|
if installType == "generic" ||
|
||||||
cmd := exec.Command("system-docker", "run", "--net=host", "--privileged", "--volumes-from=all-volumes",
|
installType == "syslinux" ||
|
||||||
"--entrypoint=/scripts/set-disk-partitions", image, device)
|
installType == "gptsyslinux" {
|
||||||
|
|
||||||
|
cmd := exec.Command("system-docker", "run",
|
||||||
|
"--net=host", "--privileged", "--volumes-from=all-volumes",
|
||||||
|
"--entrypoint=/scripts/set-disk-partitions",
|
||||||
|
image, device, diskType)
|
||||||
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
|
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -5,7 +5,9 @@ SCRIPTS_DIR=$(dirname ${0})
|
|||||||
|
|
||||||
VERSION=${VERSION:?"VERSION not set"}
|
VERSION=${VERSION:?"VERSION not set"}
|
||||||
|
|
||||||
while getopts "i:f:c:d:t:r:o:p:ka:" OPTION
|
MBR_FILE=mbr.bin
|
||||||
|
|
||||||
|
while getopts "i:f:c:d:t:r:o:p:ka:g" OPTION
|
||||||
do
|
do
|
||||||
case ${OPTION} in
|
case ${OPTION} in
|
||||||
i) DIST="$OPTARG" ;;
|
i) DIST="$OPTARG" ;;
|
||||||
@ -18,11 +20,16 @@ do
|
|||||||
k) KEXEC=y ;;
|
k) KEXEC=y ;;
|
||||||
a) APPEND="$OPTARG" ;;
|
a) APPEND="$OPTARG" ;;
|
||||||
t) ENV="$OPTARG" ;;
|
t) ENV="$OPTARG" ;;
|
||||||
|
g) MBR_FILE=gptmbr.bin ;;
|
||||||
*) exit 1 ;;
|
*) exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
[[ "$ARCH" == "arm" && "$ENV" != "rancher-upgrade" ]] && ENV=arm
|
[[ "$ARCH" == "arm" && "$ENV" != "rancher-upgrade" ]] && ENV=arm
|
||||||
|
|
||||||
|
if [[ "$ENV" == "gptsyslinux" ]]; then
|
||||||
|
MBR_FILE="gptmbr.bin"
|
||||||
|
fi
|
||||||
|
|
||||||
DIST=${DIST:-/dist}
|
DIST=${DIST:-/dist}
|
||||||
CLOUD_CONFIG=${CLOUD_CONFIG:-"${SCRIPTS_DIR}/conf/empty.yml"}
|
CLOUD_CONFIG=${CLOUD_CONFIG:-"${SCRIPTS_DIR}/conf/empty.yml"}
|
||||||
CONSOLE=tty0
|
CONSOLE=tty0
|
||||||
@ -85,15 +92,15 @@ create_boot_dirs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_syslinux() {
|
install_syslinux() {
|
||||||
dd bs=440 count=1 if=/usr/lib/syslinux/mbr/mbr.bin of=${DEVICE}
|
dd bs=440 count=1 if=/usr/lib/syslinux/mbr/${MBR_FILE} of=${DEVICE}
|
||||||
cp /usr/lib/syslinux/modules/bios/* ${BASE_DIR}/${BOOT}syslinux
|
cp /usr/lib/syslinux/modules/bios/* ${BASE_DIR}/${BOOT}syslinux/
|
||||||
extlinux --install ${BASE_DIR}/${BOOT}syslinux
|
extlinux --install ${BASE_DIR}/${BOOT}syslinux
|
||||||
}
|
}
|
||||||
|
|
||||||
install_syslinux_raid() {
|
install_syslinux_raid() {
|
||||||
dd bs=440 count=1 if=/usr/lib/syslinux/mbr/mbr.bin of=/dev/sda
|
dd bs=440 count=1 if=/usr/lib/syslinux/mbr/${MBR_FILE} of=/dev/sda
|
||||||
dd bs=440 count=1 if=/usr/lib/syslinux/mbr/mbr.bin of=/dev/sdb
|
dd bs=440 count=1 if=/usr/lib/syslinux/mbr/${MBR_FILE} of=/dev/sdb
|
||||||
cp /usr/lib/syslinux/modules/bios/* ${BASE_DIR}/${BOOT}syslinux
|
cp /usr/lib/syslinux/modules/bios/* ${BASE_DIR}/${BOOT}syslinux/
|
||||||
extlinux --install --raid ${BASE_DIR}/${BOOT}syslinux
|
extlinux --install --raid ${BASE_DIR}/${BOOT}syslinux
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,6 +211,16 @@ if [ -n ${ENV} ]; then
|
|||||||
install_grub
|
install_grub
|
||||||
"${SCRIPTS_DIR}/seed-data" ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
|
"${SCRIPTS_DIR}/seed-data" ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
|
||||||
;;
|
;;
|
||||||
|
"syslinux")
|
||||||
|
format_and_mount
|
||||||
|
install_syslinux
|
||||||
|
"${SCRIPTS_DIR}/seed-data" ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
|
||||||
|
;;
|
||||||
|
"gptsyslinux")
|
||||||
|
format_and_mount
|
||||||
|
install_syslinux
|
||||||
|
"${SCRIPTS_DIR}/seed-data" ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
|
||||||
|
;;
|
||||||
"arm")
|
"arm")
|
||||||
format_and_mount
|
format_and_mount
|
||||||
"${SCRIPTS_DIR}/seed-data" ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
|
"${SCRIPTS_DIR}/seed-data" ${BASE_DIR} ${CLOUD_CONFIG} ${FILES}
|
||||||
@ -275,3 +292,4 @@ fi
|
|||||||
if [ "$KEXEC" = "y" ]; then
|
if [ "$KEXEC" = "y" ]; then
|
||||||
kexec -l ${DIST}/vmlinuz --initrd=${DIST}/initrd --append="${KERNEL_ARGS} ${APPEND}" -f
|
kexec -l ${DIST}/vmlinuz --initrd=${DIST}/initrd --append="${KERNEL_ARGS} ${APPEND}" -f
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -4,6 +4,10 @@ set -e
|
|||||||
set -x
|
set -x
|
||||||
|
|
||||||
DEVICE=${1}
|
DEVICE=${1}
|
||||||
|
DISKTYPE=${2}
|
||||||
|
if [[ -z $DISKTYPE ]]; then
|
||||||
|
DISKTYPE="msdos"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z $DEVICE ]]; then
|
if [[ -z $DEVICE ]]; then
|
||||||
echo "Need to Pass a device name as arg1." 1>&2
|
echo "Need to Pass a device name as arg1." 1>&2
|
||||||
@ -33,11 +37,13 @@ fi
|
|||||||
dd if=/dev/zero of=${DEVICE} bs=512 count=2048
|
dd if=/dev/zero of=${DEVICE} bs=512 count=2048
|
||||||
partprobe ${DEVICE}
|
partprobe ${DEVICE}
|
||||||
|
|
||||||
fdisk ${DEVICE} <<EOF
|
# https://www.gnu.org/software/parted/manual/html_node/set.html
|
||||||
n
|
# https://wiki.archlinux.org/index.php/syslinux
|
||||||
p
|
BOOTFLAG="boot"
|
||||||
1
|
if [ "${DISKTYPE}" == "gpt" ]; then
|
||||||
|
BOOTFLAG="legacy_boot"
|
||||||
|
fi
|
||||||
|
parted -s -a optimal ${DEVICE} mklabel ${DISKTYPE} -- \
|
||||||
|
mkpart primary ext4 1 -1 \
|
||||||
|
set 1 ${BOOTFLAG} on
|
||||||
|
|
||||||
|
|
||||||
w
|
|
||||||
EOF
|
|
||||||
|
Loading…
Reference in New Issue
Block a user