How Do You Troubleshoot Mounting a Vboxsf Folder Share on a Linux Guest Running via Oracle VirtualBox on a Windows Host?

Problem scenario:  You are trying to mount a file share using Oracle VirtualBox.  You have a Windows host and a Linux CentOS guest.  (For complete directions on how to set up a folder share for this scenario, see this link.) 

You are trying to run this command:  "mount -t vboxsf contint /mnt/windows-share"
# where "contint" is the name of the folder share in the Oracle VirtualBox GUI.  

But you get this error:

"/sbin/mount.vboxsf: mounting failed with the error: Protocol error"

How do you solve this apparent "Protocol" problem?

Solution
Verify the name of the folder share by going to the GUI for the guest VM.  Then go to Devices -> Shared Folders -> Shared Folder Settings.  In the window that pops up, see the "Name" column on the left.

Replace "contint" in the command with the name of the folder share as seen in the "Name" column.  The command should now work.

How Do You Get the Apache Web Service to Start after a Cold Reboot?

Problem scenario
You want the Apache web service to start automatically after a Linux server is rebooted.  You want it to start automatically when you turn on a Linux server (after being off completely).  On Linux CentOS you have this entry in /etc/crontab:

@reboot            root         apachectl start

You notice that on reboots (warm or soft) it works.  But when you turn on your server after it has been off, this entry does not start Apache web server.  You tried creating a Bash script (making it executable too) in /etc/init.d with this command: "apachectl start".  Despite these things, the Apache web service does not reliably start when you reboot or turn the server on.

How do you get Apache web server to automatically start when the CentOS server is turned on (after a cold or hard reboot)?

Possible Solution #1
As root, issue this command:  chkconfig httpd on

This solution will start the Apache web service automatically when either of the following two things occur: one, when the server is turned on from being off completely (hard or cold reboot).  Two, when the server was warmly (aka softly) rebooted.  

Possible Solution #2
It may be preferable to use "sudo chkconfig httpd on" without being root.  Test it to see if it works on your system.

How Do You Get Apache Web Service to Start Automatically after a Reboot of a CentOS Linux Server?

Problem scenario  
You have to manually start Apache web server every time you do reboot the server.  You want the Apache web service to start automatically.

Solution
1.  Edit /etc/crontab.  Add the lowest line of these two (the line above is for reference):

# *  *  *  *  * user-name  command to be executed
@reboot         root       apachectl start

2.  Save the changes.  You are done.

This solution only works if you are doing a warm (or soft) reboot.  A start up from a turned-off machine will not have the Apache web service running because of this crontab entry.  A crontab would not be needed if your solution could allow the Apache web service to start automatically after a cold (or hard) boot up and a warm (or soft) reboot.  For a solution like this, see this link.

How Do You Fix a PHP Web Page when the Page Is Completely Blank?

Problem scenario
Using a web browser you go to a PHP web page.  There are no errors, but the page is blank.  It is just all white, but you expect content to be rendered (e.g., text should be visible).  The WSOD (white screen of death) is a common problem to troubleshoot in a web browser.  What do you do to see output you want it to display?  

Solution
1.  Did you forget a semicolon ";"?  Some tags or HTML sections can make even a careful programmer's brain skip over a line that needs a semicolon.  Go to the source .php file.  Look for a missing semi-colon at the end of a line.  Omitting a closing semi-colon can make the page render just white.  Add the semi-colon on the line that needs it.  Save the file.  Go back to the browser and refresh the page.  Remember that a semi-colon may appear at the end of a line, but if it is after a closing brace "}", you may need a semi-colon before the terminating close brace.  If you accidentally forgot a semicolon or commented one out, this could cause the page to be blank.

2.  Did you forget a closing brace?  With conditional statements (e.g., if, for, or while), there needs to be a closing brace.  If you accidentally forgot one or commented one out, this could cause the page to be blank.

3.  See if there is an extra <?php in your code.  An unclosed <?php string (with no corresponding ?>) can render a PHP page blank or white.

4.  See if there is an extra */ in your code.  An unopened */ two-character string (with no corresponding /*) can render a PHP page blank or white.  Alternatively, an unclosed multi-line comment opener /* can also cause this problem.

5.  If you are using pg_query commands, are you using a variable?  If so, the variable expansion of the SQL query should have no quotes in the variable itself.  Normally you'll see something like this:

pg_query("select * from goodtable;");

The above works.  However, if you want to have a variable for your pg_query, it should not have double quotes.  It should be like this:

$query = 'select * from goodtable;';
pg_query($query);

6.  
Are you using session_start(), session_set(), or $_SESSION in your code?  These can be used improperly to cause a page to appear blank.  If you are using these functions, see this link.

7.  Did you forget to use session_start?  If variables are referenced later on that relied on this function call, your PHP page may be blank.

8.  The PHP variables (e.g., $varname) involved in the display were not assigned a variable (because of a typo in the code or either because of the result of a deterministic or non-deterministic algorithm).  If you tried to concatenate a variable but forgot to place a period ".", this can cause the entire page to be blank.  If you have a space where there should be a period, this variable assignment may cause the entire PHP page to appear white with no content.  If you have complex lines that you suspect are causing the problem, try commenting out specific lines to see if some content comes back (i.e., put "//" (with no quotes) before the line of PHP code.  This can help you narrow down a seemingly elusive problem.

9.  The page could be blank by design. Are you sure it is not supposed to be blank? Some PHP pages have no HTML to be presented. Examine the code and see if the intended rendering is actually not viewable. Maybe the web page (via the PHP code) is supposed to be blank as it is coded. If your PHP is showing the underlying code in a way that you do not expect (e.g., you see text or raw PHP code when you want to see a publicly presentable and beautifully-rendered web page), see this posting.

10. Is your PHP program using Linux Bash commands? If so, see this posting.

11. Try this link for more suggestions.

How Do You Place a Postgres Database on a Flash Drive on a Windows Host Running Oracle VirtualBox with a Linux Guest VM?

Problem scenario
You have Postgres installed on the Linux guest of Oracle VirtualBox.  You have storage capacity on the Windows host.  You can interactively work with smbclient to share files between the Linux guest and the Windows host.   You want to share files between the two servers without the interactive smb commands.  You want the Postgres database to reside on the Windows host.  This way your Linux guest hard disk does not have to be expanded but can run Postgres commands from your Linux guest.

How do you place a large Postgres database on a flash drive (or USB stick) on a shared folder on a Windows host running Oracle VirtualBox with a Linux guest VM?

Solution
There may be no definitive "best practice" way of doing this, but if there is insufficient space on the Linux guest running Oracle VirtualBox, you may want to configure the entire Linux guest to be on the flash drive itself.  In short, it may be advisable to create a new VM making sure that its files are on this USB stick.  This way the Postgres databases can be on the USB stick.

vboxsf is an Oracle VirtualBox technology that can present Windows folder shares for regular Linux operations.  However, mounting vboxsf file shares in Linux will not allow you to change the permissions of the directory as it is seen in Linux.  Postgres requires a data directory to have specific permissions.  Therefore it seems impossible as of February 2017 to have a data directory to reside on a Windows file share and work with Postgres that is installed on a Linux guest running on Oracle VirtualBox on a Windows host.  

When creating a new VM, do not accept the default location of the virtual hard disk.  Make sure the virtual hard disk is on the USB stick.  Warning:  installing even the minimal version of CentOS will take hours even if you are using USB 3.0 technology.  The I/O is slower with having a virtual disk on a USB stick.  But it is not unusable.  Installing the OS may be the most noticeable part.

How Do You Troubleshoot an Apache Web Service Problem when from a Web Browser You Receive the Error “The Address Is Restricted”?

Problem scenario
You are using Oracle VirtualBox on a Windows host.  You are using a Linux guest that is running Apache web server.  The Apache httpd service is running on the guest Linux server.  But when you are on the Windows host, you try to access the website, you get an error in the web browser.  This is the error you receive:

"This address is restricted
This address uses a network port which is normally used for purposes other than Web browsing. Firefox has canceled the request for your protection."

What do you do to view the web page running on the Linux guest when you are on the Windows host?

Solution
Go to the back end.  Specifically go to the Oracle VirtualBox window for the server with the Apache service.  Go to Devices -> Network -> Network Settings -> Advanced -> Port Forwarding.  

Make sure that there is a rule that involves guest port 80 (or whatever non-standard port Apache web server is configured to use on the guest) and host port 80.  If you do not use host port 80 in your "Port Forwarding Rules", Firefox and Chrome will restrict the address. 

How Do You View the Website That Your Oracle VirtualBox Guest Server Is Presenting with a Web Browser on Your Windows Host?

Problem scenario:  You have a Linux VM guest running on Oracle VirtualBox.  You installed Apache web server on this server.  How do you browse to its website from your Windows host machine?

Solution

#1  Determine the host IP address as configured for the guest.  In Oracle VirtualBox go to Devices -> Network -> Network Settings.  For Adapter1 go to "Advanced" and click the button for "Port Forwarding." The host IP address may be 127.0.1.1.

#2  Open a web browser.  Go to the web page (e.g., http://127.0.1.1/index.html).  

Troubleshooting:  If you are still having trouble, review the steps below.

1.  Verify the file exists in the location you expect it to be. On the back end of the Linux server, use "find / -name httpd.conf"  The "DocumentRoot" stanza will show you which directory path on the Linux server to find the files.

2.  Use this command to see if the Apache web server is running: "ps -ef | grep httpd"
If you do not see a process running, try this command:

apachectl start

3.  Verify no firewall is blocking the connection between your Oracle VirtualBox client and host.  If you are not sure how to do this, you could use a PowerShell command or script on the host.  This posting can help you with that.  You could install nmap on the guest of the Linux server and use that.

Using PowerShell Version 3, How Do You Determine If a Port Is Open for a given IP Address?

Problem scenario
You are using Windows 7 and PowerShell version 3.  You want to test if a port is open to a given IP address.  (If you are using a modern version of PowerShell, use the Test-NetConnection command.)   How do you find out if a port of an IP address is open or not?

Solution
Use the PowerShell function Test-TCPPortConnection written by Jonathan Medd.  Every line of this code except the last line was taken from here.

function Test-TCPPortConnection {
<#
 .SYNOPSIS
 Test the response of a computer to a specific TCP port

 .DESCRIPTION
 Test the response of a computer to a specific TCP port

 .PARAMETER  ComputerName
 Name of the computer to test the response for

 .PARAMETER  Port
 TCP Port number(s) to test

.INPUTS
 System.String.
 System.Int.

.OUTPUTS
 None

 .EXAMPLE
 PS C:\> Test-TCPPortConnection -ComputerName Server01

 .EXAMPLE
 PS C:\> Get-Content Servers.txt | Test-TCPPortConnection -Port 22,443
#>
[CmdletBinding()][OutputType('System.Management.Automation.PSObject')]
param(
[Parameter(Position=0,Mandatory=$true,HelpMessage="Name of the computer to test",
 ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)]
 [Alias('CN','__SERVER','IPAddress','Server')]
 [String[]]$ComputerName,
 [Parameter(Position=1)]
 [ValidateRange(1,65535)]
 [Int[]]$Port = 3389
 )
begin {
 $TCPObject = @()
 }
 process {
 foreach ($Computer in $ComputerName) {
foreach ($TCPPort in $Port) {
 $Connection = New-Object Net.Sockets.TcpClient
 try {
 $Connection.Connect($Computer,$TCPPort)
 if ($Connection.Connected) {
$Response = “Open"
 $Connection.Close()
 }
 }
 catch [System.Management.Automation.MethodInvocationException]
 {
 $Response = “Closed / Filtered"
 }
 $Connection = $null
 $hash = @{
 ComputerName = $Computer
 Port = $TCPPort
 Response = $Response
 }
 $Object = New-Object PSObject -Property $hash
 $TCPObject += $Object
 }
 }
 }
end {
Write-Output $TCPObject
 }
}
Test-TCPPortConnection -ComputerName x.x.x.x -Port 80  # End of code

Replace x.x.x.x with the IP address you want to test.  Replace 80 with the given port you want to test.  You do not have to save the file to run it in the PowerShell ISE application.  Run the code and examine the results.  You will see if a given port is open or not (closed or filtered).

How Do You Get Jenkins Running on Linux to Work With Windows Servers?

Problem scenario
You want your central Jenkins 1.651.1 server running on Linux to push down builds (or run jobs) on Windows servers.  When you try to connect Jenkins master to a slave server, you get an error message like this:

"ERROR: Access is denied. See http://wiki.jenkins-ci.org/display/JENKINS/Windows+slaves+fail+to+start+via+DCOM for more information about how to resolve this. org.jinterop.dcom.common.JIException: Message not found for errorCode: 0x00000005 at org.jinterop.dcom.core.JIComServer.init(JIComServer.java:"

You know the credentials and IP address are correct.  You want the Jenkins server (on Linux) to communicate with other Windows servers.  How do you do this without a permissions error like the one above?

Possible Solution #1
Prerequisites

  • You must use Jenkins version 1.x.  This solution will not work for Jenkins version 2.32.1 or higher.  It may not work for Jenkins 2.x at all. If you want to install Jenkins 1.651.1 see this posting
  • You must have a Windows server to be "managed node" of the Jenkins server running on Linux.  These directions below are of no use if you are not using a Windows server (to configure as a worker node of Jenkins).  If you want to deploy a Windows server in AWS, see this posting.

Procedures
1.  Make sure that JRE is installed on the Windows server.  You can download a standalone (offline) installer here:  https://java.com/en/download/manual.jsp

2.  On the Windows server, open a web browser and go to this URL (constructed with the directions in the sentence beneath it):

http://3.3.3.3:8080/computer/4.4.4.4/slave-agent.jnlp

Replace the 3.3.3.3 with the IP address of the Jenkins master server.  Replace the 4.4.4.4 with the IP address of the Windows server you want builds to run on (aka the Windows slave). 

Click "Run" to install the Java component (the Jenkins Remoting Agent) in the pop up.

If the above does not work, Open PowerShell as administrator and run this command.  The command will look like this (read the content beneath it to customize it properly):

javaws http://3.3.3.3:8080/hudson/computer/4.4.4.4/slave-agent.jnlp

Replace the 3.3.3.3 with the IP address of the Jenkins master server.  Replace the 4.4.4.4 with the IP address of the Windows server you want builds to run on (aka the Windows slave).  If the above does not work, you may need to put a copy of the jenkins-cli.jar file on the WIndows server.  Then you can execute java commands with the jenkins-cli.jar file if you initially pass username and password if your Jenkins instance requires it.

Opening PowerShell without being an administrator, or any sort of CMD prompt, and running the javaws command above will not allow Jenkins builds to work as robustly as you would normally want them to run.  Jenkins may appear to register successful build runs.  The console output (in Jenkins) may have an "Access Denied" message which would refer to the inability of Jenkins to write to certain folders on the Windows server.  

Opening PowerShell without being an administrator, or any sort of CMD prompt, and running the javaws command above can create problems with Jenkins runs that are difficult to troubleshoot.  Despite the improved security, the javaws command should only be run with these methods (e.g., a cmd prompt or PowerShell opened not as administrator) if you are certain you know what you are doing.

Related tip:  JNLP is powerful for managing servers in a heterogeneous environment from a Linux Jenkins instance.  Ensure your Jenkins server does not allow anonymous access.  If from a server you can open a web browser and type in the Jenkins URL and view Jenkins without being challenged for credentials, your Jenkins instance is not secure.

Possible Solution #2
There are no prerequisites. If you want to install Cygwin on the Linux server, the Windows server will act like a Linux server. You can use this posting to install Cygwin.

How Do You Troubleshoot Mounting a cifs File Share when You Get an Error about “wrong fs type, bad option, bad superblock”?

Problem scenario:  You run this command on a Linux CentOS server:

sudo mount -t cifs -o user=jdoe //172.33.44.55/contintshare /mnt/windows-share

But you get this error:  "mount: wrong fs type, bad option, bad superblock on //172.33.44.55/contintshare, missing codepage or helper program, or other error (for several file systems (e.g., nfs, cifs) you might need a /sbin/mount.<type> helper program)"

What do you do?

Solution

The error message is not clear or helpful.  Replace "user" with "username", and try the command again.  For example this command will work:

sudo mount -t cifs -o username=jdoe //172.33.44.55/contintshare /mnt/windows-share