multipathd queue_if_no_path And no_path_retry Explained

If you configure your multipath device to use “no_path_retry N” explicitly you may still see queue_if_no_path in multipath -ll output as a listed feature:

$ multipath -ll
mpathc (3600601608de04200c24aed5886c9b28e) dm-3 DGC ,VRAID 
size=2.0T features='2 queue_if_no_path retain_attached_hw_handler' hwhandler='1 alua' wp=rw

Does it mean the no_path_retry setting was not applied at all? According to multipath.conf man page both, queue_if_no_path and no_path_retry, are identical:

queue_if_no_path
Queue IO if no path is active; identical to the no_path_retry keyword.

But which policy is in use: queue or fail?

Unfortunately, it was not made clear in documentation but if no_path_retry is set to anything but fail, you will see queue_if_no_path in multipath -ll output.

If no_retry_path was set to fail, the output would look like this:

$ multipath -ll 
mpathc (3600601608de04200c24aed5886c9b28e) dm-3 DGC ,VRAID 
size=2.0T features='1 retain_attached_hw_handler' hwhandler='1 alua' wp=rw

This means, that yes, “no_path_retry N” is actually used as a path failure handling policy but queue_if_no_path is displayed instead anyway.

Also, no_path_retry is recommended over queue_if_no_path. Straight from multipath.conf man page:

The usage of queue_if_no_path option can lead to D state processes being hung and not killable in situations where all the paths to the LUN go offline. It is advisable to use the no_path_retry option instead.

If you want to set no_path_retry option explicitly, in an attempt to make sure that failed I/O requests are not queuing up and waiting patiently for a path to come back online, you need to add to your /etc/multipath.conf this:

devices {
 device {
 vendor "DGC" 
 product "VRAID" 
 no_path_retry fail
 }
}

Obviously, you need to match your vendor and product.

Another way to do the same is to use dmsetup command. Assuming you have three different multipath devices: mpatha, mpathb and mpathc.

$ dmsetup message mpatha 0 "fail_if_no_path" 
$ dmsetup message mpathb 0 "fail_if_no_path" 
$ dmsetup message mpathc 0 "fail_if_no_path"

If you have a compatible device it will be most likely configured automatically by multipathd. If that’s the case your multipath.conf would look not very different from this real-life example:

$ grep -v ^# /etc/multipath.conf                                                                                                                                                                                                  
defaults {
        user_friendly_names yes
        find_multipaths yes
}
devices {
        device {
                vendor                  "DGC" 
                product                 "VRAID" 
                no_path_retry           fail
        }
}

blacklist {
}

To apply your changes just run these commands:

$ multipath -d
$ multipath -v2
$ multipathd reconfigure

To verify the changes, look up runtime configuration and look for no_path_retry:

$ multipathd show config

Using snap Application Aliases

If you run snap and snapd <= 2.25 this is how you can set up aliases for snap applications in your snapcraft.yml:

apps:
   psql:
      command: usr/bin/wrapper-psql
      aliases: [psql]
      plugs: [network]

Build and install your snap package. Then you need to enable all such aliases manually as the user you plan to run your application as. Normally, it is an unprivileged user.

Before you can enable an alias, though, you need to make sure you’re logged in:

$ sudo snap login
Email address: *****
Password of "*****": 
Login successful

Otherwise you won’t be able to create aliases as an unprivileged user (only as root via sudo.)

Enable your alias:

$ snap alias postgresql93.psql psql
Added:
 - postgresql93.psql as psql

Verify it was created:

$ snap aliases
Command Alias Notes
postgresql93.psql psql manual

Use the alias:

$ whereis psql
psql: /snap/bin/psql
$ psql --version
psql (PostgreSQL) 9.3.17

Remove your alias:

$ snap unalias psql
Removed:
 - postgresql93.psql as psql

Aliases are unique:

$ snap alias postgresql94.psql psql
error: cannot perform the following tasks:
- Setup manual alias "psql" => "psql" for snap "postgresql94" (cannot enable alias "psql" for "postgresql94", already enabled for "postgresql93")

They can also be enabled automatically upon installation of a snap package when it is installed from a store.

Note, in snap version => 2.26 this behavior will change.

Read more about aliases and upcoming changes here.

The sticky bit note

chmod’s man page doesn’t apparently explain it but “t” and “T” are both signifying a sticky bit, the difference is whether executable flag is set for other or not:

drwxrwxr-T     1774
drwxrwxr-t     1775

Running 2 and more Skype instances on Mac OS X simultaneously

What follows is a copy-paste of this Skype forum post. I’ve tested this on 10.8.2. Seems to work.

 

We do not officially support or recommend running two instances of Skype simultaneously on the one computer. However, it is possible to do this:

Make a copy of Skype:

  1. Open Finder.
  2. In the sidebar, click Macintosh HD > Applications.
  3. Click Skype to select it.
  4. Press Cmd+C, then Cmd+V to copy and paste Skype.
  5. Skype copy appears.

Change the bundle identifier in the Info.plist file:

  1. Right-click the copy of Skype and select Show Package Contents.
  2. Click the folder named Contents, then open the Info.plist file.
  3. In the Info.plist file, locate the bundle identifier setting, com.skype.skype and change it to com.yourname.skype (for example: com.john.skype).
  4. Go to File > Save, and then close the file.

Change the data path used by Skype for storing data files:

  1. Open Terminal (Go to Finder and in the Search field, enter Terminal).
  2. In the Terminal window, enter the command:
    defaults write <new bundle identifier > DataPath <”path to a new data directory”>
    For example:
    defaults write com.john.skype DataPath “~/Library/Application\ Support/Skype\ copy”

Note: after Microsoft had terminated support for older versions and forced everyone to update their Skype this step returns an error now:

2014-08-23 11:13:58.912 defaults[45773:707]
Rep argument is not a dictionary
Defaults have not been changed.

However, I just ignored it and started up Skype and it worked. I can still run two copies of Skype as before.

  1. Press Return.

 

You can rename Skype copy to anything you’d like it to be. For example, you could use Skype business instead. This comes in handy, because when placed on a dock a tooltip will display this Skype business name and make easy for you to distinguish which Skype dock icon represents what instance.

Writeable Linux NFS 4 shares and Mac OS X Finder

In my setup I run Arch Linux and NFSv4 server on this system. I’d like to connect to any of the shares thatare available on this laptop server and write to them from the Finder in Mac OS X.

NFS Configuration

First things first, the Arch Wiki:

https://wiki.archlinux.org/index.php/Nfs
https://wiki.archlinux.org/index.php/Nfs#Mounting_from_OS_X

Then you get NFS and its dependencies installed.

Now, NFS configuration.

I export just one folder, /srv/nfs4/seagate1TB. NFS4 has the concept of the root for the exports and that’s what /srv/nfs4/ is exactly. Access is granted exclusively to specific /29 network.

/etc/exports

/srv/nfs4/ xxx.xxx.xxx.0/29(rw,fsid=0,no_subtree_check)
/srv/nfs4/seagate1TB xxx.xxx.xxx.0/29(rw,insecure,no_subtree_check,nohide,all_squash,anonuid=1000,anongid=1000)

I encourage to read ‘man exports’, specifically General Options, User ID Mapping and EXAMPLE sections.

After reading ‘man exports’ it was clear that the key to configuring writeable NFS share were all_squash, anonuid and anonguid options.

In plain English, when Finder copies to NFS share/export files and folders they have to be created on the NFS server. The server then has to decide who these files are going to belong to. Since the server has no way to tell what user (user ids, the UID and GID) are currently used on the client OS X machine, and also because it is, in fact, not always desired that files are created on a server with the same UID/GID of the user that runs NFS client software, there are basically two options.

First, is to use all_squash which is going to ‘anonymize’ UID/GID and instruct NFS server to create files in such a way that they belong to nobody user. Alternatively, you can set all_squash, as well as anonuid=1000 and anongid=1000 to match first non-system user on a modern Linux system.

So, I know that I store files on the disk that is exported as a specific user, so I configured my NFS export/share to create files on behalf of a client (Finder in Mac OS X) as that specific user (that’s what anonuid and anongid are for).

One more thing. Just for the sake of completeness, this is how I mount the disk and make it available for NFS export:

/etc/fstab

UUID=9d244934-d9fa-4a8e-8dd7-5c595f5518cf /mnt/seagate1TB auto defaults 0 0

# NFSv4
/mnt/seagate1TB /srv/nfs4/seagate1TB none bind 0 0

I first mount this disk device with unique identifier (UUID) in /mnt/seagate1TB, then bind it to /srv/nfs4/seagate1TB. I like to keep things multihomed sort of. Meaning, they can do many functions simultaneously, so this disk isn’t used for NFS alone and it makes sense to mount it in /mnt/seagate1TB first.

If you couldn’t care less about such things, just mount it directly to /srv/nfs4/seagate1TB to have it as a reminder that it is explicitly used for NFS.

You can also use symlinks, that are really handy. Consider the following example:

% ls -l /srv/nfs4/

disk -> /run/media/joe/disk
disk-1 -> /run/media/joe/disk-1
disk-2 -> /run/media/joe/disk-2
seagate1TB -> /run/media/joe/9d244934-d9fa-4a8e-8dd7-5c595f5518cf/

In fact, I’ve switched to using symlink because it lets me maintain NFS export handles in a consistent fashion regardless of where the actual filesystems/disks are mounted. So, I can always access them as:

myserver.net:/srv/nfs4/disk
myserver.net:/srv/nfs4/disk-1
etc

while the disk are mounted elsewhere.

Firewall and NFS4

If you have a restrictive firewall things get really interesting. rpcbind daemon uses random ports to facilitate client to server connections. Fun! Honestly, I don’t know how to deal with this. Well, except restarting firewall manually or granting access to all destination ports for the host in question (this is what I’m doing on my home LAN).

Trivia

To quickly unexport all shares on the server:

exportfs -au

To quickly mount/export all shares on the server:

exportfs -rav

-v will increase verbosity so that you know what’s going on.

How to release mouse pointer in virt-manager running inside VNC client on Mac OS X

My setup consists of Mac OS X system that runs RealVNC client to connect to Ubuntu Server machine that is a KVM host via VNC.

When working in guest VM graphical console (as opposed to text console which usually requires additional configuration of guest VM) you may end up clicking into the black area.

That would grab your mouse pointer.

Actually, you don’t have to click VM screen area if all you want to do is type in something but if you must use mouse to click something inside the terminal view it’s going to get locked.

To release your mouse pointer normally you’d press Ctrl_L+Alt_L, as it is stated in the window title.

Screen Shot 2013-01-31 at 5.18.48 PM

However, it didn’t work on Mac.

Instead you need to use:

Ctrl_L+Command_L

which has the same effect.

PS: interestingly it is one of the top blog posts on this blog. I guess way too many people run into this problem? If you’re one of them let me know in the comments section down below.

GnuCash: Editing Currency Exchange Rate

GnuCash can deal with multiple currencies. However, its behavior when setting currency exchange rates is somewhat obscure and had me spend literally hours to figure out how to get it under control a couple of times.

The use case. Account A is in USD currency, account B is in UAH currency. You need to transfer funds from A to B, which involves currency exchange rate.

When you do this the very first time, you enter Description of the transaction, specify the account B to transfer funds to, and key in Debit/Withdraw value of say 150USD and then hit Enter key, GnuCash then will present you with an exchange rate editor window where you should be able to enter the exchange rate for this transaction.

As it often happens, many transactions are repetitive, and luckily GnuCash helps making these records fast by offering you a history autocompletion function, much like one found in LibreOffice and Bash/Linux/UNIX terminal.

So, typically a user would quickly create another new record in a ledger for account A, specify a different amount of Debit/Withdrawal this time and find out that the resulting value in account B is wrong.

Continue reading