Update on my PINGish bootable USB

Reece Arnott <[email protected]>
Newsgroups gmane.org.user-groups.linux.dunedin.general
Message-ID <[email protected]>
I'm getting my head around compiling the kernel and modules from source 
code and making some progress on figuring out a number of different ways 
of *not* adding wireless networking and USB3 support via kernel modules 
(issues number 2 and 3 in my previous long email). Is there an easy way 
to compile modules without compiling the entire kernel (in particular 
the USB3 support in xhci_hcd.ko of the 3.1.2 kernel from source 
downloaded from 
ftp://ftp.kernel.org/pub/linux/kernel/v3.x/linux-3.1.2.tar.bz2 and 
setting different kernel information than that of the host system)? It 
takes a couple of hours to compile everything and when you do it wrong 3 
or 4 times it starts to get annoying.

I'm not sure what I was doing wrong with transferring the rootfs.tar.bz2 
filesystem to be a new initrd.gz loop device filesystem (issue number 1 
in my previous long email) but I didn't have much trouble with doing it 
this weekend.

I suspect I was tired and not paying attention to one of two things:
1. The filesystem contains symlinks so I couldn't unzip it, select all, 
copy and paste in nautilus. I unzipped it directly to a mounted and 
formatted loop device.
2. There are 3 different sizes to keep in mind and a>b>c where a is the 
size of the unzipped rootfs.tar.bz2, b is the filesize of the mounted 
loop device, and c is the amount of ram set aside in syslinux.cfg to 
load this loop device into. For future things I have created another 
little script to transfer from a currently mounted initrd to a newly 
created and differently sized one. See below...

I have also figured out another way to create a new bootable USB (and 
for completeness bootable CD iso) without using the full UNetbootin 
interface, see below also. I needed to find the mbr.bin to replace the 
USB master boot record (using dd) and isolinux.bin to be the boot sector 
for the CD (using mkisofs). They were both in the same syslinux library 
folder /usr/lib/syslinux. There is one more missing link as I am 
currently still relying on syslinux to install the bootsector in the 
active partition. I suspect if I knew the correct file in the syslinux 
library folder then I could use dd to copy the bootsector rather than 
use syslinux which you'd have to install on any Linux system before 
being able to use the script. dd is more likely to be previously installed.

Does anyone know what file is used as the bootsector for syslinux on a 
FAT32 filesystem? I've installed syslinux on my Ubuntu machine and I am 
assuming its one of the files in /usr/lib/syslinux. I may have to 
download the source code and see what files it uses for the -i (install 
bootsector) option.

---Transfer initrd to different size loop device----

echo "New Size in KB"
read filesize
echo "File for new initrd"
read initrdnew
echo "Folder to mount new initrd"
read initrdnewmount

#Assumes the loadfs.sh has been run first
echo "Folder for mounted initrd"
read initrdmount

sudo dd if=/dev/zero of=$initrdnew bs=1024 count=$filesize
sudo losetup /dev/loop1 $initrdnew
sudo mkfs -t ext3 -m 1 -v /dev/loop1
sudo mount -t ext3 /dev/loop1 "$initrdnewmount"

echo "Zipping up the old filesystem"
cd "$initrdmount"
sudo tar -cjf "/tmp/rootfs.tar.bz2" *
cd "$initrdnewmount"
echo "Unzipping to the new filesystem"
sudo tar -xjf "/tmp/rootfs.tar.bz2"

echo "Type: sudo umount \"$initrdnewmount\""
echo "to unmount the new filesystem."

---- end of file -----



---- make bootable cd iso----
#isolinux.bin oriignally found in /usr/lib/syslinux/isolinux.bin
echo Where is the USB drive mounted?
read mountpoint
echo Destination iso?
read bootcdiso
mkisofs -b bootableiso/isolinux.bin -c bootableiso/boot.cat 
-no-emul-boot -boot-load-size 4 -boot-info-table -o "$bootcdiso" 
"$mountpoint"

---- end of file -----


--- make usb bootable----
#mbr.bin originally found in /usr/lib/syslinux/mbr.bin
echo What device to make bootable?
read bootabledevice
echo What partition do you want to make active?
read activepartition
sudo syslinux -i $bootabledevice$activepartition
sudo dd conv=notrunc bs=440 count=1 if=mbr.bin of=$bootabledevice
sudo parted $bootabledevice set $activepartition boot on

---- end of file -----


-- "Believing men would act in their own interest was not cynicism, it 
turned out, but sheerest optimism; in reality men do not meet so high a 
standard." -- Harry Potter and the Methods of Rationality (Chapter 84) 
http://hpmor.com/ Reece Arnott Dunedin New Zealand

_______________________________________________
DunLUG mailing list
[email protected]
http://lists.ethernal.org/listinfo/dunlug
DunLUG Wiki - http://dunlug.kallisti.net.nz/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.