Set up the test rig

Set up the test rig.

This post is going to be a long one for two reasons: first, I am verbose; second, it is a lot to describe to do the setup. I structure this post in paragraphs because it can help you reading and it helps me organizing my working notes.

The test rig

As Test rig, I have an IBM Thinkpad T41: a very good piece of hardware. Now it is obsolete on many points of view, but this is not what it makes it a very good piece of hardware. The T41, before being owned by me and being my test rig, it was owned by the company I work for and was my working notebook 1. With it I performed all kind of tests on cars, recording data and interacting with the engine control unit by changing parameters and doing all what is needed for the job of a test driver. At that time I wasn't even paying any kind of attention on the stress I was putting on my notebook, I gave for granted that it worked without problems. My focus was to test and stress the car I was responsible for. Looking back now, I know it was a tremendous amount of stress for the hardware of my notebook too. It was able to work and record data (it means to read and write from HDD) while the car was travelling at any speed, on any road condition, with any kind of shakes which, as a matter of fact where applied on the arm of the HDD. In other terms, it means to operate the HDD and heavily shaking it at the same time.
Summer and winter test can be very bad especially if you have to do winter test during summer due to tight development schedule of the car. So here is the scenario: during summer (let us assume it is a sunny day of July with 30 °C outside) you have to perform engine cold start test to be sure your car starts even on the very bad winter's days. So a day or two before the test you put your prototype car with all measurements equipment installed (including the notebook) in a very special fridge. Now besides the fact that the fridge is very big such as you can put a car in, it is indeed a complete laboratory room inside a fridge. There is the chassis dynamometer, the exhaust gas measurement device and so on. All that is needed to simulate road condition in such a way that you can operate the car. The day of the test everything inside the fridge is at -25°C (but sometimes we did -30°C and even -35°C) including the notebook. By the way, my wife is wondering why I am the only one in our group of friends and relative that got very bad cold during summertime, but I guess my body was not that happy to do temperature jumps from -25°C to above 30°C. But now the focus is on the notebook. Now I am not a designer of HDD, but I guess that as the car was having a hard time to fire-up the engine in cold condition, the same would have been for the HDD to boot the notebook. The worst part of it is when the test is over. Since we are always on a tight schedule we have to take the car out of the cold chamber and let another car in to cool down overnight for the testing schedule of another colleague for the day after. When you see it for the first time is really nice: the atmosphere inside the chamber is very dry so it is damn cold but not "white". There is no ice on the walls of the chamber, nor on the car. But when you take the car out, it is like a huge block getting immediately white and full of ice. Almost the same happens with the notebook, it gets wet all together, but we are on a hurry to go back to the desk and start analyzing data, so we just wipe a bit the screen, the keyboard and move on. During my reading on The Starman's Realm I realized how bad I was with my notebook. If you go there and read you will find things like you shouldn't operate your HDD at low atmospheric pressure, meaning in high altitude2, well I did that too in Peru` for the high altitude test on the car. Of course, the engines don't like high altitude because of lack of oxygen so we had to test and adapt the engine's software to apply countermeasure to keep good combustion going even in those conditions. By the way, the human brain also needs oxygen and the high altitude tests are the worst of them all. Likely I had to do that only 2 times in my life, and I try to avoid them as much as I can. That is everything else but not fun (if you want to make yourself an idea about that watch the "Top Gear Christmas special south America". They went to Chile up to 17064 Foots or 5200 Meters). So after all of this and with some 10 years of operation, I run a check disk on the HDD. Guess how many bad sectors were there? Only one! That's what I mean when I say it is a good piece of hardware. As a mechanical engineer, I love good quality things and made robustly to last. For me, the fact that my T41 is not the fastest or the biggest in terms of storage and RAM capacity are not parameters I am measuring it but rather its robustness, and this is the reason why I say: It is a good piece of hardware!
Having said all that, let's go back on track and talk about the setting of the T41. It has XP on it, and I want to keep it because of the DEBUG.EXE. I want to add Linux, plus a partition to do my experiments on it. This took me already a couple of months to set all this properly. I will tell my experience with that in such a way you can potentially avoid some mistakes I did and make your setup take shorter than it took to me. Giving the fact that XP was available and proved stable on that PC, I started concentrating on Linux meaning that I formatted it all and tried different version. One problem that Linux has with the T41 is the wireless connection. I find confirmations about this problem in forums by many other users with an IBM T41 struggling to make it work with Linux/Ubuntu. In the end, I was not able to identify the root cause for it but I did a lot of experiments: the fact is that the WiFi is working perfectly up to Ubuntu 10 with Kernel 2.6 (I have Kernel 2.6.32-72-generic), with any version higher than that it is not working well at all. In theory, it is possible to attempt a Kernel to OS-Version mismatch (meaning try to run Ubuntu 12 on Kernel 2.6) but either it wasn't working well or I wasn't able to do it in the right way. So after all the trials, I decided to stay with Ubuntu 10 and I restarted from scratch to set up my test rig.

XP installation and setup

I started here from scratch having a completely new installation of Windows XP with one special detail: divide the HDD into 2 partitions and install the XP in the first one leaving the second partition even unformatted. As we will see in a while, the reason for it is that we want to reserve a space in the HDD where we will install the Ubuntu and some other space for our test partition. To do that we go to the partitioning tool we find in XP (see pictures from Fig. A to Fig. D; as you can see I have a German version of XP so with the use of screenshots I hope that everybody can get there despites a different language).

XP installation and setup
Fig. A

XP installation and setup
Fig. B

XP installation and setup
Fig. C

XP installation and setup
Fig. D

Once we are in the partitioning tool we start to create partitions in the not partitioned area. So we right-click on the not partitioned area and we select "create a new partition" (or something similar) from the menu. A new window pops up, we click on continue, then we say that we want to have a primary partition, that it is 100 MB in size, we assign a drive letter and we format it with FAT with label "TEST" (pictures from Fig. E to Fig. J).

XP installation and setup
Fig. E

XP installation and setup
Fig. F

XP installation and setup
Fig. G

XP installation and setup
Fig. H

XP installation and setup
Fig. I

XP installation and setup
Fig. J

After it, we set two other primary partitions for the Ubuntu OS and its dedicated SWAP partition. In the end, the result looks like the one in Fig. K.

XP installation and setup
Fig. K

So the first step of setup is done. We have only one primary partition, at the same time four is the maximum number of primary partitions that we can have on a drive with a "Master-Boot-Record-Technique" (MBR-Technique) of handling partitions. Drive D: labelled "TEST" is where we want to boot from for our tests and learning purposes. To do so we need to have GRUB2. To have GRUB2 we need to have Ubuntu/Linux installed side by side with windows XP on this machine and here is where drive E: and G: come to play a role. We will discuss GRUB2 later. Our next step now is to install Ubuntu 10.

Ubuntu 10 installation and setup

We reboot the T41 from the Ubuntu 10.04 installation CD. The point is that handling with partitions in Ubuntu/Linux is tricky and error-prone. The more robust way I found is the one described here which summarized consist in preparing the partitions using XP before installing Ubuntu/Linux and then to pilot the Ubuntu installation where we want it to be. When we get to that point we select "manual" for the partitioning method as in Fig. L.

Ubuntu 10 installation and setup
Fig. L

At this point, we see in Fig. M the four partitions as prepared with XP.

Ubuntu 10 installation and setup
Fig. M

So we select the smallest FAT32 partition and we tell the Ubuntu install-program that we want to use this partition as Linux SWAP area (from Fig. N to Fig. P).

Ubuntu 10 installation and setup
Fig. N

Ubuntu 10 installation and setup
Fig. O

Ubuntu 10 installation and setup
Fig. P

Now that we told Linux where to place the SWAP partition, we tell where to place the OS partition also named the /root partition. To do so we follow the steps from Fig. Q to Fig. V which steps are similar to what we just did before but with few setting more.

Ubuntu 10 installation and setup
Fig. Q

Ubuntu 10 installation and setup
Fig. R

Ubuntu 10 installation and setup
Fig. S

Ubuntu 10 installation and setup
Fig. T

Ubuntu 10 installation and setup
Fig. U

Ubuntu 10 installation and setup
Fig. V

In the end, we give some more confirmations (Fig. W and Fig. X) and the installation program will continue its job.

Ubuntu 10 installation and setup
Fig. W

Ubuntu 10 installation and setup
Fig. X

During the installation phase, the program comes to the point of the installation and setup of the GRUB2 module which knows that he has to boot Ubuntu and self detect the windows XP on partition 1. At the end of this stage, we can boot XP and Ubuntu.

Setup GRUB2 to make the PC boots from the test area

What is the GRand Unified Bootloader (GRUB)? In my opinion, it is a mini Operative System specialized on the task of booting any other OS after itself. Unfortunately due to this high degree of specialization in booting whatever the user feels like to boot, it is downgraded in the common opinion to the rank of a boot loader. Since my definition of GRUB is the one of being it a mini OS it is clear that my opinion is closer to the one of Gordon Matzigkeit (programmer and project initiator/coordinator of GRUB). GRUB has been continuously developed until version 0.97 and after that, it got a quantum leap in its development. To acknowledge that, the GRUB @ version 0.97 has been frozen under the name GRUB Legacy and the newly developed software has got the name of GRUB2. Now is time for you to study GRUB2 from the material that I found on the free software foundation web site:

Now that you have studied the GRUB2 manual and you know of what it is capable of, you can eventually agree with me that this software is indeed a mini OS that can perform many tasks. One of these tasks is the main one: to boot almost anything else after itself. But it is unfair to downgrade it to the rank of a simpler boot loader looking only at this feature and forgetting the rest. To explain a bit further my point of view let's consider some features that GRUB2 has and that we typically expect to find in any OS. GRUB2 understands different file systems (such as FAT, NTFS, EXT4, etc.) and can directly search read and write files from the HDD as an OS would do. This implies a lot in terms of hardware management capability of an HDD. The same can GRUB2 do from CD/DVD or Ethernet. GRUB2 can also modify the display and accommodate a graphic user interface for its boot menu with a very high degree of customization that includes screen resolution and colour management. It can even set a background picture rather than just a black screen. Such level of video management capability is a kind of minimum requirement and expected in any OS. GRUB2 has also a command line terminal where the user can instruct the PC to perform determined actions by issuing a command or even to load software in memory and pass control to it. This is definitively a capability of OS. The only difference here between any OS and GRUB2 is that in the case of any OS, it loads and starts a software who is intended to return control to the OS (sooner or later) once it is terminated so the OS remains awake behind the scenes to be ready to take over when the software on stage is done with its performance. On the other hands the purpose of GRUB2 is to load very special kinds of software (another OS) that will NOT terminate and does NOT require the intervention of GRUB2 once again, so GRUB2 isn't going to stay awake in any manner and its "loading and give control" approach is less complicated than other operative systems, nevertheless, you see really that the core capabilities and behaviours of GRUB2 are the ones typically of any other OS.

Having said that it's time to move on. GRUB2 has been very slightly modified or let's say customized for Ubuntu so we have to take a look on this documentation as well:

And here comes my understanding of all of that: GRUB2 looks into /boot/grub/grub.cfg to perform a series of actions including setting up and displaying a multi-boot menu on the screen, which is aligned to the wishes of the user (or let's say the administrator) who has written them down in the grub.cfg file and this is the core of it. You can write from scratch or modify an existing grub.cfg file (which by the way is a plain text file) if you want, but it is strongly recommended NOT to do so. Why? The reason is that a function in Ubuntu has been implemented that writes or better overwrites this file every time the user (or software) invokes the command update-grub3. The advantage of it is that at installation, or during a kernel update, or major version update of Ubuntu, the grub.cfg file can be updated to reflect the changes in the system. The disadvantage of it is that we have another layer between the user and his/her idea about what GRUB2 has to do and the way to instruct GRUB2 to do what the user wants it to do (Fig. Y).

Setup of GRUB2
Fig. Y - Layers until GRUB2

It turns out that since the mechanism is the one described before, one can modify staff in Layer 2, then run the update-grub command and read in layer 1 the effects of the modification to see (better read grub.cfg file) if something went wrong even before rebooting the system. In a way, there is a smaller feedback loop between the goals the user wants to implement and the implementation itself. Now let's have a look on some modifications I did to Layer 2 in order to make GRUB2 boot from my TEST partition on HDD. First of all, I wanted to remove the countdown from the boot menu just because of personal taste. So here follow the steps to accomplish that. As we can observe the effect is to have the same value on the two branches of the IF-statement whether or not there was an error by the previous attempt of loading an OS.

/boot/grub/grub.cfg before the change
[...] if [ ${recordfail} = 1 ]; then set timeout=-1 else set timeout=10 fi [...]

Modification in /etc/default/grub
[...] # GRUB_TIMEOUT=10 # this is the original one GRUB_TIMEOUT=-1 # this is the modified value [...]

/boot/grub/grub.cfg after the change
[...] if [ ${recordfail} = 1 ]; then set timeout=-1 else set timeout=-1 fi [...]

A second modification I want to implement is to change the screen resolution for the boot menu. Before doing any change I first rebooted my PC, then on the grub menu I pressed "c" to get the command prompt and I typed vbeinfo. Here I get all the possible screen resolution supported by my video, I noticed one on paper to enter this value later on for the modification I want to make. Here follow the steps to accomplish that.

/boot/grub/grub.cfg before the change
[...] if loadfont /usr/share/grub/unicode.pf2 ; then set gfxmode=640x480 insmod gfxterm insmod vbe if terminal_output gfxterm ; then true ; else # For backward compatibility with versions of # terminal.mod that don't # understand terminal_output terminal gfxterm fi fi [...]

Modification in /etc/default/grub
[...] # The resolution used on graphical terminal # note that you can use only modes which your graphic card # supports via VBE # you can see them in real GRUB with the command `vbeinfo' #GRUB_GFXMODE=640x480 # this is the original one GRUB_GFXMODE= 1024x768x32 # this is the modified value [...]

/boot/grub/grub.cfg after the change
[...] if loadfont /usr/share/grub/unicode.pf2 ; then set gfxmode=1024x768x32 insmod gfxterm insmod vbe if terminal_output gfxterm ; then true ; else # For backward compatibility with versions of # terminal.mod that don't # understand terminal_output terminal gfxterm fi fi [...]

The final step is to setup GRUB2 to boot from the Test partition on the HDD. To do so we will copy the structure of the "Windows XP" boot in the file /etc/grub.d/40_custom and modify it. The information we need for the modification is the unique identifier of the partition. To find it out we use the command blkid in the terminal. In Fig. Z we see the required info for each partition including the one with label "TEST". With this information, we can perform the final part of our modification.

Setup of GRUB2
Fig. Z - blkid in terminal

We copy the entry from grub.cfg and we paste it in 40_custom and perform the following settings:

  1. Set a name for the menu entry such as "Boot TEST (on /dev/sda2)"
  2. Change the file system from ntfs to fat16
  3. Set the root to the second partition
  4. Set the identification number of the partition
/boot/grub/grub.cfg before the change
[...] ### BEGIN /etc/grub.d/30_os-prober ### menuentry "Microsoft Windows XP Professional (on /dev/sda1)" { insmod ntfs set root='(hd0,1)' search --no-floppy --fs-uuid --set 26F4C476F4C44A2F drivemap -s (hd0) ${root} chainloader +1 } ### END /etc/grub.d/30_os-prober ### ### BEGIN /etc/grub.d/40_custom ### # This file provides an easy way to add custom menu entries. # Simply type the menu entries you want to add after this # comment. Be careful not to change the 'exec tail' line # above. ### END /etc/grub.d/40_custom ### [...]

/etc/grub.d/40_custom
#!/bin/sh exec tail -n +3 $0 # This file provides an easy way to add custom menu entries. # Simply type the menu entries you want to add after this # comment. Be careful not to change the 'exec tail' line # above. menuentry "Boot TEST (on /dev/sda2)" { insmod fat16 set root='(hd0,2)' search --no-floppy --fs-uuid --set 4065-3BDA drivemap -s (hd0) ${root} chainloader +1 }

Finally, we run the command update-grub and see the changes in grub.cfg.

/boot/grub/grub.cfg after the change
[...] ### BEGIN /etc/grub.d/30_os-prober ### menuentry "Microsoft Windows XP Professional (on /dev/sda1)" { insmod ntfs set root='(hd0,1)' search --no-floppy --fs-uuid --set 26F4C476F4C44A2F drivemap -s (hd0) ${root} chainloader +1 } ### END /etc/grub.d/30_os-prober ### ### BEGIN /etc/grub.d/40_custom ### # This file provides an easy way to add custom menu entries. # Simply type the menu entries you want to add after this # comment. Be careful not to change the 'exec tail' line # above. menuentry "Boot TEST (on /dev/sda2)" { insmod fat16 set root='(hd0,2)' search --no-floppy --fs-uuid --set 4065-3BDA drivemap -s (hd0) ${root} chainloader +1 } ### END /etc/grub.d/40_custom ### [...]

Now that everything is set the moment of the truth comes: reboot and see what happen. Indeed we have a new menu entry (Fig. AA) that allow us to boot directly from the partition 2 which of course is equivalent to a floppy without OS on it (Fig. AB). With this, we have concluded the setup of our test environment.

Setup of GRUB2
Fig. AA - new menu entry "Boot TEST"

Setup of GRUB2
Fig. AB - The "no system disk" error message in german

This was A LOT OF WORK to do! But from now on I have an HDD partition that I can use in the same way as if it was a floppy drive.
Did you manage to do the same on your PC? Tell me in the comment.



  1. The company I work for doesn't own the PC rather it lease them. At the end of the leasing period, the employee has the option to buy the old PC meanwhile my company starts new leasing of a newer one. [click back]
  2. "The platters of a common hard drive are not completely sealed off from the outside as many people think. Therefore, you can damage an HDD by running it at too high of an altitude where there is less air pressure[...]". Read full article on this page. [click back]
  3. update-grub is a stub for grub-mkconfig -o /boot/grub/grub.cfg. If the user wishes to create a boot menu with a different name or path, then he will use the full command with the -o switch. For istance if you want to test the result of the change made in the script and configuration files instead of overwriting grub.cfg then use grub-mkconfig -o /home/(username here)/Desktop/grub_test.cfg [click back]

<PREV.  -  ALL  -  NEXT>

Comments