Monday, November 2, 2009

Dual boot Windows 7 and Fedora Core 11

A first attempt in creating a dual boot system.

SETUP:

Create recovery disks for Windows 7.

Reference the fedoraproject.org documentation on installation options.

I shrank the default C drive partition to create free space for the Fedora installation. In the start menu, right click on the "Computer" item, then select "Manage". In the new window, on the right-hand list, select Disk Management. Shrink as appropriate.

I downloaded a boot.iso file that creates the minimum installation of Fedora so I could finish the installation from the internet.

I downloaded an iso recorder to burn the boot.iso file onto a cd. Supposedly, the windows option "Burn" found at the top of the file viewer window will not copy the iso in the proper format.

INSTALLATION:

(The initial mud walk)

The installation documentation for fedora was quite thorough. However, I was not warned that canceling the network setup would cause the installer to exit and then leave my computer unbootable! I didn't think the installation would affect anything outside the linux partition of the drive. Not sure what happened. Good thing recovery disks were made!!!

So second time around. Another installer issue. The installer hangs on the screen for selecting the partition arrangement. Seems like it didn't like the selection of "Use free space" and also checking the checkbox to review partitions. On my fifth time around, I selected "Create custom", clicked next, then went back and selected "Use free space". Not sure what the exact problem here was either.

Moving on ... the bootloader options. I am installing the bootloader on my one hard drive and selected only the linux partition. I expected an advanced settings screen to select whether I wanted to install the bootloader in the master boot record or the linux boot partition, but none followed. I went straight to network configuration and then install package selection. Afraid that going back would blow up the installation and cause me to go through hours of system recovery again, I just proceeded and finished the installation.

This installation set up grub as the bootloader with Fedora as default. Pressing any button within the first few seconds that grub starts up will bring up the menu. The configuration file for grub needed to be changed to start Windows. I used the following entry from http://www.cyberciti.biz/faq/grubconf-for-windows-vista-or-xp-dual-boot/

title Microsoft Windows 7
root (hd0, 0)
makeactive
chainloader +1

I also deleted the "hiddenmenu" command near the beginning of the file.

Things seem to be working ok except an error message when booting Fedora, supposedly involving a broken bios. This then causes the Fedora kernel to complain. Fedora still seems to work though. No problems on the Windows side though.

Friday, August 14, 2009

Talking to mysql in Haskell

With the mysql database installed and all the other needed libraries for odbc and haskell, I can now use the haskell module HDBC.ODBC to talk to the database...

Using ghci to test some statements:

I used the function "connectODBC ...", but it resulted in a disparaging "***Exception: (unknown)".

Then I saw an example online using "handleSqlError (connectODBC ... )" which gave me the reason for the exception.

I was successful with the statement:
handleSqlError (connectODBC "DSN=my_name_from_odbc.ini_file;USER=myName;PASSWORD=myPassword")

So, time to actually run a query on my database!

I used the following program:

main = DB.handleSqlError $ do
dbh <- connectODBC "DSN=myodbc;USER=myname;PASSWORD=mypasswd; DATABASE=mydb"
res <- DB.quickQuery dbh "SELECT name FROM Mushrooms" [ ]
showRows res

showRows :: [[DB.SqlValue]] -> IO ()
showRows rows = mapM_ ioResult rows
where ioResult = (putStrLn . formatRow . fromSql)

formatRow :: [String] -> String
formatRow row = concat $ List.intersperse ", " row

fromSql :: [DB.SqlValue] -> [String]
fromSql sqlList = map DB.fromSql sqlList

Monday, August 3, 2009

MySql setup

I was interested in setting up MySql so I could use it with a Haskell program.

General setup comments:

- Install cabal. I downloaded cabal-install-0.6.2.tar.gz. After unpackaging the archive, I ran the script bootstrap.sh. This took care of downloading and installing dependencies. I originally tried manual builds as outlined in the book Real World Haskell, appendix A, but gave up because of all the dependency errors. However, the bootstrap script may also require some manual downloading of missing components, and re-running the script.

- Install HDBC. First run 'cabal update' to obtain a list of packages available from Hackage. Then run 'cabal install hdbc'. This produced errors that needed to be fixed ( I am using Fedora 9 and HDBC 2.1.1). I followed recommendations on this bug report - http://software.complete.org/software/issues/show/164. Basically, modifications needed to be made to the hdbc package file "Database/HDBC/SqlValue.hs" and the convertible package file "Data/Convertible/Instances/Time.hs". I commented out all the instance declarations which had an error message about being a duplicate of what was found in the time-1.1.3 package. In order to make the changes above, I unpackaged the archives for the hdbc and convertible packages, made the changes to the .hs files, and then installed the packages by running 'cabal install' from within the top-level directory of the package.

- Install the driver hdbc-odbc. Running 'cabal install hdbc-odbc' produced errors about missing C libraries or headers. I installed the following:

unixODBC.i386 : A complete ODBC driver manager for Linux
unixODBC-devel.i386 : Development files for programs which will use the unixODBC library.

Commands used: 'yum install unixODBC.i386' and 'yum install unixODBC-devel.i386'.

- Apparently the above packages don't include a driver for Mysql to use with the driver manager unixODBC. So I downloaded one from Sun's website:

http://dev.mysql.com/downloads/connector/odbc/5.1.html

- Using ODBC required modifying the files odbcinst.ini and odbc.ini. These were in the directory /etc. A great resource on how ODBC works for linux and details on what is needed to get it working was found at:

http://www.easysoft.com/developer/interfaces/odbc/linux.html#what_is_odbc

and also: http://www.unixodbc.org/odbcinst.html

I used an odbcinst.ini file with these values:

[MySQL]
Driver = /usr/lib/libmyodbc5.so
UsageCount = 1

And an odbc.ini file with these values:

[MySQL-test]
Description = MySQL database test
Trace = Off
TraceFile = stderr
Driver = MySQL
Server = 127.0.0.1
Port = 3306
Option = 262144

Then I tested the ability to connect using the isql utility:

isql -v MySQL -test [mysql_username] [password]