Howto Install Trixbox 2.4 from a USB Flash Drive
Howto Install Trixbox 2.4 from a USB Flash Drive
-------------------------------------------
The Summary of the Entire Process is:
1. Install new MBR (Master Boot Record) onto the Flash
2. Create 2 Partitions on the Flash Drive, one for the diskboot.img image and the other for the Trixbox ISO file.
3. Boot the target system with the USB Drive
4. When asked where the install media is, point it to the second partition on the flash.
5. The Install Process will begin.
Requirements:
1. At least a 1GB USB Flash Drive
2. A working Linux Box that can load the Flash Drive so you can format it and install the images.
3. The target system BIOS must be able to Boot from USB Device
Detailed Instructions:
1. Copy the trixbox-2.4.0.2.iso file onto your working Linux system into /tmp.
cd /tmp
Make a temporary directory
mkdir trixbox
Mount the ISO Image into that temporary directory so that you can extract the diskboot.img file
mount -o loop -t iso9660 /tmp/trixbox-2.4.0.2.iso /tmp/trixbox cd /tmp/trixbox/images [root@wailea images]# ls -al total 120967 drwxr-xr-x 4 root root 2048 Dec 27 20:20 . drwxr-xr-x 7 root root 2048 Dec 27 20:22 .. -rw-r--r-- 1 root root 7610368 Dec 27 20:11 boot.iso -rw-r--r-- 1 root root 12582912 Dec 27 20:11 diskboot.img -rw-r--r-- 1 root root 35532800 Dec 27 20:16 minstg2.img drwxr-xr-x 2 root root 2048 Dec 27 20:11 pxeboot -rw-r--r-- 1 root root 651 Dec 27 20:10 README -rw-r--r-- 1 root root 68132864 Dec 27 20:20 stage2.img -r--r--r-- 1 root root 1541 Dec 27 20:22 TRANS.TBL drwxr-xr-x 2 root root 2048 Dec 27 20:12 xen
The file we are interested in is diskboot.img. It is designed to be installed in a
USB Flash Drive and enables us to boot the operating system.
2. Now we must install a new MBR (Master Boot Record) in the flash drive. We can use the ms-sys program for this which can be found at http://ms-sys.sourceforge.net/
Insert the USB Flash Drive into the working Linux box and determine the device name it loads under.
[root@wailea images]# dmesg | grep 'SCSI device' SCSI device sda: 2013184 512-byte hdwr sectors (1031 MB)
In this case it is loaded as /dev/sda
Now use the ms-sys program with the ‘-s’ option to install the MBR (ms-sys -s /dev/sdX)
[root@wailea images]# ms-sys -s /dev/sda Public domain syslinux master boot record successfully written to /dev/sda
3. You are now ready to make the 2 partitions.
Use fdisk (on that same Linux Box) to create two partitions on the Flash drive.
The first one should be 13 MB, and the other one should occupy the rest of the space.
[root@wailea images]# fdisk /dev/sda
{use ‘p’ to print the partition table and then ‘d’ to delete existing partitions}
Command (m for help): p
Disk /dev/sda: 1030 MB, 1030750208 bytes
32 heads, 62 sectors/track, 1014 cylinders
Units = cylinders of 1984 * 512 = 1015808 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 14 13857 e W95 FAT16 (LBA)
/dev/sda2 15 1014 992000 c W95 FAT32 (LBA)
Command (m for help): d
Partition number (1-4): 1
Command (m for help): d
Selected partition 2
{then use ‘n’ to add 2 new partitions, the first one 13M and the second one with the rest of the space}
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-1014, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-1014, default 1014): +13M Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (15-1014, default 15): Using default value 15 Last cylinder or +size or +sizeM or +sizeK (15-1014, default 1014): Using default value 1014
{Now use ‘t’ to change the partition type, the first 13MB partition must be type "e W95 FAT16 (LBA)" and the second, where the Trixbox ISO image will be located must be type "c W95 FAT32 (LBA)}
Command (m for help): t Partition number (1-4): 1 Hex code (type L to list codes): e Changed system type of partition 1 to e (W95 FAT16 (LBA)) Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): c Changed system type of partition 2 to c (W95 FAT32 (LBA)) Command (m for help): p Disk /dev/sda: 1030 MB, 1030750208 bytes 32 heads, 62 sectors/track, 1014 cylinders Units = cylinders of 1984 * 512 = 1015808 bytes Device Boot Start End Blocks Id System /dev/sda1 1 14 13857 e W95 FAT16 (LBA) /dev/sda2 15 1014 992000 c W95 FAT32 (LBA)
{finally use 'a' to make 1st parition bootable)".
Command (m for help): a Partition number (1-4): 1 Command (m for help): p Disk /dev/sda: 1030 MB, 1030750208 bytes 32 heads, 62 sectors/track, 1014 cylinders Units = cylinders of 1984 * 512 = 1015808 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 14 13857 e W95 FAT16 (LBA) /dev/sda2 15 1014 992000 c W95 FAT32 (LBA)
{confirm there is a star under the Boot Column for the fist partition, that means its bootable}
{write the new partition table with ‘w’ and exit}
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: If you have created or modified any DOS 6.x partitions, please see the fdisk manual page for additional information. Syncing disks.
4. Remember the diskboot.img file, now we will need it.
'dd' the bootdisk.img to the first partition and it will be bootable.
[root@wailea images]# dd if=/tmp/trixbox/images/diskboot.img of=/dev/sda1 24576+0 records in 24576+0 records out
5. Format the second partition as FAT32
[root@wailea images]# mkfs -t vfat -F 32 /dev/sda2 mkfs.vfat 2.8 (28 Feb 2001)
6. Mount the Filesystem into temporary directory /tmp/flash
[root@wailea images]# mkdir /tmp/flash [root@wailea images]# mount /dev/sda2 /tmp/flash
7. Copy the Trixbox ISO File into /tmp/flash.
[root@wailea tmp]# cp /tmp/trixbox-2.4.0.2.iso /tmp/flash
8. Copy the ks.cfg (Kickstart file) into /tmp/flash. You will thus be saving it to the second partition on the flash for later access.
[root@wailea tmp]# cp /tmp/trixbox/ks.cfg /tmp/flash
9. The ks.cfg file contains all the directives needed to install the trixbox components. Without it you will end up just installing plain CentOS. You will need to edit the file and make appropiate changes to eliminate all references to the cdrom.
remove these lines:
# CDROM Based Installation cdrom change line ‘clearpart --all –initlabel’ to: clearpart --drives=hda --all –initlabel #do not clear partitions on flash
10. Unmount the Partition and remove the USB Drive
[root@wailea tmp]# umount /tmp/flash
11. Insert the Drive into the Target Machine where you want to install Trixbox.
12. Follow the instructions. You will not see the usual Trixbox splash screen. You will see the default CentOS screen. At the boot prompt you must indicate where the kickstart file is. You do that with the following command. Substitute ‘sda2’ for whatever the path of your second partition is on the flash.
linux ks=hd:sda2/ks.cfg
If you get a message later saying that it did not find the file. Just wait a few seconds and retry. It sometimes takes a moment to load the Flash Drive.
13. When it asks for the type of media which contains the packages, select ‘Hard drive’. When it asks for the partition and directory that hold the CD images for trixbox, you must select that second partition on the USB Drive. In my test system it loaded as ‘sda2’. You might have to test by trial an error if you have multiple drives. In any case, do not press F2 to ‘configure additional devices’ as this will take you nowhere.
14. After finishing the installation, if you pull out the Flash Drive and reboot, it may give you a Grub Disk Error (it happened on mine). For some reason, the installation wirites the Grub Loader in the MBR of the Flash. It also sets the /boot/grub/device.map file pointing hd0 to the flash and when you pull the Flash out, you can’t boot. This probably won’t happen on every system but its better to know about it. What you need to do now is put the flash back in and reboot. (make sure your BIOS has greater priority booting from the USB Flash than the Hard Disk). Once you boot the operating system and get the into the root prompt, change the below file so that the Hard Disk is hd0:
[trixbox1.localdomain grub]# more /boot/grub/device.map # this device map was generated by anaconda (hd0) /dev/hda (hd1) /dev/sda
15. Then install grub on the MBR of your hard drive like this:
[trixbox1.localdomain grub]# grub-install /dev/hda Installation finished. No error reported. This is the contents of the device map /boot/grub/device.map. Check if this is correct or not. If any of the lines is incorrect, fix it and re-run the script `grub-install'. # this device map was generated by anaconda (hd0) /dev/hda (hd1) /dev/sda
16. Finally make the changes to the grub.conf file so that it now points to hd0 like this:
[trixbox1.localdomain grub]# cat /etc/grub.conf
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
title trixbox (2.6.18-53.1.4.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-53.1.4.el5 ro root=LABEL=/
initrd /initrd-2.6.18-53.1.4.el5.img
17. If you need to use the Flash for another install, you will have to prepare the first partition again (Steps 2, 3 and 4). If you need many installs, I recomend you instead make further modifications to the ks.cfg file to prevent writing of the MBR on the flash (bootloader --location=partition) and use the %post processing to install grub on the MBR of the Hard Drive. . I use the /sbin/grub –-batch command
Enjoy!
Ricardo Villa

