[[wiki]wiki[/wiki]][/wiki]一、手动的很简单
由于openbsd官方不提供iso镜像文件下载,因此我们需要自己制作一个可引导的openbsd安装光盘。步骤如下:
1、从openbsd官方[wiki]网站[/wiki]下载所需文件
$ cd /download/
$ wget -c -t0 -T150 -m [[wiki]URL[/wiki]][wiki]FTP[/wiki]://ftp.openbsd.org/pub/OpenBSD/4.0/i386[/url]
2、使用mkisofs制作光盘镜像文件
$ cd /download/ftp.openbsd.org/pub/OpenBSD/
$ mkisofs -vrlTJV "OpenBSD40" -b 4.0/i386/cdrom40.fs -c boot.catalog -o OpenBSD40.iso ./
3、刻录iso文件到光盘.
二、mk_openbsd_iso-0.3.sh
#!/bin/sh
# Author : MichaelBibby <
michaelbibby@gmail.com>
# Date : 2006.07.24
# Pur[wiki]POS[/wiki]e : Au[wiki]Tom[/wiki]atic download file sets and create an OpenBSD -release or
# -snapshots ISO.
# Version : 0.2.1
# Usage : ./mk_openbsd_iso.sh [3.9|4.0|snapshots] [i386|amd64|sparc64]
# ChangeLog:
# * 0.2 --> 0.2.1:
# - Fix the bug when get val[wiki]UE[/wiki] of CDROM_FS.
# * 0.1 --> 0.2:
# - Add function FETCH_SRC to fetch source code and ports tarballs.
# - Modify some temp directories and little adjustment.
#FETCH_CMD="wget"
FETCH_CMD="proz -r"
VERSION="$1" # Special OpenBSD version, like 3.9, 4.0, snapshots.
ARCH="$2" # Maechine architecture, like i386, amd64.
TMP_ARCHIVE="$HOME/tmp/openbsd/$VERSION" # Store all openbsd file sets.
SRC_ARCHIVE="$TMP_ARCHIVE/$VERSION" # Store source code and ports tarball.
SETS_ARCHIVE="$TMP_ARCHIVE/$VERSION/$ARCH" # Store all installation file sets.
PKGS_ARCHIVE="$TMP_ARCHIVE/$VERSION/$ARCH/packages" # Store all packages.
# Directory for temp dir.
TMP_DIR='/tmp'
# Check the following URL to choose a mirror near you:
#
http://www.openbsd.org/ftp.html
# ---------- Offical ----------------------------
#MIRROR="ftp://ftp.openbsd.org/pub/OpenBSD"
# ---------- For release version ----------------
MIRROR="http://openbsd.md5.com.ar/pub/OpenBSD"
# ---------- For snapshots version --------------
#MIRROR="http://mirror.sese.asu.edu/pub/OpenBSD"
USAGE()
{
if [ X"$#" != X"2" ]; then
echo "USAGE: $0 VERSION ARCH"
echo "e.g.: $0 [3.9|4.0|snapshots] [i386|amd64|...]"
exit 255
fi
}
CHECK_DIRS()
{
# Set all nessessary dir into an ARRAY: DIRS.
DIRS_ARRAY="$SETS_ARCHIVE $SRC_ARCHIVE $PKGS_ARCHIVE"
echo "Checking neccessary directories..."
# Check and create dirs.
for dir in ${DIRS_ARRAY}
do
if [ ! -d "$dir" ]; then
echo -ne "\tWARNNING: $dir NOT exist, creating it..."
mkdir -p $dir
echo "DONE"
fi
done
}
# Fetch OpenBSD's installation file sets, like base39.tgz, comp39.tgz.
FETCH_SETS()
{
TMP_OB_FILES_SETS="${TMP_DIR}/ob_file_sets"
# If you want to specify which file sets will be contained in the iso file,
# you should comment the following 2 lines, and create '/tmp/ob_file_sets'
# manually, and then write the file sets' names in it.
# ------------------------------------------------------------------------
echo "Remove old index file of OpenBSD sets..."
rm -f ${TMP_OB_FILES_SETS} 2>/dev/null
# ------------------------------------------------------------------------
echo "Downloading new index file of OpenBSD file sets..."
cd ${TMP_DIR}
$FETCH_CMD $MIRROR/$VERSION/$ARCH/index.txt
mv index.txt ${TMP_OB_FILES_SETS}
#$FETCH_CMD -c -O $TMP_OB_FILES_SETS $MIRROR/$VERSION/$ARCH/index.txt
cd ${SETS_ARCHIVE}
for i in $(cat $TMP_OB_FILES_SETS)
do
echo "Downloading file set: $i..."
${FETCH_CMD} $MIRROR/$VERSION/$ARCH/$i
#$FETCH_CMD -c -O $SETS_ARCHIVE/$i $MIRROR/$VERSION/$ARCH/$i
done
}
FETCH_SRC()
{
# Fetch source code and ports tarball.
if [ X"$VERSION" == X"snapshots" ]; then
FILE_LIST="ports.tar.gz"
else
# If you want to download XF4.tar.gz, just append it to $FILE_LIST.
FILE_LIST="src.tar.gz sys.tar.gz ports.tar.gz"
fi
cd ${SRC_ARCHIVE}
for i in $FILE_LIST
do
echo "Downloading src sets: $i..."
${FETCH_CMD} $MIRROR/$VERSION/$i
#$FETCH_CMD -c -O $SRC_ARCHIVE/"$i" $MIRROR/$VERSION/"$i"
done
}
FETCH_PKGS()
{
TMP_OB_PKG_SETS="${TMP_DIR}/ob_pkg_sets"
# If you want to specify which packages will be contained in the iso file,
# you should comment the following 2 lines, and create '/tmp/ob_pkg_sets'
# manually, and then write the packages' name in it. Finally, maybe you
# want to comment the line following: 'rm -f $TMP_OB_PKG_SETS'.
# ------------------------------------------------------------------------
rm -f $TMP_OB_PKG_SETS 2>/dev/null
echo "Downloading OpenBSD package sets' index file..."
cd ${TMP_DIR}
$FETCH_CMD $MIRROR/$VERSION/packages/$ARCH/index.txt
mv index.txt ${TMP_OB_PKG_SETS}
#$FETCH_CMD -c -O $TMP_OB_PKG_SETS $MIRROR/$VERSION/packages/$ARCH/index.txt
# ------------------------------------------------------------------------
cd ${PKGS_ARCHIVE}
for i in $(cat $TMP_OB_PKG_SETS)
do
echo "Downloading package: $i..."
${FETCH_CMD} $MIRROR/$VERSION/packages/$ARCH/$i
#$FETCH_CMD -c -O $PKGS_ARCHIVE/$i $MIRROR/$VERSION/packages/$ARCH/$i
done
}
CREATE_ISO()
{
CDROM_FS=$(basename ${SETS_ARCHIVE}/cdrom*.fs)
MKISOFS_CMD="mkisofs -vrlTJV "OpenBSD_${VERSION}_$ARCH" \
-b $VERSION/$ARCH/${CDROM_FS} \
-c boot.catalog \
-o $HOME/OpenBSD_${VERSION}_$ARCH.iso $TMP_ARCHIVE"
$MKISOFS_CMD
}
# ----------- SCRIPT MAIN -------------
USAGE "$@"
clear
echo -e "\n\
\t# --------------------------------------------------------------------------#
\t# ------- Please make sure you have the neccessary tools installed on ------#
\t# ------- your system, such as mkisofs/wget. ------#
\t# --------------------------------------------------------------------------#
\t# ------- We recommend you buy OpenBSD's Offical CD sets to support ------#
\t# ------- ongoing development of OpenBSD. There are many good reasons ------#
\t# ------- to own an OpenBSD CD set: ------#
\t# -------
http://www.openbsd.org/faq/faq3.html#BuyCD ------#
\t# --------------------------------------------------------------------------#
\t# ------- Warnning: Not every platform supports all boot options. For ------#
\t# ------- more information, see also: ------#
\t# -------
http://www.openbsd.org/faq/faq4.html#Overview ------#
\t# --------------------------------------------------------------------------#
\t# ------- Note: The ISO file will only contain base installation file ------#
\t# ------- sets, so, if you want to include source code/ports and ------#
\t# ------- packages in it, please uncomment the function at the end ------#
\t# ------- of script, and read the note of function '\$FETCH_PKGS': ------#
\t# ------- FETCH_SRC && \ ------#
\t# ------- FETCH_PKGS && \ ------#
\t# --------------------------------------------------------------------------#
"
sleep 10
CHECK_DIRS && \
FETCH_SETS && \
FETCH_SRC && \
FETCH_PKGS && \
CREATE_ISO && \
echo -e "GOOD, ISO has been created:\n\t$HOME/OpenBSD_${VERSION}_${ARCH}.iso"
# 使用方法:
$ ./mk_openbsd_iso.0.3.sh snapshots i386 --> 下载并制作 i386 平台的 snapshots 版本
$ ./mk_openbsd_iso.0.3.sh 4.0 amd64 --> 下载并制作 amd64 平台的 4.0 版本