<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>~chuck/blog &#187; Minix</title>
	<atom:link href="http://www.ozymo.com/explosions/tag/minix/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ozymo.com</link>
	<description>What more could you want?</description>
	<lastBuildDate>Tue, 17 Oct 2023 03:57:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Installing Minix 2.0.4 in VirtualBox</title>
		<link>http://www.ozymo.com/explosions/151</link>
		<comments>http://www.ozymo.com/explosions/151#comments</comments>
		<pubDate>Tue, 07 Oct 2008 22:05:55 +0000</pubDate>
		<dc:creator>chuck</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[Minix]]></category>

		<guid isPermaLink="false">http://www.ozymo.com/~chuck/blog/?p=151</guid>
		<description><![CDATA[I have a few low-level development projects I want to undertake, and am working on building up my skills in systems programming. So, what better OS to use for a base than Linux, right? However, the Linux kernel is substantially large, and right now, I need to focus on trying to learn fundamental OS programming]]></description>
			<content:encoded><![CDATA[<p>I have a few low-level development projects I want to undertake, and am working on building up my skills in <a title="System Programming Tutorial" href="http://www.ftt.co.uk/tutorials/Sysprog_tutorial1.html" target="_blank">systems</a> <a title="Free Linux Programming Books" href="http://www.techbooksforfree.com/linux.shtml" target="_blank">programming</a>.  So, what better OS to use for a base than <a title="O'Reilly's Linux System Programming Book" href="http://oreilly.com/catalog/9780596009588/" target="_blank">Linux</a>, right?  However, the <a title="Kernel Home Page" href="http://www.kernel.org" target="_blank">Linux kernel</a> is substantially large, and right now, I need to focus on trying to learn <a title="Google search for the term" href="http://www.google.com/search?hl=en&amp;q=fundamental+OS+programming+skills&amp;btnG=Google+Search" target="_blank">fundamental OS programming skills</a>.  I think it would be better to start with a smaller base system.  Since Linux was written in and based on <a title="Minix Home Page" href="http://www.minix3.org/" target="_blank">Minix</a>, I figure I&#8217;ll give that a go.  Here&#8217;s a short walk-through on installing the system in <a title="VirtualBox Home Page" href="http://www.virtualbox.org" target="_blank">VirtualBox</a> on a <a title="Debian Home Page" href="http://www.debian.org" target="_blank">Debian</a> Lenny host.  Enjoy!</p>
<p><strong>I assume that you already have a VirtualBox installation on your system and you know how to use it. </strong>I chose to use the 2.0.4 release of Minix, because the <a title="Wikipedia Article on Minix" href="http://en.wikipedia.org/wiki/MINIX" target="_blank">OS base grew substantially for version 3</a>.<strong> </strong>You can download Minix 2.0.4 from <a title="Minix 2.0.4 (Intel build)" href="http://www.minix3.org/previous-versions/bzipped/Intel-2.0.4.tar.bz2" target="_self">here</a>.</p>
<p>To start, <a title="VirtualBox Documentation" href="http://www.virtualbox.org/wiki/End-user_documentation" target="_blank">create the VirtualBox guest</a>.  I called it, creatively, &#8220;Minix 2.0.4&#8243;.  You can call yours what you like.  I created a new virtual disk of 512M, which is much more than is necessary to install Minix, but will give me plenty of room to dick around.</p>
<p>Before booting, configure your Minix VM to boot from a floppy image.  Navigate to the directory created when you extracted the Minix tarball, then to the i386 folder therein.  You&#8217;ll see that there is nothing there.  Tell VirtualBox to look for all files, rather than .IMG files.  You&#8217;ll see the <strong>ROOT.MNX</strong> and <strong>USR.MNX</strong> files in your directory.  For boot, we need to select the <strong>ROOT.MNX</strong> file.</p>
<p>Boot the machine.  Press <strong>=</strong>, as it says, to start Minix.  You&#8217;ll be prompted for a location of a device to use for mounting <strong>/usr</strong>.  Unmount the floppy, as the root floppy is now loaded into RAM, by clicking <em>Devices-&gt;Unmount Floppy</em> on the VirtualBox window.  Select <em>Devices-&gt;Mount Floppy-&gt;Floppy Image&#8230;</em> and navigate to the USR.MNX file we saw before.  In Minix, finish the line with <strong>fd0</strong> so that the device listed is <strong>/dev/fd0</strong>.  Hit return, and you should be prompted with a login message.  Above this, Minix explains that to install, you need to issue the <strong>setup</strong> command.  <em>Ignore this.</em> We&#8217;re going to use the included documentation, and do things manually.  What a concept!</p>
<p>In the extracted folder from the Minix tarball, you&#8217;ll find a file called <strong>usage.txt</strong>.  This file contains both &#8220;automatic&#8221; and &#8220;manual&#8221; installation instructions for Minix.  Open the file in your favorite editor.  I use vi.</p>
<p>Scroll down to section <strong>6. MANUAL INSTALLATION</strong>.  These are the instructions we will use to install Minix.  Sort of.</p>
<p>First things first, type <strong>root</strong> at the login prompt to log in as the root user.</p>
<p>Now, issue the <strong>part</strong> command to start the disk partitioner.  For help in part, type <strong>?</strong>.  I scrolled using the arrow keys to the <strong>Kb</strong> column, and typed in the entire disk size, since we are not going to partition a VM.  How silly would that be?  Type the <strong>&gt;</strong> key on the newly created partition to create the &#8220;subpartition&#8221; scheme.  This is much like partitions inside a FreeBSD slice, except Minix refers to them as slices inside a partition  It&#8217;s all semantics.  I created partitions as follows:</p>
<blockquote><p><strong>Size in K   Partition </strong><strong>Description</strong><br />
1440            My Root partition, to be mounted as /.<br />
10240          Partition to mount at /usr.<br />
2880            Swap.</p></blockquote>
<p>This creates just under 15M of partition space for use on the Minix system, and leaves just under 500M available on the slice I initially created.  There is no need to reboot at this time, as the disk  driver reloads  the  partition  tables  on the next access if the disk is not in use.  Since we haven&#8217;t mounted anything, we&#8217;re good to go.  Remember that the numbering for the disk starts at zero, i.e., our first partition is <strong>/dev/c0d0p0</strong>, and our first slice is <strong>/dev/c0d0p0s0</strong>.</p>
<p>Set the new slice as bootable by issuing the following command:</p>
<blockquote><p><strong># installboot -m /dev/c0d0p0 /usr/mdec/masterboot</strong></p></blockquote>
<p>Create your <strong>swap space</strong>, and turn it on:</p>
<blockquote><p><strong># mkswap /dev/c0d0p0s1<br />
# mount -s /dev/c0d0p0s1</strong></p></blockquote>
<p>Now, we will create a filesystem for the <strong>/usr</strong> partition on <strong>/dev/c0d0p0s2</strong>:</p>
<blockquote><p><strong># mkfs /dev/c0d0p0s1<br />
# readall -b /dev/c0d0p0s1 | sh<br />
# mount /dev/c0d0p0s1 /mnt<br />
# cpdir -v /usr /mnt</strong></p></blockquote>
<p>This will copy all of the data from the floppy-mounted <strong>/usr</strong> partition to the <strong>/mnt</strong> directory, where the disk-mounted <strong>/usr</strong> partition resides.  You can now mount the new <strong>/usr</strong> directory instead of using the floppy:</p>
<blockquote><p><strong># umount /dev/c0d0p0s1<br />
# umount /dev/fd0<br />
# mount /dev/c0d0p0s1 /usr</strong></p></blockquote>
<p>This is where things get a little hairy.  In the <strong>usage.txt</strong> file, we are instructed to switch back to the <strong>ROOT.MNX</strong> image to make the root partition and fill it with data.  But, if you switch back to the <strong>ROOT.MNX</strong> image in VirtualBox, and mount it as follows, you can look in the <strong>/mnt</strong> directory with ls and see that there are some problems:</p>
<blockquote><p><strong># mount /dev/fd0 /fd0</strong></p></blockquote>
<p>So, if the <strong>ROOT.MNX</strong> image won&#8217;t work now, what do we do?  Reboot!  Type <strong>halt</strong> at the prompt, and the system will move to the <strong>fd0&gt;</strong> prompt.  Go ahead and power off the virtual machine, or type <strong>exit</strong> and reset the box through VirtualBox.  Then start it back up.  Make sure you are booting from the <strong>ROOT.MNX</strong> image.</p>
<p>When prompted for a device to mount as /usr, simply provide the device we filled earlier, <strong>/dev/c0d0p0s1</strong>.  Again, log in byt typing &#8220;root&#8221; at the login prompt.  From here, we can move on from the instructions in <strong>usage.txt</strong>:</p>
<blockquote><p><strong># mkfs -i 512 /dev/c0d0p0s0<br />
# mount /dev/fd0 /fd0<br />
# mount /dev/c0d0p0s0 /mnt<br />
# cpdir -v /fd0 /mnt<br />
# umount /dev/fd0</strong></p></blockquote>
<p>You can issue <strong>ls /fd0</strong> after mounting it, and see that the file names are correct, unlike they were previously.</p>
<p>The <strong>/mnt/etc/issue</strong> file (or /etc/issue, when the device is mounted as root) creates the &#8220;use setup&#8221; line when the system boots, so it can be removed, or replaced with one of your choosing.  The /mnt/etc/fstab file (or /etc/fstab, when the device is mounted as root) needs to be modified to reflect the new partitions.  I used sed and cat to make my edits:</p>
<blockquote><p><strong># sed &#8216;s/t=unknown/t=\/dev\/c0d0p0s0/;s/r=unknown/r=\/dev\/c0d0p0s1/&#8217; \ /mnt/etc/fstab &gt; /mnt/etc/fstab.new<br />
# cp /mnt/etc/fstab.new /mnt/etc/fstab<br />
# cat &gt;&gt; /mnt/etc/fstab &lt;&lt; EOF<br />
</strong>&gt; swap = /dev/c0d0p0s2<br />
&gt;<strong> EOF</strong></p></blockquote>
<p>Now unmount the new root partition and make it bootable:</p>
<blockquote><p><strong># umount /dev/c0d0p1s0<br />
# installboot -d /dev/c0d0p1s0 /usr/mdec/bootblock boot</strong></p></blockquote>
<p>Now we&#8217;re all set!  Simply issue <strong>halt</strong> again, as before, and reboot the machine.  Don&#8217;t forget that you need to unset the boot floppy device, or change the boot order in VirtualBox to have it boot from the hard disk.</p>
<p>Use your new system wisely!</p>
<p>/cs</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ozymo.com/explosions/151/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
