Sharing With Samba
To set up file sharing using the samba service, I’m following a howto guide on the Ubuntu Forums. Here’s the basic steps without all the exposition in the guide (with the assumption that I just want to share a folder /s with myself and no one else):
Install samba:
$ sudo apt-get install samba
Stop samba:
$ sudo /etc/init.d/samba stop
Backup samba configuration file template, then create and edit a new configuration file:
$ sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.template
$ sudo touch /etc/samba/smb.conf
$ sudo gedit /etc/samba/smb.conf
Paste in:
[global]
; General server settings
netbios name = ezmac
server string =
workgroup = WORKGROUP
announce version = 5.0
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192
passdb backend = tdbsam
security = user
null passwords = true
username map = /etc/samba/smbusers
name resolve order = hosts wins bcast
wins support = yes
printing = CUPS
printcap name = CUPS
syslog = 1
syslog only = yes
[s]
path = /s
browseable = yes
read only = no
guest ok = no
create mask = 0700
directory mask = 0700
force user = ez
force group = ez
Start samba:
$ sudo /etc/init.d/samba start
Add myself as a samba user and activate:
$ sudo smbpasswd -L -a ez
$ sudo smbpasswd -L -e ez
That’s all it takes to be able to login from other computers and have full access to the files in /s. But I also want to be able to mount shares being served from the other computers on my network. For that I run:
$ sudo apt-get install smbfs
then to mount a network share I run:
$ smbmount //XX.XX.XX.XX/share /path/to/mount/point
and unmount with:
$ smbumount /path/to/mount/point
where XX.XX.XX.XX is the local ip address of the server, share is the name of the network share, and /path/to/mount/point is obviously the path to the mount point. In gutsy I could use the server name instead of the ip address, but that is not working for me now. I did some research and tried some things, but nothing worked so I’ll just do it this way for now (fortunately all of my computers have static local IP’s anyway).
UPDATE: I am now able to access my shares by server name after adding the static ip address and server name to the file /etc/hosts. Not sure how useful that is, since I still have to know the ip address and it has to be static, but this does work.
In addition to the guide I was following, I looked at a review of the ‘create mask’ and ‘directory mask’ options here and scanned some parts of Using Samba, 2nd Edition by Jay Ts, Robert Eckstein, and David Collier-Brown (this book is an awesome resource, read it).
Mounting a Partition
I forgot to specify a mount point for my shared FAT32 partition when I installed Ubuntu Hardy. The result is that the drive doesn’t automatically mount so every time I want to access it, I have to choose it from the Places menu and enter a password. Then the drive mounts to /media/SHARE, which is not at all what I want. I want to make it fast & easy to access the drive from a terminal, so I’m going to manually configure the system to automatically mount the drive to /s whenever I start the computer.
To do this, I create the mount point in the terminal:
$ sudo mkdir /s
then I get some info about my drive by running:
$ sudo fdisk -l
which tells me what I need to setup the auto-mounting by editing the /etc/fstab file (first I create a backup – always good form):
$ sudo cp /etc/fstab /etc/fstab.BKP_07302008
$ sudo gedit /etc/fstab
where I add the line:
/dev/sda3 /s vfat defaults,umask=007,uid=ez,gid=ez 0 0
which tells the system to mount ‘/dev/sda3′ at ‘/s’ with the type ‘vfat’ (fat32) using the default options, but give only me and my group permission to access the drive. Then I just save the file, exit, and reboot to test.
On reboot, all is well.
I got help on this from the Ubuntu Forums. I read through an excellent guide by Nana Langstedt at Tuxfiles.org. The article is packed details about how to edit the fstab file and actually understand it.
VirtualBox Revolutions
Based on the (limited) information I found about the upgrade to 1.6 on the VirtualBox forums here, here & here, I should be able to just install the new version, and it will automatically replace the old one with a working result. It’s worth a try now that I know I can revert back to 1.5 if I need to.
The install went ok, and when I launch the program, it comes up with a message that the settings have been converted to a new format. I have the option to save the changes, backup the old files and then save the changes, or cancel and not auto convert the settings. I’m choosing to just save, since I already have backups.
Now, that’s more like it! The virtual machine shows up and starts right away when I tell it to. Guess I just got ahead of myself yesterday by jumping to the new version. I’ll take this as a lesson to always restore backups in the version of the program where the backups were made (if at all possible). This also illustrates the benefits of the practice I usually follow of archiving the installer files for all of the software I install from the web.
By the way, even though I followed the “magic” step in the tutorials that is supposed to enable USB, it doesn’t work. I did some research that indicates I can set permissions in the /etc/fstab file and maybe do some other things to get it working, but I don’t really need all that. I just have the /media attached to the vm as a shared folder, so I can access any USB drives (like external hard drives which are automatically mounted in /media) simultaneously in both the Ubuntu host and the XP guest. This is actually better than the intended behavior that requires switching the devices back and forth between the host and guest which only allows access in one or the other. I can see that being necessary for like webcams or other peripherals that work with software in the guest, but for me and my hard drives I prefer this way (there may be a performance hit, but hey, it works).
VirtualBox Reloaded
Well, I was able to get into my XP virtual machine by uninstalling VirtualBox 1.6.2 (through Synaptic) and reinstalling version 1.5.6, which I was using before (I knew there was a reason why I wrote down the version numbers of all my programs when I was backing things up). Thanks to Ubuntu Unleashed for giving me the terminal command to download & install it:
wget http://www.virtualbox.org/download/1.5.6 virtualbox_1.5.6-28266_Ubuntu_hardy_i386.deb ; sudo dpkg -i virtualbox_1.5.6-28266_Ubuntu_hardy_i386.deb
My first attempt at running that command failed on two missing dependencies libxalan110 & libxerces27, but I quickly found them in Synaptic and the second try went right through. I also had to replace the .VirtualBox directory in my home folder with the one the that I had backed up to my external drive. To make things even more interesting, VirtualBox automatically showed my vm but it was inaccessible because their shared folders didn’t exist. I had to go and create a dummy folder where the shared folder used to be. After all that, I was relieved to have it start right up to my Windows desktop.
Now I’m going to look into the proper way of upgrading to the new version.
Bluetooth
Much to my surprise, my Apple Bluetooth Keyboard and Mighty Mouse are working out of the box in Hardy… well, maybe not.
I was attempting to set them up, so I turned them on and right clicked on the bluetooth applet in the notification area and chose preferences. I clicked to highlight ‘input devices’, which was already checked, then clicked to add a device. Since nothing showed up, I decided to go the old fashioned way and run a scan in the terminal. I bumped the Mighty Mouse incidentally and low and behold the cursor on my screen moved with it. The mouse was indeed working so I checked the keyboard and I could type just fine. I got all excited at first, but quickly realized that scrolling on the mouse was non-responsive, and the volume keys on the keyboard did nothing.
I decided to reboot and try again, but this time, I’ve got nothing. The mouse showed up briefly now in the bluetooth applet, and seemed to connect, but still didn’t work. Checking for input devices again shows nothing.
So I guess I’ll fool around rebooting and trying again, but I’m thinking I’m gonna have to go with my original plan and do things the hard way.
Touchpad
Setting up the touchpad to work in Ubuntu Hardy like it does in OS X with 2 finger scrolling and 2 finger tap to right click is easy but the solution is not obvious. Back up then edit the X configuration file Xorg.conf:
$ sudo cp /etc/X11/xorg.conf /etc/X11/xorg.BKP.07292008
$ sudo gedit /etc/X11/xorg.conf
Replace the Synaptics Touchpad InputDevice section with:
Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "SHMConfig" "true"
Option "LeftEdge" "10"
Option "RightEdge" "1200"
Option "TopEdge" "10"
Option "BottomEdge" "370"
Option "FingerLow" "10"
Option "FingerHigh" "20"
Option "MaxTapTime" "180"
Option "MaxTapMove" "220"
Option "SingleTapTimeout" "100"
Option "MaxDoubleTapTime" "180"
Option "LockedDrags" "off"
Option "MinSpeed" "1.10"
Option "MaxSpeed" "1.30"
Option "AccelFactor" "0.08"
Option "TapButton1" "1"
Option "TapButton2" "3"
Option "TapButton3" "2"
Option "RTCornerButton" "0"
Option "RBCornerButton" "0"
Option "LTCornerButton" "0"
Option "LBCornerButton" "0"
Option "VertScrollDelta" "20"
Option "HorizScrollDelta" "50"
Option "HorizEdgeScroll" "0"
Option "VertEdgeScroll" "0"
Option "VertTwoFingerScroll" "1"
Option "HorizTwoFingerScroll" "1"
EndSection
Restart X using Ctrl+Alt+Backspace and it’s working. I’ve spent a great deal of time trying to get drag and drop working with the touchpad, but haven’t been successful. I know I can live without it, so I’m just giving up on it.
There is another small issue with the touchpad. It is extremely frustrating to have an accidental mouse click move your cursor while typing on the keyboard. To correct the problem, I need a startup program:
System > Preferences > Sessions
with the following line:
syndaemon -t -d
Thanks again to the authors of the community wiki page.
Fonts
Not sure if I’ll ever need them, but I’m installing the Microsoft Core TrueType fonts because it’s easy. I just have to run the terminal command:
$ sudo apt-get install msttcorefonts
Sessions and Gedit
My last post got me thinking about startup programs, so I might as well go ahead and turn off any that I don’t want. I just have to uncheck them in:
System > Preferences > Sessions
Working with the xmodmap file in the Gedit Text Editor reminded me that I hate the default setting where it automatically creates a backup of every file I save. It’s not a bad concept, but I would prefer that the program save the backup in it’s own directory instead of cluttering up my personal folders (which is an option I’ve grown accustomed to in the Windows only text editor ConTEXT). Since that’s not available, I’m just going to turn it off:
Applications > Accessories > Text Editor
then:
Edit > Preferences : Editor Tab : File Saving
where I uncheck the option ‘Create a backup copy of files before saving’.
Remap Keys
Since the right Super/Apple key and the lower Enter key are both pretty useless in Linux, I’m going to remap them to work as Right Click Key and Control Key, respectively.
In a terminal I launch a program called xev that returns keycodes when a key is pressed.
$ xev
I have an external keyboard connected via Synergy, so I can get all the codes I need:
Right Super: 116, Super_R
Lower Enter: 108, KP_Enter
Right Control: 109, Control_R
Right Click Key: 117, Menu
Then I create a text file in my home folder called .xmodmap using the command
$ gedit .xmodmap
and I enter the following lines:
keycode 108 = Control_R
add Control = Control_R
keycode 116 = Menu
then save the file and exit. The line ‘add Control = Control_L’ is not described in the wiki that I was following. After my initial attempts failed, I had to do some research and install a program called xkeycaps that I found out about via Google which led me to here. The xkeycaps program revealed that the modifier aspect wasn’t turned on so I enabled that and generated a sample output which gave me the line above.
Anyway, to test the mapping, I run the terminal command:
$ xmodmap ~/.xmodmap
and it works. To get the map to run every time I startup, I just have to log out, then log back in. Ubuntu Hardy is smart enough to know that I created the file .xmodmap and it asks me if I want to load it.
Hard Drive
Another thing I’ve never worried about but seems like a good idea, is a high load/unload cycle count on the hard drive as described on the community wiki
My Second Generation (C2D) MacBook is susceptible to a high load/unload cycle count on the hard drive. This is a workaround to lower the drive cycles and extend the drive life. Generate the following three files using the commands below:
echo -e '#!/bin/sh\nhdparm -B 254 /dev/sda' | sudo tee -a /etc/acpi/start.d/99-macbook-fix.sh
echo -e '#!/bin/sh\nhdparm -B 254 /dev/sda' | sudo tee -a /etc/acpi/resume.d/99-macbook-fix.sh
echo -e '#!/bin/sh\nhdparm -B 254 /dev/sda' | sudo tee -a /etc/acpi/suspend.d/99-macbook-fix.shAdd execute permissions to the files:
sudo chmod a+x /etc/acpi/start.d/99-macbook-fix.sh
sudo chmod a+x /etc/acpi/resume.d/99-macbook-fix.sh
sudo chmod a+x /etc/acpi/suspend.d/99-macbook-fix.shTo have these changes take effect immediately (without requiring a reboot):
sudo hdparm -B 254 /dev/sda