Chinaunix首页 | 论坛 | 博客
  • 博客访问: 42198
  • 博文数量: 13
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 200
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-26 08:56
文章分类

全部博文(13)

文章存档

2008年(13)

我的朋友
最近访客

分类: BSD

2008-03-31 16:13:06

制作可启动的OpenBSD ISO映像(简单修正版)

随着4.0 的发布,新一轮的尝鲜、升级、安装、测试又要开始。对于新手(包括我在内)这第一步便是如何制作安装盘,网上现成的文章成堆,另外还有高手(一般都谦虚地 说自己不是)制作的自动化脚本,极大的方便了制作过程。不过这里引发了两个问题,其一:大部分网上的文章,这第一步从站点下在所需文件的方法就有些问题(也许是我人品问题),所以我才写这个“简单修正”。

其二:人家给你制作了自动化脚本,在第一时间方便了你的安装,但如果你还是想自己动手从最基础的部分入手,想更细化规范的学习,相信这第一步还是挺重要,扎实的基础是日后游刃有余的根本。

制作iso映像系统环境为debian,所需附加软件mkisofs。
第一步:建立文件夹(可选),下载所需文件。
#mkdir -p /home/openbsd/4.0
#cd /home/openbsd/4.0
#wget -crnH --cut-dirs=3 ftp://ftp.tw.openbsd.org/pub/OpenBSD/4.0/i386/
注:你可以按照你的系统环境变通,但剩余容量最好大于500兆,至于建立openbsd文件夹,网上通常写法类似于mkdir -p openbsd/4.0/i386,我这里省略了i386是因为后面的wget下载过程中会自动建立。
说到下载.
第二步:制作iso映像。
这步可以安心的使用网上文章的命令来生成iso映像了,但提醒你注意命令行里的路径。
如果没有mkisofs,先安装吧!
#apt-get install mkisofs
然后开始制作吧!过程相对较短!可能一两分钟吧!
#cd /home/openbsd (确保你在正确的路径)
#mkisofs -vrTJV “OpenBSD40″ -b 4.0/i386/cdrom40.fs -c boot.catalog -o OpenBSD40.iso ./
稍等一会儿,你就会通过自己的操作获得一张标准的可引导安装盘,至于刻录吗?抱歉-帮不上忙,这个也要你自己动手了,不过-估计不用看教程,是不?:~)



最后附上自动安装脚本:

脚本的使用方法:

$ ./mk_openbsd_iso-0.1.sh 3.9 i386
复制内容到剪贴板
代码:
#!/bin/sh





# Author : MichaelBibby



# Date : 2006.07.22



# Purpose : Automatic download file sets and create an OpenBSD -release or



# -snapshots ISO.



# Version : 0.1



# Usage : ./mk_openbsd_iso.sh [3.9|4.0|snapshots] [i386|amd64|sparc64]





VERSION="$1" # Special OpenBSD version, like 3.9, 4.0, snapshots.



ARCH="$2" # Maechine architecture, like i386, amd64.



TMP_ARCHIVE="$HOME/tmp/openbsd" # Store all openbsd file sets.



SETS_ARCHIVE="$TMP_ARCHIVE/$VERSION/$ARCH" # Store all installation file sets.



PKGS_ARCHIVE="$TMP_ARCHIVE/$VERSION/$ARCH/packages" # Store all packages.





FETCH_CMD="wget"





CDROM_FS=$(basename ${SETS_ARCHIVE}/cdrom*.fs)





# Check the following URL to choose a mirror near you:



#



#MIRROR="ftp://ftp.openbsd.org/pub/OpenBSD"



MIRROR=""





MKISOFS_CMD="mkisofs -vrlTJV "OpenBSD_${VERSION}_$ARCH" \



-b $VERSION/$ARCH/${CDROM_FS} \



-c boot.catalog \



-o $HOME/OpenBSD_${VERSION}_$ARCH.iso $TMP_ARCHIVE"





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_APPS()



{



# Set all nessessary applications into an ARRAY: APPS.



APPS_ARRAY="mkisofs $FETCH_CMD"





echo "Checking neccessary applications..."





for i in $APPS_ARRAY



do



if [ ! $(whereis "$i") ]



then



echo "ERROR: $i is not installed, you should installed first"





case $i in



mkisofs)



echo "mkisofs is always included in package 'cdrtools'.";;



esac





exit



fi



done



}





CHECK_DIRS()



{



# Set all nessessary dir into an ARRAY: DIRS.



DIRS_ARRAY="$SETS_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/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. Finally, maybe you



# want to comment the line following: 'rm -f $TMP_OB_FILES_SETS'.



# ------------------------------------------------------------------------





echo "Downloading OpenBSD file sets' index file..."



$FETCH_CMD -O $TMP_OB_FILES_SETS $MIRROR/$VERSION/$ARCH/index.txt





# ------------------------------------------------------------------------





for i in $(cat $TMP_OB_FILES_SETS)



do



echo "Downloading file set: $i..."



$FETCH_CMD -c -O $SETS_ARCHIVE/$i $MIRROR/$VERSION/$ARCH/$i



done





#rm -f $TMP_OB_FILES_SETS



}





FETCH_PKGS()



{



TMP_OB_PKG_SETS="/tmp/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'.



# ------------------------------------------------------------------------





#echo "Downloading OpenBSD package sets' index file..."



#$FETCH_CMD -c -O $TMP_OB_PKG_SETS $MIRROR/$VERSION/packages/$ARCH/index.txt





# ------------------------------------------------------------------------





for i in $(cat $TMP_OB_PKG_SETS)



do



echo "Downloading package: $i..."



$FETCH_CMD -O $PKGS_ARCHIVE/$i $MIRROR/$VERSION/packages/$ARCH/$i



done





#rm -f $TMP_OB_PKG_SETS



}





# ----------- SCRIPT MAIN -------------



clear



echo -e "\n\



\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# ------- ------#



\t# --------------------------------------------------------------------------#



\t# ------- Warnning: Not every platform supports all boot options. For ------#



\t# ------- more information, see also: ------#



\t# ------- ------#



\t# --------------------------------------------------------------------------#



\t# ------- Note: If you want to include some packages in the ISO file, ------#



\t# ------- please read the function: FETCH_PKGS, and uncomment the ------#



\t# ------- function at the end of script: ------#



\t# ------- FETCH_PKGS && \ ------#



\t# --------------------------------------------------------------------------#



"



sleep 10





USAGE "$@" && \



CHECK_APPS && \



CHECK_DIRS && \



FETCH_SETS && \



#FETCH_PKGS && \



$MKISOFS_CMD && \



echo "GOOD, ISO has been created:\n\t$HOME/OpenBSD_${VERSION}_${ARCH}.iso"
阅读(750) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~