FlashInstall

Материал из OpenWiki
Перейти к: навигация, поиск

Советы по созданию установочного образа на USB Flash, установка системы на Flash

Установка FreeBSD с Flash

Ниже скрипт для преобразования установочного iso образа в формат для заливки на USB Flash (в BIOS поставить загрузку с USB-HDD):

#!/bin/sh

# You can set some variables here. Edit them to fit your needs.

# Set serial variable to 0 if you don't want serial console at all,
# 1 if you want comconsole and 2 if you want comconsole and vidconsole
serial=0

set -u

if [ $# -lt 2 ]; then
    echo "Usage: $0 source-iso-path output-img-path"
    exit 1
fi

isoimage=$1; shift
imgoutfile=$1; shift

export tmpdir=$(mktemp -d -t fbsdmount)
# Temp file and directory to be used later
export tmpfile=$(mktemp -t bsdmount)

export isodev=$(mdconfig -a -t vnode -f ${isoimage})

echo "#### Building bootable UFS image ####"

ISOSIZE=$(du -k ${isoimage} | awk '{print $1}')
SECTS=$((($ISOSIZE + ($ISOSIZE/5))*2))

# Root partition size

echo "Initializing image..."
dd if=/dev/zero of=${imgoutfile} count=${SECTS}
ls -l ${imgoutfile}
export imgdev=$(mdconfig -a -t vnode -f ${imgoutfile})

bsdlabel -w -B ${imgdev}
newfs -O1 /dev/${imgdev}a

mkdir -p ${tmpdir}/iso ${tmpdir}/img

mount -t cd9660 /dev/${isodev} ${tmpdir}/iso
mount /dev/${imgdev}a ${tmpdir}/img

echo "Copying files to the image..."
( cd ${tmpdir}/iso && find . -print -depth | cpio -dump ${tmpdir}/img )
#bzcat ${tmpdir}/iso/dist/root.dist.bz2 | mtree -PUr -p ${tmpdir}/img 2>&1 > /dev/null

#echo "/dev/ufs/${UFS_LABEL} / ufs ro 1 1" > ${tmpdir}/img/etc/fstab

if [ ${serial} -eq 2 ]; then
        echo "-D" > ${tmpdir}/img/boot.config
        echo 'console="comconsole, vidconsole"' >> ${tmpdir}/img/boot/loader.conf
elif [ ${serial} -eq 1 ]; then
        echo "-h" > ${tmpdir}/img/boot.config
        echo 'console="comconsole"' >> ${tmpdir}/img/boot/loader.conf
fi

cleanup() {
    umount ${tmpdir}/iso
    mdconfig -d -u ${isodev}
    umount ${tmpdir}/img
    mdconfig -d -u ${imgdev}
    rm -rf ${tmpdir} ${tmpfile}
}

cleanup

ls -lh ${imgoutfile}

Оригинал здесь.

Скрипт для форматирования и монтирования загрузочной USB Flash (Взят с сайта [frenzy])

#!/bin/sh

DEF_DEV=/dev/da0

echo -n "Введите имя устройства USB Flash [${DEF_DEV}]: "
read DEVICE

if [ -z "${DEVICE}" ]; then
	DEVICE=$DEF_DEV
fi

if [ ! -c "${DEVICE}" ]; then
	echo "Не найден ${DEVICE}, проверьте путь"
	exit 1;
fi

dd if=/dev/zero of=${DEVICE} bs=512 count=32
fdisk -BI ${DEVICE}
dd if=/dev/zero of=${DEVICE}s1 bs=512 count=32
bsdlabel -w -B ${DEVICE}s1
bsdlabel ${DEVICE}s1 >> tmp.$$
ed tmp.$$ <<EOF
/a:
s/unused/4.2BSD
wq
EOF
bsdlabel -R ${DEVICE}s1 tmp.$$
rm tmp.$$
newfs ${DEVICE}s1a

TEMPDIR=$PWD/tmpdir.$$
mkdir $TEMPDIR
mount ${DEVICE}s1a $TEMPDIR

Ссылки