BCCD:FossilScripts

From Earlham Cluster Department

Jump to: navigation, search

bbc_unfold script (unpacks the raw subsystems from the iso image)

#!/bin/sh

usage () {
    cat <<EOF
Usage: bbc_unfold iso-file

Take a LNX-BBC ISO file and unfold the four filesystems on the 
disk so they can be examined or modified.  The four filesystems
created are:

    bbc     This is a copy of the ISO9660 filesystem on the CD image.
            Exverything else is stored in here.


    sing    This directory contains the contents of the compressed
            filesystem stored in the file singularity on the CD image.
            This is the final running root filesystem of a lnx-bbc
            system when it is running.  This is most of the data
            is the CD image.

    lnx     This is a mounted FAT fileystem from the file lnx.img
            on the CD.  This is exactly the size of a 1.4MB floppy.
            When the lnx-bbc disc is booted, the system bios of the 
            PC treats this file as a fake bootable floppy.  This
            contains the kernel, an initial ram disk root.bin, and
            a few other files to boot using syslinux.

    root    This is a mount ext2 filesystem from the file root.bin
            contained in lnx.img.  This is the initial ramdisk
            root filesystem when the lnx-bbc boots.


    bbc_fold creates two mount points for lnx and root.  These 
    mount points are visible with a 'df'.  These filesystems should
    be unmounted with bbc_clean, bbc_fold, or bbc_isolinux when you
    are finished examing the lnx-bbc disc.

EOF
}

die () {
    echo
    echo "Error: $1";
    echo
    exit 1
}

# Get the ISO
for option in "$@"; do
    case "$option" in

        *)
            if test "x$iso" != x; then
                echo "Only specify one ISO file" 1>&2
                usage
                exit 1
            fi
            iso="${option}" ;;
    esac
done

if test "x$iso" = x; then
    echo "ISO file not specified." 1>&2
    usage
    exit 1
fi

# Mount the ISO image, make a copy of the contents and
# unmount the image.
#
echo "Mounting ISO image"
rm -rf bbc-iso
mkdir bbc-iso
sudo mount $iso bbc-iso -o loop || die "Cannot mount $iso as ISO9660"
rm -rf bbc
# cp -a bbc-iso bbc
rsync -HlpogDr bbc-iso bbc-tmp
mv bbc-tmp/bbc-iso bbc
rm -rf bbc-tmp

sudo umount bbc-iso
rm -rf bbc-iso

# Copy lnx.img floppy image from cd and mount as lnx
#
cp -f bbc/lnx.img .
mkdir -p lnx
sudo mount lnx.img lnx -o loop || die "Cannot mount lnx.img"

# Copy root.bin initrd, uncompress, and mount as root
#
cp -f lnx/root.bin root.bin.gz  || die "Cannot find lnx/root.bin"
rm -rf root.bin
gzip -d root.bin.gz
mkdir -p root
sudo mount root.bin root -o loop || die "Cannot mount root.bin"

# Decompress singularity
#
echo -n "Decompressing singularity..."
extract_compressed_fs bbc/singularity > sing.uncomp 2> /dev/null || \
    die "uncompressing singularity"
echo

# Mount singularity as romfs, copy contents, and unmount image
#
rm -rf sing.romfs
mkdir sing.romfs
sudo mount sing.uncomp sing.romfs -o loop -t romfs || \
    die "Cannot mount singularity"
# cp -a sing.romfs sing
rsync -HlpogDr sing.romfs sing-tmp
mv sing-tmp/sing.romfs sing
rm -rf sing-tmp

sudo umount sing.romfs
rm -rf sing.romfs sing.uncomp

echo
df lnx root
echo
echo
echo "lnx-bbc unfolded as follows:"
echo
echo "   bbc      r/w copy of CDROM filesystem"
echo "   sing     r/w copy of singularity comrpessed r/o filesystem"
echo "   lnx      Mounted fat r/w el-toritto fake book floppy"
echo "   root     Mounted ext2 r/w initrd root filesystem on floppy"
echo
exit 0


bbc_fold script that puts all of the pieces from unfold together into a new bootable image


#!/bin/sh

usage () {
    cat <<EOF
Usage: bbc_fold iso-file

Take the four directories created by bbc_unfold and fold them
back into a bootable LNX-BBC bootable image.

EOF
}

die () {
    echo
    echo "Error: $1";
    echo
    exit 1
}


# Get the ISO name
#
for option in "$@"; do
    case "$option" in

        *)
            if test "x$iso" != x; then
                echo "Only specify one ISO file" 1>&2
                usage
                exit 1
            fi
            iso="${option}" ;;
    esac
done

if test "x$iso" = x; then
    echo "ISO file not specified." 1>&2
    usage
    exit 1
fi

echo "Folding initrd root filesystem"
sudo umount root                || die "Cannot unmount root"
rm -rf root.bin.gz root
gzip -9 root.bin
mv root.bin.gz root.bin
sudo cp -f root.bin lnx
rm -rf root.bin

echo "Folding el toritto fake boot floppy"
sudo umount lnx                 || die "Cannot unmount lnx"
rm -rf lnx
sudo cp -f lnx.img bbc
rm -f lnx.img

echo "Generating new singularity"
sudo rm -rf bbc/singularity
genromfs -d sing -f sing.fs     || die "Cannot create romfs for singularity"

echo -n "Compressing singularity..."
create_compressed_fs sing.fs 65536 > bbc/singularity 2> /dev/null || \
    die "Cannot compress romfs into singularity"
rm -rf sing.fs

rm -rf $iso  || die "deleting old $iso"
mkisofs -v -d -N -D -R -T -c boot.catalog -b lnx.img -A "Linux" -V "LNX" -P "bbc-jeff" -o $iso bbc || die "mkisofs failed"
rm -rf sing bbc
exit 0
Personal tools
Namespaces
Variants
Actions
websites
wiki
this semester
Toolbox