mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
103 lines
6.6 KiB
HTML
103 lines
6.6 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
|
||
|
<html><head>
|
||
|
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
|
||
|
<meta http-equiv="Content-Language" content="en-us"><title>Product</title>
|
||
|
|
||
|
<link rel="stylesheet" type="text/css" href="../style.css"></head>
|
||
|
<body style="background-color: rgb(255, 255, 255);"><h3><a name="title" href="http://www.eluaproject.net/en/Booting_eLua_from_a_stick" class="local">Booting eLua from a stick</a></h3>
|
||
|
|
||
|
<div class="content">
|
||
|
|
||
|
<p>This is follow up of <a href="http://www.eluaproject.net/en/Booting_your_PC_in_eLua">this tutorial</a>.
|
||
|
After completing it you'll be able to boot eLua directly from your USB
|
||
|
stick (provided, of course, that your computer can boot from an USB
|
||
|
stick, which is true for most computers nowadays). You might want to
|
||
|
check the <a href="http://www.eluaproject.net/en/Booting_your_PC_in_eLua">boot your PC in eLua</a>
|
||
|
tutorial first for more details. If you have an old USB stick that you
|
||
|
don't use anymore, and/or the shear geekness of this idea makes you
|
||
|
feel curious, this tutorial is definitely for you :)</p>
|
||
|
|
||
|
<h2>Disclaimer</h2>
|
||
|
|
||
|
<p><strong>As mentioned <a href="http://www.eluaproject.net/en/Booting_your_PC_in_eLua">here</a>,
|
||
|
the code won't try to access any kind of storage (HDD, CDROM, floppy),
|
||
|
not even for reading, so you don't need to worry about that. Also it
|
||
|
doesn't try to reprogram your video card registers, so it can't harm it
|
||
|
or your monitor. It only implements a "protected mode keyboard driver"
|
||
|
that can't physically damage anything in your system. In short, I made
|
||
|
every effort to make the code as harmless as possible. I tested it on 5
|
||
|
different computers and in 2 <a href="http://www.virtualbox.org/">VirtualBox</a>
|
||
|
emulators, and nothing bad happened. That said, there are no warranties
|
||
|
of any kind. In the very unlikely event that something bad does happen
|
||
|
to your system, you have my sincere sympathy, but I can't be held
|
||
|
responsible for that. Also, I can't be held responsible if you mess up
|
||
|
your HDD by failing the GRUB installation procedure (even though, once
|
||
|
again, this shouldn't be possible unless you really insist on messing
|
||
|
it up). If you're new to computers, this tutorial might not be for you.
|
||
|
Your call.</strong></p>
|
||
|
|
||
|
<h2>Prerequisites</h2>
|
||
|
|
||
|
<p>To have your own bootable eLua USB stick you'll need:</p>
|
||
|
|
||
|
<ul><li>an USB stick. I tested this on an 128M USB stick, because
|
||
|
it's the smallest I could find. You should be OK with a 4M stick or
|
||
|
even a 2M stick</li><li>a computer running Linux. I use Ubuntu, but any other distribution is fine.</li><li><a href="http://www.gnu.org/software/grub/">GRUB</a>.
|
||
|
Since you're running Linux, chances are you're already using GRUB as
|
||
|
your bootloader. If not, you must install it on your HDD, or at least
|
||
|
know how to install it directly on the USB stick. I won't go into
|
||
|
details here, google it and you'll find lots of good articles about
|
||
|
GRUB. This tutorial assumes that you're using GRUB as your bootloader.</li><li>The eLua ELF file. Download it from <a href="http://elua.berlios.de/surprise">here</a>. OR <a href="http://www.eluaproject.net/en/Downloads">download eLua</a> and compile it for the i386 architecture using a toolchain that you can build by following <a href="http://www.eluaproject.net/en/Building_GCC_for_i386">this tutorial</a>.</li><li>a text editor to edit your GRUB configuration file.</li></ul>
|
||
|
|
||
|
|
||
|
<p>The rest of this tutorial assumes that you're using Linux with GRUB,
|
||
|
and that GRUB is located in /boot/grub, which is true for many Linux
|
||
|
distributions.</p>
|
||
|
<h2>Backup your stick</h2>
|
||
|
|
||
|
<p>Since the stick is going to be formatted, make sure to backup the
|
||
|
data from your stick first (you can copy it back after finishing the
|
||
|
tutorial).</p>
|
||
|
|
||
|
<h2>Partition and format your stick</h2>
|
||
|
|
||
|
<p>Depending on your stick, this step might not be required, but
|
||
|
chances are you'll need to re-partition and re-format your stick before
|
||
|
installing GRUB on it. The problem is that many sticks have a very
|
||
|
creative, non-standard partition table, and GRUB doesn't like that. I
|
||
|
looked at the partition table on my eLua USB stick, and it scared me to
|
||
|
death, so I had to follow this procedure. In short, you'll need to
|
||
|
delete all the partitions from your stick, create a new partition, and
|
||
|
then format it. For a step by step tutorial check here.</p>
|
||
|
<h2>Install GRUB on your stick</h2>
|
||
|
|
||
|
<p>First, mount your freshly formatted stick (I'm going to assume that the mount directory is /mnt):</p>
|
||
|
|
||
|
<pre><code> $ sudo mount /dev/sda1 /mnt<br></code></pre>
|
||
|
|
||
|
|
||
|
<p>(of course, you'll need to change /dev/sda1 to reflect the physical location of your USB stick).
|
||
|
Then copy the required GRUB files to your stick:</p>
|
||
|
|
||
|
<pre><code> $ cd /mnt<br> $ mkdir boot<br> $ mkdir boot/grub<br> $ cd /boot/grub<br> $ cp stage1 fat_stage1_5 stage2 /mnt/boot/grub<br></code></pre>
|
||
|
|
||
|
|
||
|
<p>Copy the <a href="http://elua.berlios.de/surprise">eLua ELF file</a> to the GRUB directory as well:</p>
|
||
|
|
||
|
<pre><code> $ cp surprise /mnt/boot/grub<br></code></pre>
|
||
|
|
||
|
|
||
|
<p>Create a menu.lst file for GRUB with you favorite text editor (I'm using joe):</p>
|
||
|
|
||
|
<pre><code> $ cd /mnt/boot/grub<br> $ joe menu.lst<br> title Surprise!<br> root (hd0,0)<br> kernel /boot/grub/surprise<br> boot<br></code></pre>
|
||
|
|
||
|
<p>Now it's time to actually install GRUB on the stick.</p>
|
||
|
|
||
|
<pre><code> $ sudo -s -H<br> # grub<br> Now we need to find the GRUB name of our USB stick. We'll use the "find" command from<br> GRUB and our "surprise" file to accomplish this:<br><br> grub> find /boot/grub/surprise<br> (hd2,0)<br><br> GRUB should respond with a single line (like (hd2,0) above). If it gives you more <br> than one line, something is wrong. Maybe you also installed eLua on your HDD? If so, <br> delete the /boot/grub/surprise file from your HDD and try again.<br> You might get a different (hdx,y) line. If so, just use it instead of (hd2,0) in the rest of <br> this tutorial.<br><br> grub> root (hd2,0)<br> grub> setup (hd2)<br> Checking if "/boot/grub/stage1" exists... yes<br> Checking if "/boot/grub/stage2" exists... yes<br> Checking if "/boot/grub/fat_stage1_5" exists... yes<br> Running "embed /boot/grub/fat_stage1_5 (hd2)"... 15 sectors are embedded.<br> succeeded<br> Running "install /boot/grub/stage1 (hd2) (hd2)1+15 p (hd2,0)/boot/grub/stage2<br> /boot/grub/menu.lst"... succeeded<br> Done. <br> grub> quit<br></code></pre>
|
||
|
|
||
|
|
||
|
<p>That's it! Now reboot your computer, make sure that your BIOS is set
|
||
|
to boot from USB, and enjoy! You can even type dofile "/rom/bisect.lua"
|
||
|
to execute the "bisect.lua" test file.
|
||
|
As usual, if you need more details, you can <a href="http://www.eluaproject.net/en/Contact">contact us</a>.</p>
|
||
|
</div></body></html>
|