Archive for the ‘Linux’ Category

Fix Broken Windows Boot After Installing Linux (grub)

Monday, October 8th, 2012

When you install Linux or another OS alongside Windows in a dual-boot configuration, the installation often sets up a boot loader like grub to manage the booting alternatives. This can sometimes break the Windows boot loader, which can cause problems in certain situations.

One situation is where you have a Windows hard drive and a Linux hard drive. It works fine as long as both drives are installed, but say you remove the Linux hard drive: you would expect the Windows drive to boot up straight into Windows. But instead you might get a message like “BOOTMGR is missing”.

Another situation that I ran into was that I could not upgrade Windows 7 to SP1 in my dual-boot configuration.  Reasons why are discussed here.  I had to revert the boot loader back to booting directly into Windows before the Windows 7 SP1 update would stick.

There are also a few other situations that might cause your Windows boot loader to get corrupted, and you probably don’t want to resort to restoring your entire drive from a backup image or re-installing Windows from the ground up.  So here’s one relatively easy way to fix your boot.

Repairing the Windows boot loader

Here is one way to repair the Windows boot:  Find a Windows Full or Upgrade install disc. Boot from it. When it comes up, select your language, then at the next screen, select the Repair Windows option at the bottom of the screen. Select the Startup Repair. Indicate which version of Windows you would like to repair, if it finds more than one installation on your hard drive. It will do some checking, and should find that your BootMgr is in need of repair. Tell it to repair the problem. After that it should boot directly into Windows again.

This works with a Windows 7 Upgrade disc.  I’m not sure about Windows XP.

Setting up Cygwin

Wednesday, September 19th, 2012

CygwinThis is my procedure for installing Cygwin on a Windows desktop. There are many ways to configure the Cygwin environment. This seems to work for me:

  1. Go to cygwin.com
  2. Download the Cygwin installer/updater to your desktop
    1. Choose setup_x86.exe (32-bit installation), or
    2. Choose setup_x86-64.exe (64-bit installation)
  3. Run it

Use the following settings to answer the setup questions:

Root dir:  c:\cygwin  (for 32-bit; or c:\cygwin64 for the 64-bit install)
Install for:  All users
Default file type:  DOS
Package dir:  c:\cygwin_install (recommended; can be deleted later)

Be sure to install the following packages:

Section  Package
------- -------
Net     inetutils
Net     ncftp
Net     openssh
Net     ping
Python  python
Python  python-imaging
Python  python-tkinter
Shells  chere
Shells  mintty
Shells  tcsh
Shells  xterm (for resize)
Utils   ncurses (for tset)
Web     wget

Set the HOME environment variable in Windows (Computer->Properties->Advanced->Environment Variables) (put your username instead of username):

Win XP:
HOME  c:\Documents and Settings\username
Win Vista/7/8:
HOME  c:\Users\username

Optional environment variables:

$JAVA_HOME
$OSG_HOME (OpenSceneGraph)
$OPENTHREADS_HOME
$ANT_HOME

Set the PATH environment variable. Cygwin will inherit the Windows PATH, but you need to add the directories containing the Cygwin executables. This is a very minimal .cshrc file. You will probably want to add a more sophisticated one. I have a small set of “dot” files that I copy into a user’s HOME directory when setting up Cygwin. To create the minimal .cshrc file, type the following lines at a shell prompt, ending with the <Ctrl-D> (Cygwin EOF) character:


/usr/bin/cat > $HOME/.cshrc
set path=(/usr/local/bin /usr/bin /bin $path)
setenv CYGWIN nodosfilewarning
<Ctrl-D>

Run the following commands (put your username instead of username):

Win XP:
/usr/bin/mkdir /home
cd /home
/usr/bin/ln -s /cygdrive/c/Documents\ and\ Settings/username/My\ Documents username
Win Vista/7:
/usr/bin/mkdir /home
cd /home
/usr/bin/ln -s /cygdrive/c/Users/username username

 

mintty shortcut:

C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico /bin/tcsh

Create ~/.Xdefaults containing the following:

rxvt.scrollBar_right: True
rxvt.visualBell: True
rxvt.cursorColor: red
rxvt.saveLines: 5000
rxvt.geometry: 80x40
rxvt.font: courier
rxvt.foreground: black
rxvt.background: white
xterm.scrollBar_right: True
xterm.visualBell: True
xterm.cursorColor: red
xterm.saveLines: 5000
xterm.geometry: 80x40
xterm.font: Consolas
xterm.foreground: black
xterm.background: white

Put mintty in the Windows Explorer folder right-mouse menu:

Run the following command to create a Windows Explorer context menu entry:

/usr/bin/chere -if -t mintty -s tcsh -e "Cygwin Terminal Here" -o "-i /Cygwin-Terminal.ico"

If you get an error like this:

Error (5): Access is denied.
/usr/bin/chere Error: Hive not writable
/usr/bin/chere: Aborting.

it is a UAC (permissions) problem.  Launch the shell as Administrator and try it again.

Modify /etc/csh.login as follows, to let the shell run by chere start in the proper directory:
Replace the last line:

cd

With:

if ( ! ${?CHERE_INVOKING} ) then
cd
endif

KeeFox on Ubuntu

Tuesday, May 8th, 2012

KeeFox is a plugin for Firefox that communicates with the KeePass2 password manager. I like KeePass2 because I can maintain a local secure password database without involving a server. It works great under Windows, and runs with Mono on Linux. However, KeeFox was complaining that the KeePassRPC.plgx plugin (in ~/.keepass/plugins) was incompatible. To fix it, I had to install the mono-complete package.

csh vs. sh

Thursday, February 9th, 2012

Sadly, this describes me: CSH Programming Considered Harmful

I’ll try to be better.

I found the article referenced above while trying to solve something that was turning out convoluted in my csh script (redirect just stderr to /dev/null). It was trivial in sh.

It is a definite trade-off, though, when it’s something you don’t use daily, where maintainability is a concern, and where you work with people who pull their hair out even at the csh syntax.

Convert 3ds files to obj with Blender

Tuesday, January 24th, 2012

Blender

3DS is an aging binary interchange format for 3D models. OBJ is another aging, but ASCII-based format for 3D models.

Here is a simple Python script that converts one or more files from 3DS format to OBJ format using Blender:

# Convert 3ds to obj using Blender
#
# Run as follows:
#   blender -b dummy.blend -P bl_3ds2obj.py -- file.3ds ...
#
# dummy.blend is just an empty Blender file needed as an argument.
# Put one or more .3ds files on the end of the command.
# The .obj files will be created with the same name (and path) as
# the .3ds file, but with the .obj extension.
# The export creates a .mtl file for each .obj file also.

import bpy
import sys
import os.path

for i in range(1, len(sys.argv)):
    if sys.argv[i] == "--":
        break

for file in sys.argv[i+1:]:
    # Start with an empty scene
    bpy.ops.object.select_all(action="SELECT")
    bpy.ops.object.delete()

    # Read a .3ds file
    bpy.ops.import_scene.autodesk_3ds(filepath=file)

    # Write a .obj file
    outfile = os.path.splitext(file)[0]+".obj"
    bpy.ops.export_scene.obj(filepath=outfile)

 

Save the script code in a file named blender_3ds2obj.py.  You will also need a Blender file to use as a placeholder in the command line.  You can save an empty file from Blender, or use an existing one.  Assume it is called dummy.blend.

To convert 3DS files, use the following command:


blender -b dummy.blend -P bl_3ds2obj.py -- file1.3ds file2.3ds file3.3ds

Tack on as many 3DS files to the end of the command as you want.

Note:  This assumes that dummy.blend and bl_3ds2obj.py are in the same folder as your 3DS files.  If not, you will need to specify the proper path to each.

Anticipation

Saturday, October 2nd, 2010

Segway, iPad, Heinz Ketchup? No, its…
The next version of Ubuntu is coming soon

Which Cygwin package contains a file?

Thursday, July 1st, 2010

Cygwin

You never have all the tools you need.  For Cygwin, I used to hunt through the package list and guess which package had what I was looking for.  Well there is a better way.  And someone else has already written about it.

This link tells you how to determine which Cygwin package contains a file.

In case that site disappears, here’s how (pretend we are looking for the strings command):

  • There’s a web way:
        http://cygwin.com/cgi-bin2/package-grep.cgi?grep=strings.exe
  • and there’s a command line way (if you already have Cygwin installed):

        cygcheck -p strings.exe

…and the answer is… binutils!

Ubuntu Lucid Lynx upgrade breaks Grub boot loader

Thursday, May 27th, 2010

Today I upgraded my laptop, which dual boots Ubuntu and Windows 7, to Lucid Lynx (Ubuntu 10.4).  Towards the end of the upgrade it said it was upgrading Grub (the multi-OS boot loader) to Grub2.  It then asked me some questions about which partitions to modify.

Apparently I answered wrong, because when the upgrade finished and I rebooted, I got an error message from Grub: “Error 4: Symbol ‘grub_puts_’ not found“.  I ended up at a prompt that said “grub-rescue>” where very few commands worked.  Even “help” was not recognized.

Thankfully, others had blazed the trail.  A little web searching turned up a procedure for repairing the Grub install.  (Note:   the first command should be “sudo fdisk -l” with a space dash lower-case L).  I just booted from the Ubuntu LiveCD and followed the procedure.  That resurrected Grub and allowed me to boot successfully into Linux.

Well, as you might have guessed, my Windows 7 boot had also been clobbered.  To fix that, I had to boot from the Windows 7 CD and follow these instructions.

Finally, here are a couple of other informational references for Grub 2:

Many thanks to those who went before, battled the dragons, lived to tell the tale, and took the time to tell it.

How to squelch the Cygwin DOS path warning

Wednesday, March 17th, 2010

CygwinIn Cygwin version 1.7 they added a “feature” that would warn you about using DOS-style paths on the command line.

my-cygwin-pc> cd c:/<TAB>cygwin warning:
 MS-DOS style path detected: c:/
 Preferred POSIX equivalent is: /cygdrive/c
 CYGWIN environment variable option "nodosfilewarning" turns off this warning.
 Consult the user's guide for more details about POSIX paths:
 http://cygwin.com/cygwin-ug-net/using.html#using-pathnames

At least this only happens the first time during the session, but I still wanted it gone.

So I tried to turn it off, but the instructions were a little ambiguous to me.  I tried setting a nodosfilewarning environment variable in my .cshrc.  I actually tried it several different ways:

setenv NODOSFILEWARNING 1
setenv nodosfilewarning 1
set nodosfilewarning=1

Turns out none of these are right.  You need to set a Windows environment variable named CYGWIN:

 

Mystery solved.