Safely ejecting USB flash thumb drives in Linux

In Windows, we use safely remove devices when removing USB drives, as typical inexpensive flash drives write data quite slowly (less than 5MB/sec). This is because by default, Windows “write caches”, that is, Windows uses RAM to temporarily store files — making the copy/write operation appear done faster than it actually is.

In Linux, the write caching is used as well, and you should verify writing to a flash drive is completed by typing sync at Terminal and waiting for the $ prompt to come back up. You can watch the writing progress with iotop or the graphical indicator-multiload. You then click the Eject icon next to the flash drive’s name in your File Manager (in Ubuntu, it’s nautilus)

Consider that your flash drive only writes at say 2MB/sec. to be “safe”. Then, writing a 1GB file will take 1000/2=500 seconds = 8.3 minutes!

Which format to use for sharing USB flash thumb drives and USB HDD

I have found that EXFAT is the most convenient format for sharing files between Mac/Linux/Windows/Android.
EXFAT is supported from Windows XP through Windows 8.1 and beyond.
EXFAT is supported on Mac OS X from 10.6.3 and newer [1].
EXFAT is supported on Linux from CentOS 5 and Ubuntu 10.04 and newer.
EXFAT is supported from at least Android 4 onward.

NTFS is not writeable on Mac OS X by default, in Mavericks I have read that one must either go into Terminal and use Homebrew or edit your /etc/fstab and make some manual changes. I.e. something not easy to do at a conference or casual meeting quickly. NTFS is NOT supported on Android.

FAT32 is also readable by Windows/Mac/Linux/Android, but is limited to 4GB file size. Sometimes I share large raw/compressed data files that are larger than this, especially if using a USB HDD. With many USB HDDs over 2TB, you would have to break up your HDD into multiple partitions for FAT32 — quite inconvenient. You could use FAT32 for a small USB flash drive. Note, I have found that when using a USB flash thumb drive to plug into a printer to “USB Direct Print” that single partition FAT32 is supported, but not EXFAT. So I keep a small USB drive formatted to FAT32 for this purpose.

Summary:
In my opinion, EXFAT is the best choice for universal support on USB HDD
For USB flash thumb drives, I format most to EXFAT–keeping a small flash drive formatted to FAT32 in case I need to quickly use the USB port on a USB direct print printer (Dell, Brother, etc.)

Important note: As I was reminded in the comments by Bob Foss, there are a variety of devices such as in-car entertainment, printers, Agilent test equipment, etc. that require only a single FAT32 partition. Since USB drives are so small and inexpensive, I keep an old USB flash drive formatted to FAT32 for these special cases.

Also, for SD cards, many devices expect still expect FAT32, so you may need to use FAT32 for SD cards just for compatibility reasons.

References:
[1] https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/fsck_exfat.8.html

Stop MATLAB high CPU usage on Idle (Windows/Mac/Linux)

For at least Matlab R2013a and R2013b, you may find that after opening the Matlab Help Browser (and even after closing just the Help Browser while keeping Matlab itself open), that Matlab uses 100% of one CPU core at about 25% duty cycle.

You can try pasting this command into Matlab (it will persist, you do NOT have to put this in startup.m).

com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType('HTMLRENDERER');

Then restart Matlab, you should see the CPU is not hanging at 100% after closing the Help Browser. Matlab will remember this setting.

However, this simpler Help Browser is not as graphically nice as the default Java Help Browser; sometimes clickable links are broken in the help files. You can thus revert back to the default Java Help Browser by pasting into Matlab command line:

com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType('HTMLPANEL');

and restart Matlab. Matlab will remember this setting too.

Xrdp on Ubuntu 12.04 through 14.04

Note: ubuntu-2d was REMOVED from Ubuntu 12.10 onward. So for Xrdp on Ubuntu 12.10 and newer, observe the specific steps below.

For cases where you have to allow RDP users from Mac/Windows to connect to a linux machine, and for whatever reason you can’t install TightVNC on the Mac/Windows user PCs, you can try Xrdp, which creates an RDP server on port 3389 on the Linux PC.


sudo apt-get install xrdp

Now on ubuntu 12.04 we need to edit a configuration file

nano ~/.xsession

——————–
copy and paste [for Ubuntu 12.04 only]:

gnome-session --session=ubuntu-2d

[for Ubuntu 12.10 through 14.04]: copy and paste into ~/.xsession

exec openbox

then exit nano

and in Ubuntu 12.10 through 14.04, type:
sudo apt-get install openbox
————————————————-
then type

sudo service xrdp restart

Note: For Ubuntu 12.10 and Ubuntu 13.04 ONLY, you can also use gnome-session-fallback. But gnome-session-fallback is BROKEN in Ubuntu 13.10. You can also use XFCE in any of these Ubuntu versions.

Note, if you use Openbox, you’ll just see a grey screen upon typing password at Xrdp login. Right-click mouse to open menu.

Note: If you just get a gray screen, trying editing
/etc/xrdp/startwm.sh
to just have

----------
#!/bin/sh

if [ -r /etc/default/locale ]; then
. /etc/default/locale
export LANG LANGUAGE
fi

exec openbox
———–

Using SketchUp 8 in Linux (wine)

You will possibly get a “SketchUp was unable to initialize OpenGL” error when trying to use SketchUp 8 under Wine 1.5 (and sometimes under Windows XP on older hardware).

To fix this OpenGL error for SketchUp8 on Windows XP or Linux/Wine, type “regedit” and then edit the key:
HKEY_CURRENT_USER/Software/Google/SketchUp8/GLConfig/Display
to have a value of 1.

Reference:

http://www.brighthub.com/internet/google/articles/118016.aspx

Installing FFMPEG and FFPLAY on Windows

To install FFMPEG and FFPLAY on Windows (XP through 7) follow these steps:

1) download FFMPEG from http://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-latest-win32-shared.7z
2) unzip the folders inside to c:\ffmpeg
3) set your PATH to include c:\ffmpeg\bin

You can now use the powerful FFMPEG from the Windows Command Prompt.

Note: if you don’t already have 7zip installed on Windows, download 7zip from:

http://www.7-zip.org/download.html

One-click RDP over SSH tunnel with Windows machines at both ends

While you can use PuTTY for SSH tunneling and then manually launch Remote Desktop Connection, I find it more efficient to simply reuse techniques so convenient from Linux. Here is how to do one-click RDP over SSH tunnel using Windows on both ends using Cygwin.

Example:
Suppose your remote SSH server on the remote Windows PC is on port 22 at WAN address 1.2.3.4, and it has a firewall blocked (as it should be!) RDP server at Port 3389 (the standard Windows Remote Desktop port). You have a user “joe” setup on the remote PC for remote access. Then, do:

  1. In Cygwin, type nano ~/myRDP and type:
    #!/bin/bash
    ssh -f -p 22 -L 3391:localhost:3389 joe@1.2.3.4 sleep 2;
    mstsc /v:localhost:3391
  2. Exit and save, then type chmod +x ~/myRDP
  3. In Windows, create a shortcut to:
    C:\cygwin\bin\mintty.exe -e /bin/bash -l -c '$HOME/myRDP'

Double clicking that windows shortcut should launch cygwin, make the SSH connection (you’ll be prompted for SSH password, or use a public key file) and then make the RDP connection over the SSH tunnel (where you will be prompted for the Windows password).

Notes:

1) You can’t specify most Remote Desktop parameters on the MSTSC command line, but if you need to do this, you can save a .RDP profile file (here, we saved it to
c:\MyRDP\MyFirstPC.RDP
) from Remote Desktop Connection and then load that specific profile by:

mstsc "c:\MyRDP\MyFirstPC.RDP" /v:localhost:3391

Note, we used Port 3391 for the local forwarding because Windows 7 uses Port 3390 for something else.

On Windows 7, you may find you have to specify an RDP file. Here’s an RDP template you can try–save this as the MyFirstPC.RDP file, after changing the 2nd to last line JoePC\Joe to match your Domain\Username:


screen mode id:i:1
use multimon:i:0
desktopwidth:i:1024
desktopheight:i:768
session bpp:i:24
winposstr:s:0,1,0,0,1024,768
compression:i:1
keyboardhook:i:2
audiocapturemode:i:0
videoplaybackmode:i:1
connection type:i:1
displayconnectionbar:i:1
disable wallpaper:i:0
allow font smoothing:i:0
allow desktop composition:i:0
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:1
disable cursor setting:i:0
bitmapcachepersistenable:i:1
full address:s:localhost:3391
audiomode:i:1
redirectprinters:i:0
redirectcomports:i:0
redirectsmartcards:i:0
redirectclipboard:i:1
redirectposdevices:i:0
redirectdirectx:i:1
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
gatewayhostname:s:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
promptcredentialonce:i:1
use redirection server name:i:0
networkautodetect:i:0
bandwidthautodetect:i:1
enableworkspacereconnect:i:0
rdgiskdcproxy:i:0
kdcproxyname:s:
username:s:JoePC\Joe
drivestoredirect:s:

Thanks to Chhavi Goenka for testing this on Windows 7 on a live system.

Windows XP: missing class msstdfmt.dll

This class missing msstdfmt.dll might be related to a VB6 program you’re trying to use. To download msstdfmt.dll from Microsoft, follow these steps:

  1. download 2gb152.exe (<1MB):

    http://www.microsoft.com/en-us/download/details.aspx?id=12972

  2. Run this 2gb152.exe, extracting its contents to c:\temp
  3. Copy msstdfmt.dll to c:\windows\system32
  4. click Start, Run, then type
    cmd
    and press Enter
  5. type regsvr32 c:\windows\system32\msstdfmt.dll

Now your program will hopefully work. Note if you’re on 64-bit Windows, consider Ryan’s comments below.