WINE tips: File associations for Windows applications in Linux (continued)

There is a downside to the approach described in my previous post regarding file associations for Windows applications run via WINE, at least in the case of KDE.

By using KDE’s ‘System Settings’ > ‘File Associations’ to change the application launch command from:

env WINEPREFIX="/home/fitzcarraldo/.wine-visio5" WINEARCH="win32" wine /home/fitzcarraldo/.wine-visio5/drive_c/Program\ Files/Visio/Visio32.EXE

to:

env WINEPREFIX="/home/fitzcarraldo/.wine-visio5" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix %U

the launch command in KDE’s Kicker application launcher menu is also changed to the latter. Trying to launch the Windows application from the Kicker menu (Wine > Programs > a_Windows_application) then fails. Presumably this is because the wine command expects a filename (the %U in the command string) but that is not being provided.

Alternative 1

One solution is to use a shell script as described in my earlier post: WINE tips: How to associate IrfanView with an image file type in Linux. Kicker can still be used to launch the application (e.g. Wine > Programs > IrfanView) when the menu command is of the following form but no filename is provided (even though the %f is left in the command string):

/home/fitzcarraldo/launch_IrfanView.sh %f

Alternative 2

Another solution – well, really a work-around – is to accept that the Windows application cannot be launched from the Kicker menu and to create a separate Desktop Configuration File in /home/fitzcarraldo/Desktop/ which uses a different command to launch the application. For example, in my previous post the file association I configured via ‘System Settings’ > ‘File Associations’ for Visio was:

env WINEPREFIX="/home/fitzcarraldo/.wine-visio5" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix %U

and therefore the command in the Kicker menu entry is the same, but I created a Desktop Configuration File which I named ‘/home/fitzcarraldo/Desktop/Visio 5 Professional‘ which contains the command:

env WINEPREFIX="/home/fitzcarraldo/.wine-visio5" WINEARCH="win32" wine /home/fitzcarraldo/.wine-visio5/drive_c/Program\ Files/Visio/Visio32.EXE

$ ls -la ~/Desktop/Visio*
-rwxrwxrwx 1 fitzcarraldo users 562 Aug 26 17:42 /home/fitzcarraldo/Desktop/Visio 5 Professional

Notice that the command to launch the Windows application does not contain a filename parameter (%U), so when I double-click on the icon on the Desktop it launches Visio.

Summary

Ideally, KDE should be changed to allow the application launching command in ‘System Settings’ > ‘File Associations’ to be edited to be different to the application launching command in the Kicker menu. In the absence of that, you have two alternatives in the case of WINE:

  1. Create a shell script to launch the application. This allows you to launch the Windows application via Kicker and by double-clicking on a file of the applicable type.

    or

  2. Create a separate Desktop Configuration File in e.g. the ~/Desktop/ directory. This allows you to launch the Windows application by double-clicking on a Desktop Configuration File for the application and by double-clicking on a file of the applicable type. However you cannot launch the application from its entry in the Kicker menu.

WINE tips: File associations of Windows applications in Linux

I have several applications for Windows installed under WINE in Linux. These applications launch correctly if I double-click on a file for that application, but, in the case of some of these applications, the file itself is not opened. Therefore I first have to launch the application and then load the file from within the application (File > Open, or whatever). Some time ago I explained how to fix this in the case of IrfanView by creating a shell script – see my post WINE tips: How to associate IrfanView with an image file type in Linux – but there is an easier way to do it in many cases, as illustrated by the example below for another Windows application I use regularly in Linux. I finally got fed up with not being able to open .vsd (Visio drawing) files by double-clicking on them in Linux, and decided to fix this. The same procedure applies, whatever the Windows application.

I use KDE, but the principle applies whatever Desktop Environment you are using. Just use the relevant File Association configuration tool for that Desktop Environment.

  1. I selected ‘System Settings’ > ‘File Associations’ from the KDE Kickoff menu launcher.

  2. I entered ‘vsd’ (without the quotes) in the search field in order to find the application associated with that file type.

    The ‘Known Types’ box then displayed the following:

    >- application

  3. When I expanded that by clicking on it, the ‘Known Types’ box displayed the following two application file types:

    v- application
            vnd.ms-visio.viewer
            vnd.visio

  4. Clicking on either displayed ‘Visio 5.0 Professional’ in the ‘Application Preference Order’ box. I selected it and clicked on ‘Edit…’, which opened a Properties window for the application’s desktop configuration file.

  5. I clicked on the ‘Application’ tab. The ‘Command’ box contained the following command:
    env WINEPREFIX="/home/fitzcarraldo/.wine-visio5" WINEARCH="win32" wine /home/fitzcarraldo/.wine-visio5/drive_c/Program\ Files/Visio/Visio32.EXE

    (The wine command itself has to be preceded by the definition of the WINEPREFIX and WINEARCH environment variables because I specified those environment variables originally when I installed the application via WINE.)

    I changed the command to be the following:

    env WINEPREFIX="/home/fitzcarraldo/.wine-visio5" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix %U

    for both vnd.ms-viso.viewer and vnd.visio application file types, and clicked on ‘OK’ and ‘Apply’.

That’s all there was to it. Now when I double-click on any file ending with ‘.vsd’, Visio launches as before but the actual file is opened in the application. Very straightforward, and I really should have made the effort to fix it sooner. :-)

Installing the Windows version of Google Earth in WINE

Some Gentoo Linux users have reported that, although the native Linux release of Google Earth crashes, they can run the Windows version successfully under WINE. However, those users have also reported that the Windows installer for Google Earth did not work under WINE and so they copied the C:\Program Files\Google\Google Earth\ directory from a Windows PC to the virtual C:\ drive in their .wine directory (it would be ‘Program Files (x86)‘ in a 64-bit Windows installation, as Google Earth is a 32-bit application).

Now, if you download the Windows Google Earth installer from the Google Web site, what you get is a file GoogleEarthWin.exe that is 534.6 KiB in size (the size may vary depending on the release). However, you can instead download the Offline Installer using the following URL:

http://dl.google.com/earth/client/advanced/current/GoogleEarthWin.exe

and then you get a file GoogleEarthWin.exe that is 24.3 MiB in size (the size will vary depending on the release), which does run in WINE and does install the Windows version of Google Earth in WINE.

So, you might like to try that if you cannot run Google Earth in Linux but you have WINE installed. However, note that you will be wasting your time if the native Linux version of Google Earth crashes because of its incompatibility with the closed-source ATI or NVIDIA video driver. For example, Google Earth 7.1.2.2041 for Linux crashes on my main laptop using the 14.3_beta version of ati-drivers (AMD ATI Catalyst driver, a.k.a. FGLRX).

Anyway, if you want to install the Windows release of Google Earth under WINE here’s how to do it in a Konsole/Terminal window:

$ cd
$ export WINEPREFIX=$HOME/.wine-googleearth
$ export WINEARCH="win32"
$ winecfg
$ cd ./.wine-googleearth/drive_c/
$ wget http://dl.google.com/earth/client/advanced/current/GoogleEarthWin.exe
$ wine GoogleEarthWin.exe

And, to run it later:

$ env WINEPREFIX="/home/fitzcarraldo/.wine-googleearth" WINEARCH="win32" wine C:\\windows\\command\\start.exe /Unix /home/fitzcarraldo/.wine-googleearth/dosdevices/c:/users/fitzcarraldo/Start\ Menu/Programs/Google\ Earth/Google\ Earth.lnk

(Of course replace “fitzcarraldo” with your user name.)

But, as I wrote above, if the native Linux version of Google Earth crashes due to its incompatibility with the closed-source video driver (ATI or NVIDIA), it is highly unlikely the native Windows version will work under WINE.

Can Linux cope with 24 Hours of Happy?

I enjoyed Pharrell Williams’ feel-good songs in ‘Despicable Me‘ and its sequel, ‘Despicable Me 2‘. ‘Happy‘, a very catchy ditty he wrote for the sequel, also features in the World’s first 24-hour-long music video, ‘24 Hours of Happy‘, shot in and around Los Angeles and released on 21 November last year. The song is played a total of 360 times over the duration of the video, each 4-minute take featuring a different person or persons dancing (improvised) along streets, in petrol stations, through Union Station, in a church, around a school, in a moving school bus, around a supermarket, in a bowling alley, and so on. Each 4-minute performance was filmed in one take using Steadicam, and the location at the end of each take segues into the next take. You see the sun rise; you see the bright sunlight of the morning and the warm sunlight of the afternoon; you see the sun set; you see the twinkling city lights at night. The concept is simple yet brilliant.

Clips from some of the takes were used to create the 4-minute official music video for ‘Happy’, so you can watch that on YouTube to get a flavour of the takes, although it does not do justice to the full video.

Williams appears in a different take every hour on the hour, and a few other takes have celebrity cameos, but the vast majority of the participants are unknown extras of all ages, races, shapes, sizes and looks. To quote Williams talking to the Los Angeles Times: “We wanted all humanity in there, not just the model-types you might expect.” Some are good dancers, others not so good. But they all have one thing in common: they’re having fun, so they look good. The joy is infectious, and I found myself watching far longer than I would have expected, having to return to the site again and again. Half the fun is watching the bystanders.

When you open the ’24 Hours of Happy’ site, the take that was in progress at the current time of day starts playing from the beginning. However, you can drag the pointer around the clock dial and watch any take from the 24-hour period. There are also buttons you can click on to jump between takes or to jump to each take featuring Williams. The yellow on-screen controls can be made to disappear by not moving the mouse pointer for 5 seconds.

Still from 24 Hours of Happy, showing on-screen controls

Still from 24 Hours of Happy, showing on-screen controls

The Web site is well-designed and fun to use, so I was not surprised it was voted ‘Site of the Month‘ and ‘Site of the Year Users’ Choice‘ by AWWWARDS, and voted ‘Site of the Month‘ and ‘Site of the Year‘ by TheFWA.

It’s impossible to list them all, but a few of my favourite takes are:

01:36  Very perky woman with ponytail.
05:28  Jogger who has to keep pulling his shorts up!
08:24  Woman on roller skates.
09:52  Very cute little girl.
09:56  Woman with some groovy moves.
10:40  Woman in Union Station. Some of the bystanders are particularly amusing.
11:16  Man with cast on foot.
11:20  Boy with an Afro.
11:36  Three groovy old ladies.
11:44  Chubby guy with style.
12:36  Woman with some groovy moves.
13:32  Dancing couple in pink.
14:20  Two cool guys in dinner jackets inside and outside Union Station.
15:00  Pharrell Williams in a church with a gospel choir.
19:04  Woman with a lizard puppet. The lizard does the lip-synching!
19:36  Guy on stilts.
23:40  Woman with LED hula hoop (love it!).

If you want to start viewing a take made at a specific time of day, you can append the time to the URL, like so:

http://24hoursofhappy.com/09h53am

Obviously I think ’24 Hours of Happy’ is fabulous, but why am I discussing it in a blog predominantly about Linux? Because Firefox 27.0.1 (32-bit) running in Windows 8.1 (64-bit) on my new Acer Aspire XC-600 micro-tower PC (dual-core Intel Pentium G2030 @ 3 GHz & 3 MB cache, 4 GB DDR3 RAM) handles ’24 Hours of Happy’ at 720p with ease, but the story is very different on my main laptop running 64-bit Gentoo Linux with KDE (quad-core Intel Core i7 720QM @ 933 MHz & 6 MB cache, 4 GB DDR3 RAM). Both machines are on my home network, connected to the Internet via high-bandwidth broadband (FTTC).

On my laptop, the latest available versions of Firefox (27.0) and Opera (12.16_p1860-r1) for Gentoo, both 64-bit, do not even complete loading the ’24 Hours of Happy’ site: the black progress bar at the bottom of the home page stops about 7/8th of the way across the page and the KDE Network Monitor widget shows there is no network activity. Clearing Firefox’s Web content cache or increasing the cache’s size to 1 GB make no difference. Konqueror 4.12.2 (configured to use the WebKit browser engine rather than the KHTML engine) loads the site and plays it quite well at 720p to start with, but eventually video becomes choppy and I notice a lot of spawned kio_http processes. The KDE Network Monitor widget shows a continuous 3600 Kib/s data stream, which does not stop when I exit Konqueror. Numerous kio_http processes are spawned and remain after I exit Konqueror, and the 3600 KiB/s activity on the network only ceases when I kill all the kio_http processes. The number of spawned kio_http processes increases if I drag the pointer around the clock to select different takes, and the page just displays ‘LOADING’ ad infinitum if I do this several times. To be fair, if I do this a lot in Firefox running in Windows 8.1, I can get Firefox to stall too. I thought I’d try a lightweight browser and installed NetSurf (3.0-r1), but that couldn’t even render the title on the home page, let alone begin to load the video.

So, does ’24 Hours of Happy’ play nicely in your Linux installation? If it does, what hardware, distribution, desktop environment, browser and quality (360p, 480p, 720p or 1080p) are you using?

ARTE Live Web videos

The Franco-German cultural Web site ARTE Live Web is an excellent resource for lovers of music (classical, jazz, alternative and World) and dance. The show videos at the site are enjoyable but unfortunately only viewable for a fixed period of time before the site removes them. Back in 2011 I wanted to download the video of a performance I’d attended and loved. I searched for a Linux tool but could not find one, then found a Windows freeware GUI tool called artepupper, and used version 0.2 to download the video. You can read about the tool on the author’s blog pages artepupper 0.1, artepupper 0.2 and artepupper 0.3. The reason for the change from 0.2 to 0.3 was that ARTE Live Web changed the format of an embedded URL inside the XML page for the video on their Web site.

Now, artepupper is based on livewebarte1.1.sh, a 2010 Bash script by Carmelo Ingrao, and a Perl script livewebarte.pl by Juan Domingo based on livewebarte1.1.sh, both of which are still available on line at Carmelo’s download page and which I only discovered after using artepupper in Windows. I tried the Perl script in Linux back in 2011, and it worked for me.

Recently I wanted to download another video from the ARTE Live Web site and found that, although artepupper 0.3 in Windows worked, the Perl script livewebarte.pl no longer worked. Presumably this was because of the aforementioned change to the embedded URL. However, I found that the Bash script livewebarte1.1.sh still worked. Actually, I had to edit the script to replace “./rtmpdump” with “rtmpdump“, as I had installed the command-line tool rtmpdump using the Linux distribution’s package manager and the executable is not stored in the same directory as the Bash script. But, apart from that, it worked.

Carmelo is a star for having deciphered how to access and download videos from the site. However, looking at his Bash script, the part where he parses a line in the XML code and extracts a string between the delimiters “MP4″ and “mp4″ is based on a hard-coded character position, which could change if the Web site’s owners change the format of the URL. So I decided to modify the Bash script to avoid using character positions to extract a string. The Bash script livewebarte1.2.sh is an updated version of Carmelo’s livewebarte1.1.sh script.

#!/bin/bash
# Script pour récupérer les vidéos FLV du site liveweb.arte.tv
# par Carmelo Ingrao <carmelo42@gmail.com> http://c.ingrao.free.fr/code/
# version 1.0
# release date 21 février 2010
## modified by Fitzcarraldo 24 April 2013
## version 1.2
## release date 24 April 2013
# licence : GPLv2
# rtmpdump compilé doit être dans le même répertoire que le script
## rtmpdump must be installed and in user's $PATH (e.g. I have it in /usr/bin/)
# utilisation du script :
#
# ./script.sh url fichier.flv
# _______________

# url --> $1
# fichier --> $2

# fichier de sortie
# on efface l'écran avant de commencer
clear

# on affiche les infos sur le script
echo "livewebarte.sh version 1.0."
echo "(c) 2010 Carmelo Ingrao; License : GPL"
echo "livewebarte.sh version 1.2."
echo "updated from version 1.1 by Fitzcarraldo on 24 April 2013; License : GPL"
echo "usage : ./livewebarte.sh url_concert_sur_liveweb.arte.tv fichier.flv"
echo "rtmpdump must be installed and in your path."

# on télécharge le code source de la page streamant le concert dans le fichier sourceconcert.html
wget $1 -O sourceconcert.html

# on récupère le numéro d'event et on le copie dans eventok.txt
#cat sourceconcert.html | grep "new LwEvent" > event.txt
#cat event.txt | cut -b "15 16 17" > eventok.txt
grep "new LwEvent" sourceconcert.html | grep -E -o -e "[0-9]+" > eventok.txt

# on prend le fichier XML d'arte et on crée l'url avec le bon numéro d'event
# xmloriginal="http://arte.vo.llnwd.net/o21/liveweb/events/event-610.xml"

# url du xml sans le numéro d'event original (pour faciliter)
xmloriginal2="http://arte.vo.llnwd.net/o21/liveweb/events/event-"

# on assigne à la variable b le contenu de eventok.txt --> numéro correct d'event
b=$(cat eventok.txt)

# on créer l'url correct du fichier XML qu'on téléchargera
xmlok=$(echo $xmloriginal2$b)
finxml=".xml"
xmlfinal=$(echo $xmlok$finxml)

# on télécharge le bon XML
wget $xmlfinal -O xmlok.xml
echo "Fichier XML téléchargé"

## I have changed the code in this part:
# on extrait le nom du fichier MP4 depuis le fichier xmlok.xml
mp4hd=$(cat xmlok.xml | grep "urlHd")
# on efface le début de l'url du MP4
# on efface le surplus à la fin du nom du MP4 et on sauve le nom dans la variable mp4hdcut2
mp4hdcut2=${mp4hd#*MP4}
mp4hdcut2=${mp4hdcut2%%mp4*}
mp4hdcut2="MP4"$mp4hdcut2"mp4"
## end of my changes to evaluate mp4hdcut2

# on lance la commande rtmpdump avec les paramètres
# rappel :
# $2 = nom du fichier de sortie
# $mp4hdcut2 = nom du fichier MP4

## Carmelo had ./rtmpdump here, but I removed the "./"
rtmpdump -r rtmp://arte.fcod.llnwd.net:1935/a2306/o25 -a a2306/o25 -f LNX 10,0,45,2 -W http://liveweb.arte.tv/flash/player.swf -t rtmp://arte.fcod.llnwd.net:1935/a2306/o25 -p http://liveweb.arte.tv/ -o $2 -y $mp4hdcut2

# on efface les fichiers crées
rm sourceconcert.html
#rm event.txt
rm eventok.txt
rm xmlok.xml

# Affichage des infos de fin
echo "________"
echo "Voilà, le téléchargement est terminé."
echo "Le fichier se trouve ici :"
echo " "
echo $2
echo " "
echo "Bon visionnage"
echo " "
echo " "
exit 0

Save it in your home directory and make it executable:

$ chmod +x livewebarte1.2.sh

Also make sure you have the package rtmpdump installed and that it is in your $PATH.

Then you can browse the ARTE Live Web site and select the performance video you wish to download. Hover the mouse pointer over the video pane and click on “INTEGRER LA VIDEO” to find the URL for that video, which will be of the form http://liveweb.arte.tv/fr/video/foo/, where “foo” is some string of characters (not literally “foo”, of course). The command to download it is then as shown below. I’ll use a file name foo.flv here, but any prefix would do:

$ ./livewebarte1.2.sh http://liveweb.arte.tv/fr/video/foo/ foo.flv

Note that it is essential to include the forward slash at the end of the URL. The file will be downloaded to your home directory and you can watch it in VLC or any other Linux media player that plays Flash video.

So there you have it; currently you can use artepupper 0.3 in Windows or livewebarte1.2.sh in Linux to download from ARTE Live Web a video of a performance you attended and loved.

How to play MSS2 codec (Windows Media Video 9 Screen) .wmv files in 64-bit Linux

One type of legacy .wmv file uses the ‘Windows Media Video 9 Screen’ MSS2 codec (“DMO-based codec, optimized for low-bitrate sequential screen captures or screencasts”, according to Wikipedia). Now, it is not possible to use win32codecs with the 64-bit versions of Linux multimedia players, so they cannot play .wmv files that use the MSS2 codec. However, there is a way around this: use the Windows version of SMPlayer in WINE. Below I explain the procedure I used to enable me to play .wmv files that use the MSS2 codec.

1. I surfed over to the download page of the MPlayer Web site and downloaded to ~/Desktop/ the installer for the latest version of SMPlayer for Windows (smplayer-0.6.9-win32.exe at the time of writing).

2. I configured WINE and installed SMPlayer for Windows:

$ cd
$ export WINEPREFIX=$HOME/.wine-smplayer
$ export WINEARCH="win32"
$ winecfg
$ cd .wine-smplayer/drive_c/
$ cp ~/Desktop/smplayer-0.6.9-win32.exe .
$ wine smplayer-0.6.9-win32.exe

3. I launched SMPlayer for Windows:

As I had opted to use a WINEPREFIX, to launch SMPlayer (Windows version) from the command line I would need to enter the following command under my normal user account:

env WINEPREFIX="/home/fitzcarraldo/.wine-smplayer" WINEARCH="win32" wine /home/fitzcarraldo/.wine-smplayer/drive_c/Program\ Files/SMPlayer/smplayer.exe

Instead it was easier for me to edit the Desktop Configuration File that was created on the Desktop, and also edit the menu entry that was created in the Kickoff menu, to execute the above command for me. Now all I need to do to launch SMPlayer for Windows is either to select it from Kickoff > Applications > Wine > Programs > SMPlayer > SMPlayer or to double-cick on the SMPlayer for Windows icon on my Desktop.

EDIT (December 11, 2012): OK, for those of you having trouble seeing the video component and only hearing the audio component of a .wmv file using MSS2, you need to do the following:

When you launch the SMPlayer 0.6.9 Setup program (wine smplayer-0.6.9-win32.exe) and click on Next and accept the Licence Agreement, make sure Binary Codecs (under MPlayer Components) is ticked.

When you launch SMPlayer for Windows and open the .wmv file, click on Options > Preferences to open the Preferences window. Click on General in the left pane, then click on the Video tab in the main pane and select “directx (fast)” or “directx(slow)” as the Output driver. I have just done this again (I’m currently using WINE 1.5.18) and I’m watching a MSS2-encoded .wmv file ‘Kai_Software2.wmv’ as I type this, as shown in the information listed by SMPlayer for Windows:

Kai_Software2.wmv
General
File H:/Kai_Software2.wmv
Size 3193 KB (3 MB)
Length 00:04:33
Demuxer asf

Video
Resolution 883 x 720
Aspect ratio 1.22639
Format MSS2
Bitrate 100 kbps
Frames per second 1000.000
Selected codec wmsdmod

Initial Audio Stream
Format 353
Bitrate 16 kbps
Rate 22050 Hz
Channels 1
Selected codec ffwmav2

Audio Streams
# 0
Language
Name
ID 1

Just to recap:

$ cd
$ export WINEPREFIX="/home/fitzcarraldo/.wine-smplayer"
$ export WINEARCH="win32"
$ winecfg
$ cd /home/fitzcarraldo/.wine-smplayer/drive_c/
$ cp ~/Downloads/smplayer-0.6.9-win32.exe ~/.wine-smplayer/drive_c/
$ wget http://winetricks.org/winetricks
$ chmod +x ./winetricks
$ ./winetricks # 'Select the default wineprefix' + OK first then 'Install a Windows DLL or component' + OK and tick 'allcodecs' and OK.
$ wine smplayer-0.6.9-win32.exe # Make sure Binary Codecs is ticked.

Help for Windows users: How to create a Linux LiveCD, LiveDVD or LivePenDrive from an ISO file

Existing Linux users are completely familiar with ISO image files, LiveCDs and LiveDVDs, but a newcomer to Linux may have never heard of ISO files, let alone created a LiveCD or LiveDVD. I was reminded of this yesterday when a confused Windows user contacted me to ask how to create a LiveCD, so I thought I’d post the instructions here as they may help other Windows users wanting to create a bootable LiveCD, LiveDVD or pen drive in order to try Linux without installing it, or indeed to use to install Linux to their hard drive.

In this particular case the Windows user wanted to create a LiveDVD for 64-bit Sabayon Linux 5.5 KDE Edition, so I oriented my instructions to Sabayon Linux. But the procedure is essentially the same for other Linux distributions that release ISO files for the creation of LiveCDs or LiveDVDs.

Below I cover two options: the creation of a bootable ‘Live’ optical disc (be it a CD or a DVD), and the creation of a bootable ‘Live’ pen drive. Steps 1 to 3 below are common to both options.

1. Download e.g. the ISO file for 64-bit Sabayon Linux 5.5 KDE Edition from one of the repository mirrors listed on the Sabayon Linux Web site’s Download page. For example: http://na.mirror.garr.it/mirrors/sabayonlinux/iso/Sabayon_Linux_5.5_amd64_K.iso

2. Find the MD5 checksum of the ISO file you downloaded. In Windows you can do this by using e.g. the freeware GUI utility WinMD5sum.

3. Visually compare the MD5 checksum with the MD5 checksum listed in the .md5 file for the ISO file you downloaded in Step 1 (some distributions just list the MD5 checksum on the Download page, rather than issuing a file). For example: http://na.mirror.garr.it/mirrors/sabayonlinux/iso/Sabayon_Linux_5.5_amd64_K.iso.md5

If they differ then the downloaded ISO file is corrupt, so go back to Step 1, otherwise proceed to Step 4.

Option A: How to create a LiveCD/DVD via Windows

If the ISO file size is less than the capacity of a CD-R (usually 650 MiB, but check on the media box or disc label) then use a CD-R. If the ISO file size is bigger than the capacity of a CD-R then use a DVD-R. If you burn to a CD-R then you will create a ‘LiveCD'; if you burn to a DVD-R then you will create a ‘LiveDVD’. Even if the ISO file is smaller than the capacity of a CD-R, there is nothing stopping you using a DVD-R instead of a CD-R if you wish.

4. Burn the ISO file to a blank optical disc, but not as a data file: you need to select the ‘Burn Image’ or ‘Burn ISO’ option in your burning utility. Optical media and optical drives are notoriously fickle, so burn using a low speed e.g. x1 or x2 in order to maximise the chance of a good burn. There are many commercial and freeware burning utilities for burning to CD-R and DVD-R. Commercial burning utilities include well-know applications such as Nero and Roxio. There are also many freeware burning utilities which you can find using e.g. Google. The Sabayon Linux Wiki article HOWTO:_Burn_Sabayon_from_Windows recommends the freeware burner ISO RECORDER but you can also find others using Google.

Many burning utilities have a Verify option to check that the burn was successful. If the utility you use does have such an option, select it. If it does not have a Verify option, there are other ways of checking the burnt CD/DVD in Windows (and Linux) if you want to. For example, see Method 3 in Sabayon Linux Wiki article HOWTO: Checking the integrity of a LiveCD or LiveDVD.

5. Boot the LiveCD/DVD to see if it works. You may need to configure your computer’s BIOS to boot first from an optical drive, or your computer may have a boot menu option which lets you select which drive to boot.

Option B: How to create a LiveCD/DVD on a pen drive (I call this a ‘LivePenDrive’) via Windows

This is only viable if your computer has a BIOS option to boot from USB pen drives, or a boot menu option to boot from USB pen drives. Legacy computers did not have these options, so, if you have an old computer that cannot boot from a pen drive, your only option would be to create a ‘Live’ optical disc.

4. Download the utility UNetbootin for Windows, and install it.

5. Run UNetbootin to create the LivePenDrive using the ISO file you downloaded. In the UNetbootin GUI window, don’t tick ‘Distribution’, tick ‘Diskimage’. Then select ‘ISO’, browse (use the ‘…’ button) to the folder containing the ISO file and select it. Make sure you have selected Type: ‘USB Drive’, and Drive: the drive letter for the pen drive. The pen drive will probably be D:\ or E:\ but, if you are not sure, check in Start > Computer (Start > My Computer if you are using Windows XP).

6. Boot the LivePenDrive to see if it works. You may need to configure your computer’s BIOS to boot first from a pen drive, or your computer may have a boot menu option which lets you select which drive to boot.

The beauty of using a pen drive is that you can overwrite its contents in future if you want to create a LivePenDrive of a newer version of the same Linux distribution or a different distribution. Unlike a CD-R or DVD-R, which will probably end up being thrown away when a new version of the ISO is released. Another advantage of using a pen drive is that the creation of a LivePenDrive is more reliable than burning an optical disc. It is not uncommon to end up with a corrupted optical disc, which is just a waste of plastic.

The best way to dual boot Linux and Windows

I’m going to explain how to configure your PC in order to dual boot Linux and Windows Vista or Windows 7, assuming Windows is already installed.

If you already have Windows Vista or Windows 7 installed in a single partition, then the method described below is the best way of ensuring that your Windows installation will still be bootable even if the Linux installation or GRUB bootloader become damaged in future.

Furthermore, if your PC has a hidden factory restore partition for Windows, the method described below is the best way of ensuring that you will still be able to recover Windows in future using that hidden partition. The reason why this is the best method is because it does not alter the contents of the MBR (Master Boot Record), which, in addition to the Windows bootloader, may contain code created by the manufacturer to boot the hidden factory restore partition instead of the Windows Vista/7 partition if it detects that you pressed a defined key or keys while the PC is booting. If the contents of the original MBR are overwritten — even if it is only by using the Bootrec.exe tool on a standard Windows Vista/7 Installation DVD — then the manufacturer’s code will no longer be in the MBR and so it will no longer be possible to boot the hidden factory restore partition by pressing the key(s) specified by the manufacturer.

Note also that some Windows applications can make a PC using GRUB 2 unbootable if GRUB 2 is installed in the MBR. See the blog article Windows applications making GRUB 2 unbootable for details. The method described below does not install any GRUB 2 code in the MBR, and thus it will avoid this problem.

So, to reiterate, the method described below avoids two potential major problems: 1) it avoids the possibility of making a Windows factory restore partition unusable; 2) it avoids the possibility of Windows applications overwriting some of the GRUB 2 code.

If you already have Windows installed, the procedure to prepare the PC and install Linux is divided into the following three main stages.

Stage 1: Reduce the size of the existing Windows partition

Do not use the partition managers Parted, GParted or KDE Partition Manager to reduce the size of the existing Windows partition, or you will damage your Windows installation.

Step A: Use the Windows defragmenter or a third-party defragmenter to defragment the Windows partition.

Step B: Use Windows’ Disk Management to shrink the partition (see Resize a Partition for Free in Windows 7 or Vista). The problem with this method is that Windows will only shrink the partition until it reaches the MFT (Master File Table), which means there may be free space in the Windows partition that you would have wanted to use in a Linux partition but cannot. However, if you are satisfied with the resulting size of the Windows partition then you can skip Step C below and proceed directly to Stage 2.

Step C: If you cannot shrink the Windows partition to the size you want by using Windows’ Disk Management, then you need to move the MFT (see Working Around Windows Vista’s “Shrink Volume” Inadequacy Problems). Basically you need to download a tool such as PerfectDisk (it has a free trial period) that will defragment the Windows partition and move the MFT in the process.

Stage 2: Create the new partitions for Linux

Boot a LiveCD or LiveDVD which has the partition editor GParted on it, and run GParted to create and format partitions for Linux (for example /, /boot, /home and swap) in the free space you created in Stage 1 above. I prefer to use GParted to create the partitions before running the Linux distribution’s installer, rather than using a partitioning tool integrated into the Linux installer itself. GParted has more functionality and enables better control over the partitioning process than a partitioning tool incorporated in the Linux distribution’s installer. Also, I have found on some occasions that installation of some Linux distributions fails if using the partitioning tool integrated in the Linux installer, but is successful if the partitions were created beforehand.

SystemRescueCD is a good LiveCD to use for running GParted, but any LiveCD/DVD which includes GParted will suffice. You can download the ISO file from the SystemRescueCd Web site http://www.sysresccd.org/Main_Page.

It is only possible to have up to four primary partitions on a hard disk, so, depending on the Linux partitions you decide to create, it is possible that you will need to create an extended partition containing logical partitions. If, for example, your hard disk has a hidden Windows factory restore partition and a partition for Windows itself, and you decide you want to have /boot and /home on separate partitions to the root directory, then one of many possible partitioning schemes would be:

- the hidden Windows factory restore partition (a Primary partition)

- the Windows partition (a Primary partition)

- the /boot partition (a Primary partition)

- an Extended partition containing the following Logical partitions:

- the swap partition

- the / (root) partition

- the /home partition

For example, on my main laptop I created and formatted the partitions /dev/sda3 to /dev/sda7 as follows:

/dev/sda1 – the hidden Windows factory restore partition

/dev/sda2 – the Windows C: drive partition

/dev/sda3 – the Linux /boot partition

/dev/sda4 – an Extended partition containing the following Logical partitions:

/dev/sda5 – the swap partition

/dev/sda6 – the / (root) partition

/dev/sda7 – the /home partition

Note that it is not essential to have /boot, / and /home in different partitions; they could all be in the same partition. However, I would recommend that at least /home be given a separate partition, so that personal files (videos, music, documents, etc.) would not be overwritten if you were to re-install Linux at some point.

You are free to choose your own partitioning scheme, but I create the Linux partitions in the order shown above so that I can assign specific sizes to the /boot, swap and / partitions, leaving the remainder of the disk space free for the /home partition.

If you do decide to put /boot on its own partition, it only needs to be small (I make it around 100 MB). On my laptop the /dev/sda4 Extended partition is around 143 GB so I created a partition of 60 GB for / (root) — which is more than ample — and a partition for /home using the rest of the available space on the laptop’s 320 GB hard disk. You’ll have to decide on the size of these partitions based on the size of the hard disk and the root partition’s space requirements recommended by the Linux distribution’s developers.

If you do not need Linux to be able to hibernate (‘suspend-to-disk’) then a swap partition of 512 MB would be sufficient for the typical desktop PC, especially when the latest PCs come with 4 GB or more RAM. Some people do not even bother having a swap partition at all with such large amounts of RAM. But if you do want Linux to be able to hibernate then try to find out if the Linux kernel which you will be installing was compiled with in-kernel LZO compression algorithm support (LZO compression algorithm support must not be compiled as a module). If the kernel was compiled with in-kernel LZO compression algorithm support then make the size of the swap partition the same as the RAM size, which is more than enough. For example, as my laptop has 4 GB of RAM I created /dev/sda5 as a 4 GB partition. If LZO compression algorithm support was not compiled into the kernel and you do not know how to rebuild the kernel after installing Linux then you will have to make the swap partition bigger than your RAM size (my guess would be at least 1.5 times the size to be on the safe side).

As to the choice of file system, I format /boot, / and /home as ext4 but you can choose a different native Linux file system if you want. You cannot use Windows’ FAT or NTFS for these Linux partitions.

Stage 3: Install the GRUB bootloader and Linux

Boot Windows Vista/7 and download the freeware tool EasyBCD from the NeoSmart Web site (you might like to make a small donation, to help the developer). You will need to download EasyBCD version 2 and upwards if you want to install a Linux distribution that uses GRUB 2; it is available to download from http://neosmart.net/dl.php?id=1. If you are going to install a Linux distribution that uses GRUB Legacy then the current version of EasyBCD should work too. Follow the instructions on the EasyBCD site on how to install Linux (http://neosmart.net/wiki/display/EBCD/Linux). N.B. You will reach a point in the Linux installation process when the Linux installer allows you to make a choice of where to install the GRUB bootloader: in the MBR (Master Boot Record) of the HDD or in the first sector of the Linux boot partition. You must select the latter, not the MBR. If the Linux installer offers you the option of installing GRUB to e.g. /dev/sda then that would install GRUB in the MBR, because no partition is specified. Make sure you specify the partition that will contain the /boot directory (/dev/sda3 in my particular case). If you created a separate partition for /boot then GRUB will be installed on that separate partition, whereas if you did not create a separate partition for /boot then GRUB will be installed on the partition containing the root directory.

The result of Stage 3 will be that, when you boot your PC, the Windows Vista/7 bootloader will load the GRUB bootloader, and the GRUB bootloader will load Linux. This process is called ‘chainloading’. When you boot the PC you will first see the Windows bootloader menu, and you can select Windows or Linux from it. If you select Linux then you will see the GRUB menu and you can select Linux from that menu, which will boot the distribution.

Whilst chainloading GRUB 2 from the Windows bootloader is more long-winded than booting GRUB 2 directly, you can now use Linux and Windows safe in the knowledge that GRUB 2 will not be overwritten by any Windows applications, and that a Windows factory restore partition will be bootable in an emergency.

A corner case

EDIT (June 21, 2012): A note about a ‘corner case’. This will only apply to a very small minority of users, and then problably only to some users of Gentoo Linux (in Gentoo Linux it is possible to have both /boot/grub/ and /boot/grub2/ simultaneously). If you select ‘GRUB2′ in the pull-down menu in the current version of EasyBCD (2.1.2), EasyBCD actually searches the sub-directories under /boot/ to find the GRUB 2 core.img file, and puts an entry in the Windows BCD pointing directly to that file, i.e. EasyBCD ignores the boot sector of the Linux boot partition. Therefore, when you select ‘Linux’ in the Windows boot manager’s menu, the Windows boot manager does not launch the GRUB code in the boot sector of the partition on which /boot/ resides, it launches the core.img file directly. Now, if your boot partition happens to have both the sub-directories /boot/grub/ and /boot/grub2/, and they both contain a GRUB 2 file core.img, EasyBCD 2.1.2 will create a BCD entry pointing to the one under /boot/grub/ rather than the one under /boot/grub2/. This may or may not be what you want. If you want GRUB 2 to use the core.img under /boot/grub2/, the workaround in EasyBCD 2.1.2 is to select ‘GRUB Legacy’ in the EasyBCD pull-down menu and specify the boot partition. This is counterintuitive, but it forces EasyBCD to create an entry in the BCD that points to the boot sector of the boot partition instead of the core.img file in a sub-directory of /boot/ on that partition. The GRUB 2 code in the partition’s boot sector will then execute the core.img file in the required sub-directory. This workaround only works if the Linux boot partition is on the same drive as the Windows partition. The developer of EasyBCD will be updating EasyBCD to look for a core.img file in /boot/grub2/ before /boot/grub/, rather than the other way around, if they both exist when you select ‘GRUB2′ in the EasyBCD pull-down menu.

EDIT (September 5, 2012): The EasyBCD developer has fixed EasyBCD a) to cater for core.img being either in /boot/grub2/i386-pc/ or in /boot/grub/, and b) to look for core.img in /boot/grub2/ before looking for it in /boot/grub/. The version with the fix, EasyBCD 2.2 Beta – Build 179.exe or later, can be downloaded from NeoSmart Technologies’ EasyBCD Support Forum. I’ve tried it and it works!

Make sure you read the EasyBCD FAQ page

EDIT (September 5, 2012): Make sure you read the EasyBCD FAQ page. For example, it states that, to date, EasyBCD does not support the EFI/UEFI, only the traditional PC BIOS.

EDIT (December 18, 2013): According to the NeoSmart Knowledgebase: “As of EasyBCD 2.2, EFI/UEFI and GPT disks are fully supported, but some options may not be compatible with EFI machines.“. I have not tried Version 2.2 or above of EasyBCD with EFI/UEFI and GPT disks, so cannot corroborate this.

WINE tips: How to associate IrfanView with an image file type in Linux

In my previous post I showed how to install IrfanView with a WINEPREFIX. This time I’m going to show you how to associate IrfanView with a particular image file type so that IrfanView launches and opens a file of that type when you double-click on the file.

IrfanView is an excellent free (but not open-source) application for Windows, and I’ve been using it in Windows since 1997. But there are so many excellent image viewing and editing applications native to Linux that I’ve never needed or wanted to install IrfanView under WINE. GQview, Gwenview, KolourPaint and the GIMP have so far covered all my needs. Nevertheless, IrfanView is my favourite utility for viewing and manipulating image files in Windows, and I can understand why some people may want to run it in Linux.

The usual method of setting file associations in Linux does not work for IrfanView. For example, if you use KDE’s Kickoff > System Settings > File Associations to associate JPG files with IrfanView, IrfanView will indeed launch if you double-click on a JPG file, but you’ll be left staring at an empty IrfanView window, as if you had simply launched IrfanView directly.

However, there is a straightforward work-around for this problem, and it involves the use of a Bash script. You associate the file type with a Bash script that you create specifically to accept a Linux parameter for the file name and convert it to a format that WINE can pass to IrfanView when launching it. Here is how to do it.

I created a text file ~/launch_IrfanView.sh containing the following Bash script:

#!/bin/sh
File="z:"${1//\//\\}
wine "/home/fitzcarraldo/.wine-irfanview/drive_c/Program Files/IrfanView/i_view32.exe" $File

(The “$File” above may be wrapped around to the next line in your browser window, but note that it is only separated by a space from the rest of the wine command.)

I used a WINEPREFIX of $HOME/.wine-irfanview/ when I installed IrfanView, so replace “.wine-irfanview” with “.wine” if you installed IrfanView without a WINEPREFIX (i.e. if it is installed in the ~/.wine/ directory tree).

I made the file executable:

$ chmod +x /home/fitzcarraldo/launch_IrfanView.sh

I then edited the command for ‘IrfanView 4.27′ in ‘Kickoff’ > ‘System Settings’ > ‘File Associations’ > ‘image’ > ‘jpeg’ > ‘Application Preference Order’ | ‘IrfanView 4.27′ > ‘Edit’ > ‘Application’ to be as follows:

/home/fitzcarraldo/launch_IrfanView.sh %f

That works fine: when I double-click on a JPG file in a Dolphin window, IrfanView launches and opens the file.

Of course, if you want IrfanView to be the default viewer for PNG files then you would perform the aforementioned steps for ‘Kickoff’ > ‘System Settings’ > ‘File Associations’ > ‘image’ > ‘png’.

As I wrote initially, there are several excellent image viewers and editors for Linux, so I did not keep IrfanView as my default image viewer in Linux. But I have left IrfanView installed under WINE, as I may yet want to use it under Linux at some point.

WINE tips: Giving each Windows application its own environment

I’m going to tell you about the useful WINEPREFIX environment variable, and, as a bonus, you’ll also find out how to install Office 2007 and IrfanView in WINE, plus how to configure file associations so that double-clicking on a .doc and/or .docx file will launch Word 2007 and open the file.

BACKGROUND

I’ll wager most WINE users have not heard of the WINEPREFIX environment variable and are installing all Windows applications in the ~/.wine/ directory tree. Until a couple of months ago that’s what I was doing too, but these days I install all Windows applications in WINE using this clever WINE feature.

Some WINE users will know that it is possible to use the ‘Add application…’ button on the Applications Settings page (the Applications tab) in the winecfg window to specify per-application libraries (DLLs) and graphics settings. For example, a user could use this feature in order to set an override of riched20 (native) for Office 2007 but not for, say, IrfanView. This WINE feature allows you to ‘ring fence’ applications from each other, avoiding the possibility of incompatible DLLs and graphics settings interfering with the working of another application. However, WINE still keeps directories and files for all the Windows applications in the ~/.wine/ directory tree.

The WINEPREFIX environment variable enables you to go a stage further. By using a WINEPREFIX you can install each Windows application (or a group of applications) in its own, completely separate environment. For example you could install IE7 in ~/.wine-ie7/, IrfanView in ~/.wine-irfanview/, World of Warcraft in ~/.wine-wow/, Word 2007 in ~/.wine-word2007/ and so on. You could even have different versions of the same Windows application installed simultaneously if you wanted. Not only does a WINEPREFIX allow you to keep an application’s DLLs and all settings completely separate from those of other applications, thus avoiding or preventing conflicts, it means that unistalling a Windows application becomes as simple as:

rm -rf ~/.wine-visio5

You no longer need to hope that wine uninstaller supports the application, or that the application’s uninstaller will work if launched directly via WINE.

If winecfg’s Applications Settings allows you to partially isolate an individual application, the use of a WINEPREFIX allows you to put an application into solitary confinement!

HOW TO USE A WINEPREFIX

Let’s look at a couple of examples.

Installing Office 2007 (including SP2) with its own WINEPREFIX:

$ cd
$ export WINEPREFIX=$HOME/.wine-office2007
$ winecfg
$ cd .wine-office2007/drive_c/
$ wget http://www.kegel.com/wine/winetricks
$ chmod +x winetricks
$ cp ~/Downloads/X12-30107.exe . # Office 2007 installer from Microsoft.
$ cp ~/Downloads/office2007sp2-kb953195-fullfile-en-us.exe . # Office 2007 SP2.
$ cp ~/Downloads/officelp2007sp2-kb953195-fullfile-en-us.exe . # Office 2007 SP2 language pack.
$ wine X12-30107.exe # Install Office 2007. If you have an Office 2007 installation DVD then use "wine /path/to/setup.exe" instead.
$ winecfg # Set up riched20.dll as per instructions in Wine AppDB for Office 2007 (it must be "Native (Windows)").
$ ./winetricks msxml3 # Install msxml3 as per instructions in Wine AppDB for Office 2007, to stop SP2 crashing.
$ wine office2007sp2-kb953195-fullfile-en-us.exe # Install Office 2007 SP2.
$ wine officelp2007sp2-kb953195-fullfile-en-us.exe # Install Office 2007 SP2 language pack.
$ ./winetricks wsh56js # Install Windows Scripting Host for the thesaurus.
$ ./winetricks allfonts # Install all the TTF fonts.
$ winecfg # Set usp10 to 'native,builtin' for the equation toolbar in Word.
$ ./winetricks fontsmooth-rgb # Install font smoothing.

I have a KDE Kickoff menu entry Applications > Wine > Programs > Microsoft Office > Word containing the following command:

env WINEPREFIX="/home/fitzcarraldo/.wine-office2007" wine C:\\windows\\command\\start.exe /Unix /home/fitzcarraldo/.wine-office2007/dosdevices/c:/users/fitzcarraldo/Start\ Menu/Programs/Microsoft\ Office/Microsoft\ Office\ Word\ 2007.lnk

The above command might look complicated, but WINE creates it automatically during the installation of Office 2007. WINE also creates similar Kickoff Menu entries for the other Office 2007 applications.

Having installed Office 2007 using a WINEPREFIX, if I wanted to launch e.g. Word from the command line I’d need to enter the following commands:

$ export WINEPREFIX=$HOME/.wine-office2007
$ wine $WINEPREFIX/drive_c/Program\ Files/Microsoft\ Office/Office12/WINWORD.EXE

instead of the following if I had not installed Office 2007 using a WINEPREFIX:

$ wine $HOME/.wine/drive_c/Program\ Files/Microsoft\ Office/Office12/WINWORD.EXE

Installing IrfanView 4.27 with its own WINEPREFIX:

$ cd
$ export WINEPREFIX=$HOME/.wine-irfanview/
$ winecfg
$ cd .wine-irfanview/drive_c/
$ wget http://www.kegel.com/wine/winetricks
$ chmod +x winetricks
$ ./winetricks mfc42
$ cp ~/Downloads/iview427_setup.exe .
$ cp ~/Downloads/irfanview_plugins_427_setup.exe .
$ wine iview427_setup.exe
$ wine irfanview_plugins_427_setup.exe

I have a KDE Kickoff menu entry for IrfanView containing the following command:

env WINEPREFIX="/home/fitzcarraldo/.wine-irfanview" wine C:\\\\Program\\ Files\\\\IrfanView\\\\i_view32.exe

The above command might look complicated, but WINE creates it automatically during the installation of IrfanView.

By installing Office 2007 and IrfanView this way, I keep the DLLs installed by the IrfanView installer completely separate from the DLLs used by Office 2007.

File associations

If you find that Word opens a blank document (Document1) when you double-click on a .doc (or.docx) file then this is a file association issue. In KDE I simply selected Kickoff > System Settings > File Associations and changed all the associations for .doc and .docx from the following:

env WINEPREFIX="/home/fitzcarraldo/.wine-office2007" wine C:\\windows\\command\\start.exe /Unix /home/fitzcarraldo/.wine-office2007/dosdevices/c:/users/fitzcarraldo/Start\ Menu/Programs/Microsoft\ Office/Microsoft\ Office\ Word\ 2007.lnk

to the following:

env WINEPREFIX="/home/fitzcarraldo/.wine-office2007" wine C:\\windows\\command\\start.exe /Unix %U

A different approach is needed if you want IrfanView to open image files when you double-click on them, and I’ll cover that in my next post.

Follow

Get every new post delivered to your Inbox.

Join 51 other followers