How to Generate a MD5SUM Checksum File for Linux ISO Images

July 22nd, 2008

Purpose: Suppose you have created your own Custom Linux LiveCD by generating an ISO image file using mkisofs command or any other command. Now you want to distribute these ISOs to people and therefore you upload them to a web site and provide a link for the download. Suppose someone downloads the ISO but how can he/she make sure that he/she is getting the exact same copy that you have uploaded. In short if someone hacks the website on which you uploaded these ISOs and the hacker/cracker changes the contents of the ISOs then you would not want your users to use those ISOs.

Here we will discuss a technique which will enable your users to verify that nothing has changed on the ISOs since you uploaded them. This is a useful technique for large ISO downloads (500MB+) to ensure your users that they are receiving the correct data.

Requirements:

a) Any Linux Distro which has MD5SUM package installed.

b) ISO image that you have downloaded from a Web site.

Step 1: Install MD5SUM package

For Debian based distro do:

#apt-get update

# apt-get install coreutils

Step 2: Create a MD5SUM file

For testing purpose I have uploaded a small DSL (Damn Small Linux) ISO here called “dsl.iso”. You can download this and use this as an example to follow the rest of the post.

Now I will create a checksum file by giving the following command:

# md5sum dsl.iso > MD5SUM

This will generate a file called MD5SUM. You can view the contents of the file by:

# less MD5SUM

61694888aede3e01229865b8e6acd4a1 dsl.iso

Also you can have a single MD5SUM file for multiple ISOs. You don’t need to create an individual file for every ISO image. For example suppose you have another file called “memtest.bin” then you can do the following:

# md5sum memtest.bin >> MD5SUM

# less MD5SUM

61694888aede3e01229865b8e6acd4a1 dsl.iso
32fe76fda886150ffbf47d5c6e7b730f memtest.bin

Basically the append operator “>>” just keeps adding new entry for every new file. You can download the combined MD5SUM file here.

Note: Although I have been mentioning ISO files all the time but this technique can be used for any type of file like a .bin, .doc, .zip, .xls, .pdf, etc.

Step 3: Upload the file on some web server

After creating the ISO and the corresponding MD5SUM checksum file upload them to any web server that you have access to.

Step 4: Verify the MD5SUM checksum

Suppose you download the above ISO files at some different time and would like to verify if the download is correct or not then you need to download the MD5SUM file also that you/originator created in Step 2 above.

Note: Make sure that the ISO files and the corresponding MD5SUM file are downloaded in the same directory otherwise the test will fail. By default if you have not moved around anything then all should be good.

Check the ISO files by giving the following command:

# md5sum -c MD5SUM

You shuold see something like this:

dsl.iso: OK
memtest.bin: OK

In case of a checksum failure you might see something like this:

# md5sum -c MD5SUM
dsl.iso: FAILED
memtest.bin: OK
md5sum: WARNING: 1 of 2 computed checksums did NOT match
#

Step 5: Done

That’s it! You are done and ready to upload your ISOs and MD5SUM checksum file.

As usual, please leave a comment/feedback, if you have any.

Access/Mount a Linux ext2/ext3 filesystem from a Windows XP machine over a LAN/Domain network

July 19th, 2008

Purpose: This post will explain how you can mount a Linux filesystem (ext2/etx3) on your Windows XP machine over a network.

Note: If you are looking for how to the reverse - Mount a windows share drive on a linux machine over a network then please refer to my previous blog entry.

Also this blog entry does NOT explain how you can access an ext2/ext3 filesystem on your Windows XP partition on the same hard drive - The typical Dual Boot scenario.

Important Note: Before you read any further I strongly encourage you to do the things that I mentioned in my previous blog as noted above. Your chances of success to follow the instructions on this entry will greatly increase. Therefore I strong encourage you to do all the things mentioned in my previous blog.

My Setup:

1. Debian Linux (4.0) running 2.6.24 kernel with IP address 192.168.0.2 and user accounts: “root” and “kushalk”

2. Windows XP SP2 machine on a network domain called “home.net” with IP address 192.168.0.3 and user account: “kkoolwal”

Step 1: Install Samba Package on your Linux machine

#apt-get install samba

Step 2: Stop the Samba Daemon

It is a good idea to stop the Samba daemon since we will be making changes to the Samba configuration file.

#/etc/init.d/samba stop

Step 3: Edit the Samba file /etc/samba/smb.conf (may be required)

This will require two steps:

a) Make sure that your domain/workgroup name is setup correctly in the variable “workgroup”. Also you need to uncomment the line by removing the “;” or “#” symbol.

workgroup = home.net

Make sure you set the name of your workgroup properly. To find out the name of your workgroup/domain do the following on your Windows machine.

To find out the Workgroup name in Windows follow these steps:
- Go to “START”
- Click “Control Panel”
- Click “System”
- Click on the 2nd tab button named: “Computername” and find out the name of your workgroup/domain.

b) Select which directory you want to share

As per the default setting you will be able to access your home directory on your Windows XP machine i.e. the directory of the user from which you connect. If you want to access any other directory other than your home directory then you need to add the following section anywhere in the smb.conf file:

[src]
comment = My Kernel/Module development sources
path = /usr/src/
read only = Yes

Basically by doing the above you are telling your Samba server that you want to share the ‘/usr/src’ directory.

That’s it. Your smb.conf file should now be configured.

Note: It is a good idea to check your smb.conf file for any syntactic error by giving the following command:

# testparm

Here is my output of the above command:

root@debian:~# testparm
Load smb config files from /etc/samba/smb.conf
Processing section “[homes]”
Processing section “[printers]”
Processing section “[print$]”
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
[global]
workgroup = home.net
server string = %h server
obey pam restrictions = Yes
passdb backend = tdbsam
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n *password\supdated\ssuccessfully* .
syslog = 0
log file = /var/log/samba/log.%m
max log size = 1000
dns proxy = No
wins server = eth0:192.168.0.20
panic action = /usr/share/samba/panic-action %d
invalid users = root
include = /etc/samba/dhcp.conf
[homes]
comment = Home Directories
valid users = %S
create mask = 0700
directory mask = 0700
browseable = No
[printers]
comment = All Printers
path = /var/spool/samba
create mask = 0700
printable = Yes
browseable = No
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
root@debian:~#

Step 4: Add a user to the Samba user list:

You need to tell the Samba server which user you will be using to connect the to Linux filesystem from the Windows machine. I added myself (user: kushalk) to the Samba server by giving the following commands:

smbpasswd -L -a kushalk
smbpasswd -L -e kushalk

Note: By default, Samba does not allow the user “root” to access the filesystem. You will have to change the setting “invalid users = root” in your smb.conf file. I have not tried this.

Step 5: Restart the Samba server

#/etc/init.d/samba start

Step 6: Access your Linux filesystem/folder from Windows XP machine

Finally go to your Windows machine (assuming you have File Sharing and all configured which I think it should be if you were able to follow the steps in my previous blog successfully) and type the following in your “Explorer Windows” and NOT “Internet Explorer” like this:

Linux Filesystem Windows Mount Login Network

Now enter your username and password - the one that you used in the smbpasswd command in Step 4 above. After that you should be able to see your home directory like this:

Linux Ext3 Share connected Windows Mount

That’s it. As usual, please leave a comment/feedback, if you have any.

Mount a Windows Network Share on Linux using SAMBA/CIFS

May 19th, 2008

Purpose: This post will explain how you can mount a Windows Network Share on to your Linux machine. Note: If you are looking for how to mount a windows partition on your local hard drive on to your Linux filesystem this post may not be for you.

Example - Setup:

1. You have a computer running Windows XP (or may be Vista) on your home/office network on a workgroup or domain.

2. You have another computer running Linux say Debian Linux.

3. You would like to mount a shared folder/drive on your Windows computer on to your Linux machine say on “/mnt/” folder so that you can access (read/write) that folder/drive.

My setup:

1. Debian Linux (4.0) running 2.6.24 kernel with IP address 192.168.0.2

2. Windows XP SP2 machine on a network domain called “home” with IP address 192.168.0.3

Step 1: Share a Windows folder/drive

You will first need to share a folder/drive on your Windows computer so that it can accessed through network. You can do this by right-clicking on the folder/drive that you would like to share and selecting the “Sharing” option. If you don’t know what I am talking about then you can refer to this MS tutorial which explains how to do that.

Step 2: Make sure your Kernel is configured properly

If you are using a standard Linux Kernel from any distribution then it is mostly like already configured. If not then just configure and compile your Linux Kernel with the following options in bold built-in or as a module.

# cat /boot/config-2.6.24 | grep CIFS
CONFIG_CIFS=y
# CONFIG_CIFS_STATS is not set
# CONFIG_CIFS_WEAK_PW_HASH is not set
# CONFIG_CIFS_XATTR is not set
# CONFIG_CIFS_DEBUG2 is not set
# CONFIG_CIFS_EXPERIMENTAL is not set

# cat /boot/config-2.6.24 | grep SMB
CONFIG_SMB_FS=y
# CONFIG_SMB_NLS_DEFAULT is not set

Step 3: Install necessary packages on your Linux machine

You will need smbfs package and also an optional smbclient package by giving the following commands:

#apt-get update

#apt-get install smbfs smbclient

The above command will also install samba-common package. If you are asked to enter a workgroup/domain name while the above packages are installed just enter the relevant infomration, In my case it was “home” as my domain name. You can enter your domain name or a workgroup name depending on your LAN configuration.

Step 4: Check which shares are available for mount

Now before you mount you can also check which shares (folders/drives) are available on your Windows machine that you can mount by giving the following command:

debian# smbclient -L infohighway -U kushal

where

infohighway = Name (NetBIOS Name) of my computer

kushal = Username on my Windows Machine

Password:

You will get an output similar to this:

Domain=[HOME] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

Sharename Type Comment
——— —- ——-
myshare Disk
IPC$ IPC Remote IPC
mydownloads Disk
ADMIN$ Disk Remote Admin
C$ Disk Default share

Domain=[HOME] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

Server Comment
——— ——-

Workgroup Master
——— ——-

From the above output you can see that I have shared folders called “myshare” and “mydownloads” on my Windows XP machine as highlighted in bold letters. This means that I can mount these folders on my Linux machine.

Step 5: Mount the Windows Share

Now the real thing. There are two ways to mount: The traditional SMBFS or the newer CIFS. It seems that CIFS is going to replace SMBFS which will soon become obsolete. I will show you both the methods:

SMBFS Method Command:

# mount -t smbfs -o username=kushal,password=******** //infohighway/drivers /mnt/

where

kushal = Username on my Windows Machine

******* = Password for the user ‘kushal’

infohighway = Name (NetBIOS Name) of my computer

drivers = Windows folder shared on my Windows XP machine

/mnt = Target mount directory on my Linux Machine

CIFS Method Command:

# mount -t cifs //infohighway/drivers /mnt/ -o username=home/kushal,password=*********

where

home = DomainName/Workgroup of your LAN network

Rest of the parameters are same as in SMBFS

Note: If you get any error messages after you give the mount command refer to the “Some typical errors” section below.

Now you can access the contents of the Windows share now by giving the command:

# ls /mnt/drivers

debian:~# ls /mnt/
audio INFCACHE.1 network Security storage video
debian:~#

Some typical errors:

You might see some typical error messages as follow in case if you missed any steps above:

Error 1: CIFS VFS: cifs_mount failed w/return code = -22

Solution: apt-get install smbfs

Error 2: smbfs: mount_data version 1919251317 is not supported

Solution: apt-get install smbfs

You can see the above error messages (if they do occur) by giving the following command just after you issue the mount command as mentioned in Step 5 above:

# dmesg | tail

Error 3: mount error 13 = Permission denied

Solution: Give the name of your Domain/Workgroup as shown in bold letter in Step 5 when mounting with CIFS method otherwise you will likely get this error message.

HOW-TO: Enabling 3D Acceleration under Debian Linux

April 28th, 2008

Purpose:

This blog entry will explain:

1. How to enable 3D acceleration under Debian Linux and may be perhaps under any other Linux distribution.

2. How to test if 3D acceleration is actually working or not.

Step 1: Find out if 3D acceleration is already enabled or not?

Give the following command:

# glxinfo | less

or

# glxinfo | less | grep Yes

If you see a line like:

“direct rendering: Yes”

in the following output:
3D Acceleration - Direct Rendering

then 3D acceleration is already enabled and you don’t need to do anything else.

However, if you see a line like:

“direct rendering: No”

then follow the steps to enable the 3D acceleration.

If you don’t have glxinfo installed, you can install it by:

# apt-get install mesa-utils

Step 2: Find out the Graphics chipset name

In order to recognize the proper driver for your Graphics chipset we need to find out it’s name/model by giving the following command:

# lspci

00:00.0 Host bridge: VIA Technologies, Inc. K8M800 Host Bridge
........
00:10.4 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 86)
00:11.0 ISA bridge: VIA Technologies, Inc. VT8237 ISA bridge [KT600/K8T800/K8T890 South]
00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233/A/8235/8237 AC97 Audio Controller (rev 60)
00:12.0 Ethernet controller: VIA Technologies, Inc. VT6102 [Rhine-II] (rev 78)
01:00.0 VGA compatible controller: VIA Technologies, Inc. S3 Unichrome Pro VGA Adapter (rev 01)
#

The line in bold above shows the name/model of my graphic card (VGA controller). Note this down.

Step 3: XOrg Configuration

Also make sure that your Xorg server is using the correct driver for your graphic card. You can check this by the following command:

# cat /var/log/Xorg.0.log | grep driver

You should see the name of your driver in the output as shown below:

X.Org XInput driver : 0.6
(II) Loading /usr/lib/xorg/modules/drivers/via_drv.so
ABI class: X.Org XInput driver, version 0.6
ABI class: X.Org XInput driver, version 0.6
(II) VIA: driver for VIA chipsets: CLE266, KM400/KN400, K8M800,
(!!) VIA Technologies does not support or endorse this driver in any way.
(!!) For support please contact the driver maintainer or your X vendor.
(II) VIA(0): [drm] loaded kernel module for “via” driver
(II) VIA(0): [drm] created “via” driver at busid “PCI:1:0:0″

If you have the correct driver installed and still you are not able to get 3D acceleration, then try the following additional steps below.

Step 4: Configure the Kernel to include the support for your Graphics Card

Give the following commands:

# cd /usr/src/linux

# make xconfig (or whatever you use)

and configure the following highlighted options :

Kernel configuration for AGP Support Linux

Kernel Configuration to eable DRI support

In short you need to configure AGP Support and DRI/DRM (Direct Rendering Manager) support under Character Devices in the Kernel configuration menu.

You should do the above for your own Graphic Card make/model like Intel 855GM (i810) etc.

Now compile your kernel and install it. In case if you don’t know how to do it, then here is good link which explains the process.

Step 5: Install the DRI package (optional but may be required)

I have found this to be “required” for my configuration. Generally your 3D acceleration should be enabled at this point of time. You can check it as shown in Step1 above. In case if it is still not enabled then try to install the xlib mesa dri package by giving the following command:

# apt-get install xlibmesa-dri

Now check your 3D acceleration again by giving “glxinfo” command.

If you are still not able to get 3D acceleration then chances are that your card and/or your driver does not support it. Check the documentation of your card and driver and try searching on the Internet.

Other tools to check/measure 3D acceleration performance

Once you get your 3D acceleration going, you can use some of the X based tools to measure the performance.

1. GLXGEARS

# apt-get install mesa-utils

# glxgears

You should see 3 colored rotating gears as your output like this:

GLX Gears

2. XENGINE

# apt-get install xengine

# xengine

This utility will show you the RPM count. You can compare the RPM count with and w/o 3D accelerations to see the effect of 3D acceleration. The piston will rotate much more faster with 3D acceleration (a visual cue).

You should see something like this:

Xengine RPM count

3. Check AGP Support

You can also check if Linux detected your AGP or not by giving the following command:

# dmesg | grep agpgart

You should be able to see some text which talks about agpgart like this:

Linux agpgart interface v0.101 (c) Dave Jones
agpgart: Detected AGP bridge 0
agpgart: AGP aperture is 64M @ 0xe0000000
agpgart: Found an AGP 3.0 compliant device at 0000:00:00.0.
agpgart: Xorg tried to set rate=x12. Setting to AGP3 x8 mode.
agpgart: Putting AGP V3 device at 0000:00:00.0 into 8x mode
agpgart: Putting AGP V3 device at 0000:01:00.0 into 8x mode

As usual, please leave a comment/feedback, if you have any.

Ethernet (eth) card not activated under Linux - udev issue

April 22nd, 2008

Purpose:
Sometimes if you are experimenting with Linux on different machines, there are chances that upon switching to a different machine your Ethernet card won’t be activated by default i.e. upon giving the command ‘ifconfig’ your Ethernet card will disappear even if your driver is loaded properly.

Test Setting:
Linux O.S.: Debian 4.0
Kernel: 2.6.22 - 2.6.24

Scenario:
For example, you install your Linux system on one machine and then you take your hard disk and attach it to an another machine which has possibly the same configuration. On booting you find that you cannot see your eth0 or eth1 upon giving ‘ifconfig’. For example, you see this

debian:~# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)

instead of this

debian:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:01:02:03:04:05
inet addr:192.168.0.101 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe81::202:244:fe68:3172/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:78108 errors:0 dropped:0 overruns:44 frame:0
TX packets:50313 errors:0 dropped:0 overruns:0 carrier:0
collisions:2 txqueuelen:1000
RX bytes:103308543 (98.5 MiB) TX bytes:3763441 (3.5 MiB)
Interrupt:169 Base address:0xe000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)

However, you can activate your Ethernet card by giving commands like:

# dhclient eth2

or

# dhclient eth3 (If you have Dual Ethernet card)

Suppose now you can attach your same hard drive to another identical machine and now you again cannot activate your Ethernet card even by giving the above commands i.e. ‘dhclient eth2′ or ‘dhclient eth3′. But you can activate it now by giving commands like:

# dhclient eth4

or

# dhclient eth5 (If you have Dual Ethernet card)

This cycle can go on and on i.e. upon switching machines every time you have to keep incrementing the eth<number> by one or by two (if you have dual Ethernet card).

If you observe something like this on your machines then read the solution below.

Note: Before you proceed to the solution make sure that your Ethernet card driver is loaded. If your driver is compiled as a module in your kernel, you can load it by giving the following command:

# modprobe <name-of-drive>

For example,

#modprobe e100

If it is built into the kernel then you don’t need to give the command as it should have got loaded automatically. Steps to configure and compile your Ethernet driver is out of the scope of this post.

Solution:
Remove the following two files from the udev directory:

debian:# cd /etc/udev/rules.d

debian:# rm z25_persistent-net.rules z45_persistent-net-generator.rules

This happens because of the above two configuration files that udev creates by default. The file ‘z25_persistent-net.rules’ creates rules for the Network devices and remembers them upon every boot. Removing this files forces the udev to create names from start i.e. eth0 upon every reboot. I don’t claim that I understand this issue completely but if you want to go to the depth of it then I recommend reading the udev documentation under the directory ‘/usr/share/doc/udev’. It has vast source of information. Also you can read more about udev in the Kernel Documentation directory under ‘/usr/src/linux/Documentation’.

I noticed this behavior in Debian 4.0 (Stable/Etch). This issue was not there in Debian 3.1 (Stable/Sarge). This means that something changed in udev package between 3.1 and 4.0. Go figure!

I was able to figure out this solution by reading the documentation mentioned above. Also this lead me to create a post which explains what steps one should take in general to (re)solve problems under Linux.

As usual, please leave a comment/feedback, if you have any.