Script for creating a bootable usb Freesco pin from linux

If you need some help, this should be the first place to look.

Script for creating a bootable usb Freesco pin from linux

Postby Peppe/Sweden » Sun Apr 10, 2011 3:40 am

This is my very first script ever so it is not the most advance script in the world but it does it job .

WARNING :
I will not take responsibility to any data loss if you use this script - in any way .
You are responsible for all your actions - which are non reversable since all commands are made under run root .


Preperations :

Any Freesco 0.4.3 or newer ( older 0.4.x will probably work as well ) .
You’ll need any modern linux distribution with a least a 2.2.x kernel with usb support.
A editor (I will us vi)
fdisk
sed
bash

If any of the above is missing it will produce an error during script execution (except fdisk and editor) .


Walkthru :

Start a terminal and change user to root with the command su
Change directory to the path where Freesco is placed
Start vi , example; vi fusb
Copy the following script to your editor;
Code: Select all
#!/bin/bash
# usb3

umount  /dev/sdb1
echo sdb1 unmounted
sleep 5
umount  /dev/sdb
echo sdb unmounted
sleep 1
echo Copying Freesco
dd if=freesco.043 of=/dev/sdb
sleep 5
mount /dev/sdb /media/usb
echo Mounting USB drive
sleep 1
sed -i 's/fd0/usb/' /media/usb/SYSLINUX.CFG
echo Changing boot device to USB
sleep 1
echo D O N E

Change the freesco image to your specific version if you are running any other then Freesco-043 , in other words dd if=freesco.043 of=/dev/sdb
(For Freesco-040 it is freesco.040 and for Freesco-041 it is freesco.041 and so on )

Start a new terminal and change user to root with the command su
Create a new directory for your usb pin with the command mkdir /media/usb
(If you already have an other directory you can use that but you must change the following to your search path in the script ”mount /dev/sdb /xxx/xxx” )
Insert your usb pin
Run the command fdisk -ll , mine shows the following ;
Code: Select all
root@P7120:/home/peter# fdisk -ll

Disk /dev/sda: 32,3 GB, 32296140800 byte
255 huvuden, 63 sektorer/spår, 3926 cylindrar
Enheter = cylindrar av 16065 · 512 = 8225280 byte
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Diskidentifierare: 0x000f3cd1

    Enhet Start     Början        Slut     Block    Id  System
/dev/sda1   *           1        3759    30194136   83  Linux
/dev/sda2            3760        3926     1341427+   5  Utökad
/dev/sda5            3760        3926     1341396   82  Linux växling / Solaris

Disk /dev/sdb: 512 MB, 512483328 byte
16 huvuden, 62 sektorer/spår, 1009 cylindrar
Enheter = cylindrar av 992 · 512 = 507904 byte
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Diskidentifierare: 0xf889595f

    Enhet Start     Början        Slut     Block    Id  System
/dev/sdb1   *           1        1009      500433    6  FAT16
root@P7120:/home/peter#


Now , notice that my harddrive is /dev/sda x and the usb pin is adressed as /dev/sdb .
Again , this might be different to your computer and configuration .
So , if the your device is different - change all entries from /dev/sdb to your device designation in the script - be sure to change all five locations !
These locations needs to be changed ;
Code: Select all
umount  /dev/sdb1
umount  /dev/sdb
dd if=freesco.043 of=/dev/sdb
mount /dev/sdb /media/usb
sed -i 's/fd0/usb/' /media/usb/SYSLINUX.CFG


save your script (if you are running vi press ZZ)
change permisson to your script with chmod 755 fusb

Keep your fingers crossed and run your script with ./fusb

Now , you should have a bootable Freesco pin , and if change directory to /media/usb , you should have a complete directory and files for Freesco to boot .
If you type the command less SYSLINUX.CFG you will hopefully see that sed has done it’s job and changed all entries from fd0 to usb .

Unmount the usb pin with the command umount /media/usb

Try to boot the usb pin ! - it should work .




The script does the following :

1:) Unmount’s all /dev/sdb devices ( sdb & sdb1 )

2:) Copy’s the freesco image to the usb pin

3:) Mount’s the usb pin .
( To the mount point /media/usb )
4:) Changes the syslinux bootable device with the sed command .
( Changes all remarks from fd0 to usb )


Sidenotes ,

* Some usb pins work fine to boot on some motherboards and some simply don’t .
My first ideas was that USB 1.1 motherboards didn’t work with 2.0 usb pin’s but that isn’t true .
One usb pin can boot fine on one motherboard and won’t work on another - I haven’t found out why yet .
If you are having problems , I recommend the following ;

Try to make something else bootable , such as tinycore linux with Unetbootin

Try to get your hands on another usb pin

Goooogle


* Some of this script is learned from a post the Lewis wrote a while ago and I opted to change the fd0 to usb on the usb pin instead directly to the orginal image if any user both want to use the image for floppy and usb use .

* The command sed is simply great and I picked up that when doing som research in the past on how to setup a linux mail server .
The mail server was never completed - but sed was picked up and is a great command !

* Scripting is fun ! , but you need to check everything over and over again so that it does everything that you want .
Needless to say , this script could be far more advance and ask question such as which usb path is to be used , which freesco image to be used and so on .
But hey , it works - it does it job fast , and it is perfect - especially for beta testers .

* I had a additon in the script that changed the kernel as well in the start - witch worked well .
You could as well have an additon that add network drivers and so on .

* Any additons in the script is ignored when you put # in front of the command .
Last edited by Peppe/Sweden on Mon Apr 11, 2011 11:12 am, edited 1 time in total.
[COLOR=blue] You mean that I don?t fly airplanes , I don?t have a grilfriend and don?t have a dog ? Buuh , I grow up to be a real loser! (The Kid , walt disney) [COLOR=blue]
User avatar
Peppe/Sweden
Junior Advanced Member
 
Posts: 161
Joined: Wed Feb 05, 2003 4:41 pm

Re: Script for creating a bootable usb Freesco pin from linu

Postby Lightning » Sun Apr 10, 2011 11:11 am

Very nice to create a simple script and document the process for creating a bootable USB stick.
I mainly have one small comment. Formatting the device with "mkfs.msdos" in not necessary when you use "dd" to put the disk image on it because the "dd" command will format the device with the disk image format and overwrite anything that was previously there and it creates a 1.44Mb USB device as an exact duplicate of the floppy image.

The mkfs.msdos command would only be used if you were making the device DOS bootable and then copying the files to it manually and then using an autoexec.bat file to start FREESCO as it is done on a DOS hard drive install. Which I am not sure if or how you could add the DOS boot files to the disk from within a Linux environment. Regardless it would mainly only be done from within a DOS/Windows environment when trying to create the bootable USB device and the "dd" command is not available.
If you are afraid that you might make a mistake. The chances are high that you will never learn anything.
User avatar
Lightning
FREESCO GOD !!
 
Posts: 12079
Joined: Wed Nov 14, 2001 6:50 am
Location: Oregon, USA

Re: Script for creating a bootable usb Freesco pin from linu

Postby Lightning » Sun Apr 10, 2011 5:54 pm

Thinking about this further, if you did format the drive as ext2 instead of DOS you could use a boot loader like lilo on it to boot the kernel and ramdisk. Be aware that regardless of how you format the drive and make it bootable makes no difference in the system because currently with USB devices those are the only files used and the /router directory structure that is on the floppy is never used in any way. The kernel, ramdisk and to be bootable are all that is required regardless of anything else.
If you are afraid that you might make a mistake. The chances are high that you will never learn anything.
User avatar
Lightning
FREESCO GOD !!
 
Posts: 12079
Joined: Wed Nov 14, 2001 6:50 am
Location: Oregon, USA

Re: Script for creating a bootable usb Freesco pin from linu

Postby Peppe/Sweden » Mon Apr 11, 2011 11:44 am

Thanks for all the comments .

Anyone that takes the time to set the script up and run it is in for treat .
It really speeds up the creating of a usb pin .

I have removed all entries that mentions formating of the usb pin .


I'm guessing that there really isn't a real advantage to make a bootable usb pin with ext2 and using lilo/grub as a bootloader since there isn't really a way to make a usb pin a persistent storage device such as a harddrive / floppy drive .

If there aren't any more comments - would it be possible to put this small guide to the "how-to section" ?

Regards , Peter
[COLOR=blue] You mean that I don?t fly airplanes , I don?t have a grilfriend and don?t have a dog ? Buuh , I grow up to be a real loser! (The Kid , walt disney) [COLOR=blue]
User avatar
Peppe/Sweden
Junior Advanced Member
 
Posts: 161
Joined: Wed Feb 05, 2003 4:41 pm


Return to FAQ - Frequently Asked Questions

Who is online

Users browsing this forum: No registered users and 2 guests

cron