memstick.img size adjustment

Daniel O'Connor doconnor at gsoft.com.au
Sun Oct 27 08:05:58 UTC 2013


On 27 Oct 2013, at 17:54, Ian Smith <smithi at nimnet.asn.au> wrote:
> But then, I never understood why we used DD mode (/dev/da0a) rather than 
> a properly sliced MBR with the potential to have multiple releases &/or 
> architectures on one stick.  Again, PC-BSD (at 8.2 anyway) made a stick 
> with a slice table, so storing data (dmesg, pciconf, whatever) back to 
> the stick was trivial, as was adding boot0 to allow boot selection.

I don't know either, although given how makefs works it might be the easy option.

>> Or can someone identify the custom changes we need to generate-release.sh in
>> order to accomplish this?
> 
> I'm all ears.

I make custom releases for work with a large (multi gigabyte) tar file which is unpacked over the installed system.

My script looks like..

== SNIP ==
set -e

PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH

BLOCKSIZE=10240

if [ $# -lt 2 ]; then
  echo "$0 file srcdir [path ..]"
  echo ""
  echo "For example.."
  echo "$0 /tmp/memstick.img /usr/obj/usr/src/release/release /tmp/extra"
  echo ""
  echo "Note that srcdir must have a release built (we need the boot loader from it)"
  exit 1
fi

FILE="${1}"

shift
SRC="${1}"
shift
DIRS="$@"

for d in $DIRS; do
  if [ ! -e "${d}" ]; then
    echo "${d} doesn't exist"
    exit 1
  fi
done

TMPDIR=`mktemp -d -q /tmp/make-usbimg.XXXXXX`
if [ $? -ne 0 ]; then
  echo "Unable to create temporary directory"
  exit 1
fi

mkdir -p "${TMPDIR}/etc"
echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${TMPDIR}/etc/fstab
makefs -b 204800 -B little -o label=FreeBSD_Install ${FILE} ${TMPDIR} ${SRC} ${DIRS}
if [ $? -ne 0 ]; then
  echo "makefs failed"
  exit 1
fi

unit=`mdconfig -a -t vnode -f ${FILE}`
if [ $? -ne 0 ]; then
  echo "mdconfig failed"
  exit 1
fi

gpart create -s BSD ${unit}
gpart bootcode -b ${SRC}/boot/boot ${unit}
gpart add -t freebsd-ufs ${unit}
mdconfig -d -u ${unit}

rm -rf "${TMPDIR}"
== SNIP ==

I haven't tried using partitions, given the way it is made it might be tricky.

--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C








More information about the freebsd-stable mailing list