2008-05-09

Samba error message

Samba error message leaves a lot to be desired.

I spent 2 hours tracking down the cause of:

$ smbclient //berbagi.3/berbagi
Password:
Anonymous login successful
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.24]
tree connect failed: NT_STATUS_BAD_NETWORK_NAME

Turned out it was caused by a parent directory to the real path being not world-readable.

2008-05-02

XP hanging when opening files

XP seems to hang when opening files. It does not actually hang; it is just doing file browsing very slowly because of certain settings. Below are the settings you can change to make file browsing faster.


From http://forums.pcpitstop.com/lofiversion/index.php/t121312.html

Go to Start - Run
type gpedit.msc
hit enter

ENABLE User Configuration select Administrative Templates - Start Menu and Taskbar-"Do not use the search-based method when resolving shell shortcuts"
ENABLE User Configuration select Administrative Templates - Start Menu and Taskbar-"Do not use the tracking-based method when resolving shell shortcuts."
ENABLE User Configuration - Administrative Templates - Windows Components - Windows Explorer-"Do not track Shell shortcuts while roaming"



From http://www.ss64.com/nt/slow_browsing.html

Removing all shortcuts from 'My Network Places' will return the system response to normal.
Prevent XP from placing shortcuts under 'My Network Places' by changing registry HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoRecentDocsNetHood to 1.


More information http://support.microsoft.com/?kbid=841978

2008-04-26

An actual restoration from Drive Snapshot backup

I had to restore a disk encrypted with PGP Whole Disk Encryption from a DriveSnapshot backup. I posted about the general idea, but the following are the steps of a real one:

# /dev/sda is the drive I needed to restore
# /dev/sdb1 contained the backup files and fullcd.iso

mount /dev/shm
mount -o ro /dev/sdb1 /media/sdb1
qemu -hda /dev/sdb -hdb /dev/sda -cdrom /media/sdb1/fdfullcd.iso -boot d
snapshot show hd2
snapshot show file.sna
snapshot restore hd2 mbrall file.sna
snapshot restore hd2 auto file.sna

xfdisk -> install boot manager (overriding pgp bootloader) -> create new menu entry pointing to the partition.

reboot.

2008-03-19

Accessing USB printer under OpenVZ VE

To access USB printer from within OpenVZ Virtual Environment (VE), you need to allow the device to be visible and accessible by doing the following from the Host Environment (HE):
vzctl set 999 --devices usb/lp0:rw

cat /proc/vz/devperms
#Version: 2.7
# 0 b 016 *:*
# 0 c 006 *:*
# 999 c 006 180:0


If there is any trouble with printer access from within VE, verify that there is none from HE .

In my case, CUPS within VE correctly detected my printer at ``usb://Samsung/ML-1740``. Yet it couldn't push any job to the printer. I spent hours trying to get it work to no avail. What I should have done was to verify if CUPS in HE could do it successfully. It couldn't. But CUPS-in-VE in another machine could push the job successfully. The problem, then, probably was with the hardware.

So, I settled with specifying the printer location (DeviceURI) at ``file:/dev/usb/lp0``. It works, except that it can't read printer status because it requires two-way communication which ``file`` protocol does not support.

2008-03-12

Shorewall and OpenVZ

A pretty basic Shorewall configuration can consume about 190 iptent (iptable entries) and the default limit is 128. So, if you are getting 'iptables: Cannot allocate memory' error message, check your /proc/user_beancounters because you might have hit the numiptent (number of iptable entries) limit.

OpenVZ VE's private and root directories must be on the same device

Files in a VE are stored under /var/lib/vz/private/${veid}. There is also /var/lib/vz/root/${veid} which is empty if the VZ is not alive and populated with what the VE sees when it is alive.

If you are moving the VE storage to another device, make sure to move both the private and root directories.

mount /mnt/newlocation
ln -s /mnt/newlocation/private/999 /var/lib/vz/private/999
ln -s /mnt/newlocation/root/999 /var/lib/vz/root/999


Otherwise you'll be getting this erronous error message:

> vzctl start 999
Starting VPS ...
vzquota : (error) Quota on syscall for 999: Device or resource busy
vzquota on failed [3]

2008-03-11

qmail in resource-constrained environment

An important thing to note when using virtualised environment
such as OpenVZ is that resources are artificially constrained. This can cause various funny and head-scratching behaviours.

My OpenVZ VE (plan VZ 128) from quantact.com, runs apache2 and qmail (as spooler).
I had to adjust tcpserver connection limit to 3 (tcpserver -c 3), and qmail-send's concurrencyremote to 1 (echo 1 > /var/qmail/control/concurrencyremote).

Each incoming SMTP request triggers an RBL lookup and may trigger a spamassassin check. The default tcpserver's incoming connection limit is 40 and there just isn't enough resources to support 40 spamassassin instances (1 spamd with 40 spamc processes). Instances will fail with various puzzling error messages. The only clear indication that they are failing because of resource constraint is by comparing the content of /proc/user_beancounters before and after failures.

Furthermore, if the remote host, where the real mail server is, is down for a period such that enough mails are queued up, when the remote host is up again, qmail-send will start 20 qmail-remote processes (the default) to send the mails all at the same time. Each process will send email to the real mail server through a stunnel connection. But there just aren't enough resources to support 20 qmail-remote processes along with 20 stunnel connections. Again, the only way to know this for certain is by comparing the content of /proc/user_beancounters before and after failures. Otherwise, all you are getting are error messages like below which could have been caused by various things like network or firewall problem:

2008-03-11T06:53:02.78164 2008.03.11 02:53:02 LOG3[11407:3058117552]: SSL_accept: Peer suddenly disconnected


Once the concurrency level is brought down, force qmail to resend the queue:

qmail-qstat; qmail-tcpok; pkill -ALRM qmail-send; qmail-qstat

OpenSSH: Hashed Known Hosts

Read more at https://itso.iu.edu/Hashing_the_OpenSSH_known__hosts_File.

To hash every user's known_hosts files and delete the known_hosts.old:

for username in `cut -f 1 -d : /etc/passwd`; do echo $username; sudo -u $username ssh-keygen -H; rm `sh -c "echo ~$username/.ssh/known_hosts.old"`; done

2008-03-08

Restoring Drive SnapShot from Linux

I use Drive Snapshot to archive our Windows machines. It is a Windows backup/disk imaging tool that does not require you to interrupt your other work in other applications. It is a good tool and has repaid its cost (US$ 57.56 in 2007 May) many times over.

Compared to other similar tools at the time, it was really the quickest and simplest one. However, its main downside was that it required DOS or Windows for restoring from scratch. DOS is troublesome to setup. There may be special drivers needed to be able to access the harddrive to be restored and also the backup files themselves. Restoring from Windows is slightly better, but only if you have another Windows machine and go through the hassle of hooking up the target drive to that machine.

Here is a method that I find easy enough for in-situ restoration. You need Live-CD Linux, QEMU and FreeDOS ISO image. I use Knoppix 5.11 since it includes QEMU.

  1. Boot Knoppix to GUI mode for QEMU UI.
  2. Make sure FreeDOS ISO image is accessible on a different partition/disk than the Snapshot image files (.SNA).
  3. The SNA and snapshot.exe filesmust be in a FAT32 volume
  4. qemu -cdrom freedos.iso -hda /dev/${fat32-partition-containing-sna-files} -hdb /dev/${target-harddrive} -boot d
  5. Follow the DOS restoration instruction. For example: snapshot.exe restore HD2 MBR image.sna which restores the MBR record from the image.sna (the CWD is assumed to be C:\ which corresponds to the fat32-partition-containing-sna-files device) to HD2 (the QEMU's hdb device which is the target-harddrive).

Hope this helps.


20080904 UPDATE: A step-by-step instruction
http://gnomicnotes.blogspot.com/2008/04/actual-restoration-from-drive-snapshot.html

2008-03-07

ntpd in openvz ve

ntpd needs to change the system time. In OpenVZ, VEs share the host's system time. The VE running ntpd needs to be given the CAP_SYS_TIME capability:
vzctl set 101 --capability sys_time:on --save