Wednesday, March 26, 2014

Expand OS X virtual disk in esxi

As you all know, it is currently not possible to expand a disk (vmdk) with 'OS X' on it in esx so that you get more space.

Well, that's not quite true. You can expand the disk. That's not the problem. You can do that using the command 'vmkfstools -x' as described here:

VMware KB: Adding space to an ESXi/ESX host virtual disk

The problem is that by using disk utility it is currently not possible to expand the size of the partition:

VMware KB: Unable to extend a partition using the guest Disk Utility after extending disk of a virtual machine running Mac OS X

So, what's the solution?

Well, it's actually quite simple:

  1. Create a new Hard disk of the size you need.
  2. Restore the contents of the too small disk to the new disk using disk utility.
  3. Detach both disks from the virtual machine
  4. Rename the old disk by issuing the command 'vmkfstools -E OldName.vmdk' as shown here VMware KB: Renaming a virtual machine disk (VMDK) via the vSphere Management Assistant (vMA) or vSphere CLI (vCLI)
  5. Rename the new disk by issuing the command 'vmkfstools -E NewName.vmdk OldName.vmdk'
  6. Attach the new disk to the VM
  7. If everything is working, delete the old disk

Tuesday, March 25, 2014

Virtualize physical OS X Server: Best practice

So you plan to virtualize a physical server running OS X?

Too bad all the tool for converting a physical server into a virtual server run on Windows or Unix.

Wenn, actually there is (quite) a simple way to do this. This method is independent of any product and can be used with any virtualization such as Parallels, VMware.

Just follow these steps:

On you physical server:

  1. Boot from an external volume and create a disk image of your server using 'Disk Utility'.
  2. After the disk image has been written, mount it and verify that it can be read and has all the data required on it.
  3. Select the image in the sidebar and run the menu 'Images > Scan Image for Restore'
  4. Turn off your physical server
Intermediate steps:
  1. Copy your disk image to a server that is accessible via AFP
  2. Note down the address, path and the credentials needed to access this image via AFP.
Inside virtualization:
  1. Create a new virtual machine for OS X.
  2. Make sure you have access to a bootable OS X media inside the virtualization. Normally this is done by using a disk image that is assigned to the virtual machine as a  CD ROM drive. If you are unsure how to create such a medium, you can use an app like DiskMaker X to create a bootable USB stick from which you can create a bootable disk image.
  3. Create a HDD in the virtual machine that is large enough.
  4. Create a network interface that has access to a network, preferably one that assigns addresses via DHCP.
  5. Start the virtual machine
Inside the virtual machine:
  1. The VM will now boot using the disk image supplied. In this example I am using a bootable "OS X 10.9 Mavericks" but the same method works with other versions.
  2. Don't start the installation process!!! Remember: we want a virtualized copy of our physical server, not a new server
  3. From the 'Utilities' menu select 'Terminal'.
  4. Once the terminal is running make sure we have an IP address by typing 'ifconfig'. The line starting with 'inet' should now show a valid IP address.
  5. Now we need to mount our disk image. There is a little trick involved here. As we have to mount our server via command line, we need a folder to attach our mount to it. In order to do so, we need a writable directory.
  6. One directory that is writeable is the Trash. So we cd into that directory by typing the command 'cd Library/.Trashes'.
  7. We are now in the directory '/var/root/Library/.Trashes'. Check that it is writeable by creating a folder using the command 'mkdir mnt'. If you see this 'mkdir: mnt: Read-only file system' you have to find another folder that is writable. There is always one as the system itself need to write certain files.
  8. So once we have created our directory, we can mount the AFP share that host our disk image. This is done by issuing the command (by replacing 'myusername', 'myserver' and 'mysharedvolume' with you own data as noted above)  'mount_afp -i afp://myusername@myserver/mysharedvolume mnt'   
  9. You are now requested for the password of the AFP user you use to mount the volume
  10. Once the volume has been mounted, you can verify everything is working by showing the contents of the mount volume by issuing the command 'ls -l mnt'.
  11. If your disk image is visible in here, we're almost done.
  12. Quit the Terminal
  13. Open 'Utilities > Disk Utility'
  14. Select the disk image of your virtual machine and go to the 'Restore' tab.
  15. In here, drag the disk you selected on the left that is now listed as 'Source' to the 'Destination field.
  16. Now we click on the button 'Image…' next to the 'Source' field. Here we select the image we created from our physical server that is now located on our AFP share we mounted in the steps above.
  17. Once this has been done, we can click on 'Restore'.
  18. The disk image of our physical server is now being restore to our virtual server.
  19. Once this has completed, we can quit 'Disk Utility' and go to 'Startup Disk…' that can be found in the menu under the Apple logo.
  20. Here we select our newly restored disk.
  21. Select 'Shut down' from the Apple menu
  22. Go to the settings of your VM and adjust network and RAM configurations as required. Detach the image file attached to the CD ROM drive.
  23. Start the VM.
  24. Et voilĂ  ! An exact copy of your physical server is now virtualized.

Tuesday, March 18, 2014

Apple Remote Desktop or another administration application is currently running.

Have you ever encountered this message:

«Apple Remote Desktop or another administration application is currently running.»
This message shows up when you try to observe or control a Mac that is itself running 'Remote Desktop Admin'.

If you have access via ssh, you can try this:

connect to the client via ssh
enter these commands:

defaults write /Library/Preferences/ AdminConsoleAllowsRemoteControl -bool true
sudo killall 'Remote Desktop'

From now on, you are able to access this client even though Remote Desktop Admin is running. 

I know you can adjust this setting in the preferences.
But, if you are not able to adjust them, do it via ssh.