Gentoo install min on USB stick

Download minimal CD ISO from gentoo.org


dmesg | tail
parted /dev/sdX
dd if=gentoo_image.img of=/dev/sdX bs=4M

Longer method

Taken from gentoo-en.vfose.ru
Install syslinux

emerge syslinux

Find the USB drive

fdisk -l

Clear disk partition table and boot sector

dd if=/dev/zero of=/dev/sdf count=1024

Create a partition table with 512-byte sectors and a primary partition of type 83 (ext2) with fdisk and make it bootable

fdisk -b 512 /dev/sdf
n p 1 enter enter
t 83
a 1 
p
w
Device     Boot      Start        End      Blocks   Id  System
/dev/sdf1   *           1        1009      500433   83  Linux

Format the partition ext2 and tune it

mkfs.ext2 /dev/sdf1
tune2fs -i 0 /dev/sdf1

install the mbr

equery f sys-boot/syslinux | grep mbr

Note: the listing above is for gentoo only. If you are using ubuntu, the listing above can be ignored.

cat /usr/share/syslinux/mbr.bin > /dev/sdf

If cat command returns Permission Denied error try with:

dd if=/usr/share/syslinux/mbr.bin of=/dev/sdf

mount the usb flash drive and disk image. If the device folder doesn’t exist, please create them before conducting the following listing.

mount -t ext2 /dev/sdf1 /mnt/usb/
mount -t iso9660 -o loop,user /downloads/install-x86-minimal-2008.0.iso /mnt/cdrom

install the system files

cd /mnt/usb/
cp -r /mnt/cdrom/* /mnt/usb/
mv isolinux extlinux
mv extlinux/isolinux.cfg extlinux/extlinux.conf
rm extlinux/isolinux.bin
rsync -av extlinux 

install the bootloader

cd /tmp
extlinux -i /mnt/usb/extlinux
umount /mnt/usb 

Lastly ensure the changes are synced to the USB Stick before removing it:

sync

Unbricking WRT54G

A quick guide how to ‘fix’ bricked WRT54G. I managed to brick it by installing OpenWRT firmware (attitude adjustment v12.09). Unfortunately this router doesn’t have enough memory to handle v12.09. My attempts to upload a new firmware trough ssh bricked the router.

To unbrick it I first did 30 30 30 reset.

  • Powered router hold reset button for 30 sec
  • Still holding reset, unpower router and wait 30 sec
  • Still holding reset power on the router and hold for another 30 sec

Find a working firmware and upload it using tftp. I used tomato WRT54G_WRT54GL.bin). Make sure tftp is installed on your system

emerge -av net-ftp/atftp
emerge -av net-ftp/linksys-tftp

Connect your computer to the router and set a static IP. On my linux box this is done by the following steps


/etc/init.d/net.eth1 stop
nano -w /etc/conf.d/net

routes_eth1="default via 192.168.1.1"
config_eth1="192.168.1.15 netmask 255.255.255.0 brd 192.168.1.255"

/etc/init.d/net.eth1 start

Turn on the router and check if the router can be pinged. Do a router power cycle and let ping command working
ping 192.168.1.1
If the router can be pinged most likely you will be able to upload a new firmware using tftp.

TFTP flashing instructions

Turn off the router. Initialize ftp transfer:

atftp 192.168.1.1
verbose
trace
timeout 60
put WRT54G_WRT54GL.bin

and turn on the router. The transfer should start by itself. If tfpt gets disconnected you can repeat the whole process.

atftp 192.168.1.1
tftp> timeout 60
tftp> trace
Trace mode on.
tftp> verbose
Verbose mode on.
tftp> put WRT54G_WRT54GL.bin
sent WRQ >
source port mismatch, check bypassedtimeout: retrying...
sent WRQ >
received ACK
sent DATA
received ACK
sent DATA
received ACK
sent DATA
received ACK

Another useful package is linksys-tftp

emerge -av net-ftp/linksys-tftp

To use it, first connect and then set the transfer


linksys-tftp> connect [router]
linksys-tftp> put [firmware image]

Useful resources

Bricked-Or-How-to-Resurrect-a-Dead-Linksys-WRT54G
openwrt wrt54g page