Portions from: http://blog.andrewbeacock.com/2009/03/how-to-move-existing-cygwin.html 

... also relevant for backing up Cygwin.

Here are the steps to move your Cygwin installation:

  1. Save off existing mount points
    mount -m > /usr/bin/mountCommands.bat
  2. Unmount existing mount points
    umount -A
  3. Copy Cygwin directory to new home -- or mv it.  Use Cygwin commands, not Windows Explorer commands or you'll get broken symlinks and distorted permissions in some circumstances.  
    1. mount -s -b --change-cygdrive-prefix "/cygdrive"
    2. tar -cvf /cygdrive/c/cygwin.tar bin cygwin dev etc lib sbin srv tmp usr var cygwin.bat cygwin.ico
    3. cd $destination
    4. mkdir cygdrive
    5. tar -xvpf /cygdrive/c/cygwin.tar
  4. In theory, you could do the previous steps with something like: cd /; tar -cf - * | (cd "$tgt"; tar -xfp - )
  5. Update any Windows shortcuts & Start Menu items
  6. Update the Cgywin path within $CYGWIN_HOME/cygwin.bat
  7. Update mount points within $CYGWIN_HOME/bin/mountCommands.bat
  8. Re-mount to new location
    • Start Cygwin
    • ./mountCommands.bat
    • Close Cygwin

Note: If you move cygwin to a flash drive, and you intend to use the flash drive on multiple computers (or even in multiple instances of Windows on the same computer), you'll need to format the flash as FAT32.  If you use NTFS, the file owner will be static by GUID, and it won't work except on one computer.

 

Moving your home directory:

  1. Use Cygwin commands, not Windows Explorer commands or you'll get broken symlinks and distorted permissions in some circumstances.
  2. I use a symlink '/home' to point to the directory that contains user home directories, so that has to get updated
  3. You might need to update the Windows HOME environment variable, because cygwin uses it to set your cygwin home directory.
  4. I started getting double-wide display with rxvt.  It was because my Windows HOME environment variable was set to newdrive\home instead of newdrive\home\kevin

Note: You *do* want your home directory to be NTFS, so that .ssh can have the correct permissions.