mount -o loop

Look at the vnode option. That will allow you to create a virtual device from a file. You can then mount that device.
 
This is some code I've managed to cobble together which works on Linux. I would like to do the same on FreeBSD but I can't get the mount -o loop to work. Not sure that mdconfig can be used... initrd-noheader just seems to be an archive file of some description which Linux knows how to decompress...

Code:
mkdir /mnt/gfh
mkdir /tmp/gfh
cd /tmp/gfh
wget http://support.goflexhome.hipserv.com/en/reflash/goflex_2_7_2_firmware.zip
unzip goflex_2_7_2_firmware.zip
dd if=initrd of=initrd-noheader.gz skip=64 bs=1
gunzip initrd-noheader.gz
mount -o loop initrd-noheader /mnt/gfh
cd /mnt/gfh
ls -al >~/loop.lst
cp etc/init.d/rcs ~

What I'm eventually hoping to do is be able to install FreeBSD on my GoFlexHome unit - it may take some time :)...
 
So you still haven't identified the file using the file(1) utility as previously advised?!

There's no Linux-specific voodoo in the decompression. A gzip is a gzip.
 
See? That wasn't so difficult after all. It's just like FreeBSD setup images: the CD/DVD images are ISOs and the ones for pendrives are IMG raw filesystem images. In the case of FreeBSD these IMGs are UFS2-based and in this Linux-specific case they're ext2-based.
 
Many thanks to everyone who helped point me in the right direction. I eventually came up with a script to create a USB disk which would provide
root Access to GoFlex Home without Registering Device

This should work on FreeBSD:-
Code:
TMPFILE=`mktemp XXXX`
echo $TMPFILE
mkdir /mnt/$TMPFILE
mkdir /tmp/gfh
cd /tmp/gfh
wget http://support.goflexhome.hipserv.com/en/reflash/goflex_2_7_2_firmware.zip
unzip goflex_2_7_2_firmware.zip
dd if=initrd of=initrd-noheader.gz skip=64 bs=1
gunzip initrd-noheader.gz
mount -t ext2fs /dev/`mdconfig -f initrd-noheader` /mnt/$TMPFILE
cd /mnt/$TMPFILE/etc/init.d/
#ls -al >~/loop.lst
cp rcS ~
cat <<EOF >sed.txt
/umount/a\
\\
# Attach the root file system and update /etc/passwd\\
echo "**** Attaching UBI file system"\\
ubiattach /dev/ubi_ctrl -m 2 -O 2048\\
if [ $? != 0 ]; then\\
        echo "**** ERROR - Could not attach UBIFS"\\
fi\\
mdev -s\\
mkdir -p /mnt/ubifs\\
\\
# sleep a while to allow devices to settle\\
sleep 5\\
\\
echo "**** Mounting root file system"\\
mount -t ubifs ubi0 /mnt/ubifs\\
\\
echo "**** Updating system password file"\\
sed -i 's/root:\*:/root:\$1\$3h5WisJ4\$JbJ\/AJORbUw8Mf.LtNVtp\/:/' /mnt/ubifs/etc/shadow
EOF

sed -f sed.txt rcS >newrcS
mv newrcS rcS
rm sed.txt
cd /tmp/gfh

gzip initrd-noheader

mkimage -A arm -O linux -C gzip -T ramdisk -n initramfs -d initrd-noheader.gz initrd

rm $TMPFILE
umount /mnt/$TMPFILE
rmdir /mnt/$TMPFILE

I don't think the standard FreeBSD installation contains unzip or mkimage so they may need to be added (not sure about wget).

I'd appreciate any comments or suggestions on how the change this script.
 
You can install wget with pkg install wget. It doesn't come with the base install, but the base does provide fetch, which is similar.
 
Back
Top