Followup Notes to Installing SUSE Linux 10.0 OSS on a Laptop

Since writing the original article Installing SUSE Linux 10.0 OSS on a Laptop, I've discovered a few things that could be helpful.

Suspending the Laptop: Dealing with Windows Shares

The problem: If your laptop accesses shared Windows folders across a network, you may not be able to access those shared folders after suspending and restoring.  SUSE Linux 10.0 does not attempt to deal with these folders, which are accessed via a technology called SMB (technically, SMB, which stands for Server Message Block, is a protocol).

The solution: Change one script file that SUSE Linux uses when suspending to disk or to memory.  If you have no experience with script files, don't panic; I'll give you the script file, or if you prefer to make the changes yourself, I'll tell you exactly what to change.  The changes are fairly minor, and you can copy them from this article and paste them into the script.

Note that this updated script file works on my SUSE Linux 10.0 OSS system; it may not work on yours.  If you use SUSE 10, it probably will; if you use another Linux distribution, it may not work.  Note that I found this script by running locate suspend from the command line (you need the findutils-locate package installed to do this); on a different distribution, you might use locate to find a similar suspend script on your system and modify it similarly.

Step 1: Find the file.  The file to change is /usr/lib/powersave/scripts/sleep_helper_functions.  SUSE Linux uses things from this file while preparing the laptop for suspend to RAM or to disk.

Before changing it, save a copy of the original in case anything goes wrong.  To do this, open a terminal window as the root user (SUSE Menu -> System -> Terminal -> Terminal Program - Super User Mode) and do the following:

steve-lap:~ # cd /usr/lib/powersave/scripts
steve-lap:/usr/lib/powersave/scripts # cp -p sleep_helper_functions sleep_helper_functions.original
steve-lap:/usr/lib/powersave/scripts #
Using KWrite to edit sleep_helper_functionsFigure 1. Using KWrite to edit sleep_helper_functions

Step 2: Copy or Edit the file.  My already-fixed version of the file can be found here.  To copy it to your system, right-click on the link and select Save Link As. Next, as root, copy the file to the /usr/lib/powersave/scripts directory, and you're done; you don't need to continue with the other steps below.

If you prefer to edit the file yourself or if you'd just like to know what the changes are, open the sleep_helper_functions file in your favorite text editor.  If you use KDE, KWrite is a good choice:

steve-lap:/usr/lib/powersave/scripts # kwrite sleep_helper_functions

Step 3: Add "smbfs" to unmount types.  It's helpful to turn on line numbers in KWrite for the next steps: select Show Line Numbers from the View menu, or press the F11 key on your keyboard.

Now find the line that reads

    { if (($3=="ntfs")||($3=="vfat")||($3==fat)) {

On my system, this is on line 100 of the script.  Change that line by adding a test for "smbfs"; the final line should look as follows, with the added portion highlighted:

    { if (($3=="ntfs")||($3=="vfat")||($3==fat)||($3=="smbfs")) {

The added portion tests whether a mounted share is of type "smbfs," which stands for SMB file system.

What does this change do?  This portion of the script decides which mounted file systems should be unmounted before suspending.  The original script unmounts NTFS, VFAT, and FAT file systems; after our change, the script also will unmount SMB file systems before suspending.

Step 4: Add logic to remount SMBFS.  The next step is to add logic for remounting the SMB file systems after the laptop comes out of suspend.  This happens on line 213 of the original script, highlighted below:

211 # we remount in reverse order...
212 for (( ; I>=0; I-- )) ; do
213   mount ${DEV[$I]} ${MNT[$I]} ${OPT[$I]} ; D=$?
214   if [ $D -eq 0 ];then
215     DEBUG "remounted ${DEV[$I]}" DIAG
216     echo " mounted '${DEV[$I]}' to '${MNT[$I]}',options '${OPT[$I]}'" >> $LSMOD_LOG
217   else
218     DEBUG "unable to remount ${DEV[$I]}" WARN
219     echo " could not mount '${DEV[$I]}' to '${MNT[$I]}', options '${OPT[$I]}', error $D" >> $LSMOD_LOG
220   fi
221 done

The version of the mount command above won't work for SMB mounts, so let's change it to the following:

211 # we remount in reverse order...
212 for (( ; I>=0 ; I-- )) ; do
213   if [ "${TYP[$I]}" = "-t smbfs" ]; then
214     echo "Attempting: mount ${DEV[$I]}" >> $LSMOD_LOG
215     mount ${DEV[$I]} ; D=$?
216   else
217     mount ${DEV[$I]} ${MNT[$I]} ${OPT[$I]} ; D=$?
218   fi
219   if [ $D -eq 0 ];then
220     DEBUG "remounted ${DEV[$I]}" DIAG
221     echo " mounted '${DEV[$I]}' to '${MNT[$I]}', options '${OPT[$I]}'" >> $LSMOD_LOG
222   else
223     DEBUG "unable to remount ${DEV[$I]}" WARN
224     echo " could not mount '${DEV[$I]}' to '${MNT[$I]}', options '${OPT[$I]}', error $D" >> $LSMOD_LOG
225   fi
226 done

The if statement (line 213) checks whether the file system type (${TYP[$I]}) is SMBFS, and if so, it uses a mount command with fewer parameters than in the original script (line 215).  Otherwise, if the file system type isn't SMBFS, it uses the original mount command (line 217).  Note that the echo statement on line 214 is not strictly needed, but it's a good idea to record things to a log file to help you when there are problems.  If you ever need to look at the log files, you can find them in /var/log/suspend2disk.log or /var/log/suspend2ram.log after a restore.

Step 5: Save and try it!  That's it for the editing; now, just save the file, exit KWrite, and try suspending and restoring your laptop.  After you restore, you may want to see if it worked; from a command line, issue a mount command with no parameters to see if your SMB folders were remounted:

steve-lap:~ # mount
/dev/hda7 on / type reiserfs (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
tmpfs on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/hda8 on /home type ext3 (rw)
usbfs on /proc/bus/usb type usbfs (rw)
pogo.steve.net:/mnt/win_d/Music on /pogo/Music type nfs (rw,noexec,nosuid,nodev,noatime,rsize=8192,wsize=8192,soft,timeo=300,retry=1,addr=192.168.1.105)
pogo.steve.net:/mnt/mdk/home/steve/My_Documents on /home/steve/Documents/pogodocs type nfs (rw,noexec,nosuid,nodev,soft,timeo=300,retry=1,addr=192.168.1.105)
/dev/hda1 on /windows/C type ntfs (ro,noexec,nosuid,nodev,gid=100,umask=0002,nls=utf8)
//linkstation/steve on /home/steve/mnt/linkst_steve type smbfs (0)
//linkstation/Pictures on /Pictures type smbfs (0)
steve-lap:~ #

As you can see from the highlighted lines above, the script changes worked, and the SMB folders were correctly remounted.  Of course, if you're not connected to the network with which you access the SMB folders, they won't be remounted correctly.  This could happen, for instance, if you're traveling with your laptop.

If anyone has suggestions, alternatives, or problems with this, please let me know either at the DesktopLinux.com forum or send email to susesteve at yahoo dot com.