Virtualbox OSX freeze

From time to time, esp. after starting a few virtual systems at the same time, the whole OSX system can freeze and there is basically nothing to rescue the system but cold reboot.

This is due to some limits set to low, which can be fixed by:

sudo sysctl -w kern.aiomax=512 kern.aioprocmax=128 kern.aiothreads=16

That will be effective till reboot, it can be made persistent by adding the following line to /etc/sysctl.conf


kern.aiomax=512
kern.aioprocmax=128
kern.aiothreads=16

Found at http://www.firewing1.com/blog/2013/08/02/setting-os-x-kernel-asynchronous-io-limits-avoid-virtualbox-crashing-os-x

Vagrant issue Timed out while waiting for the machine to boot

vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/xenial64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/xenial64' is up to date...
==> default: Setting the name of the VM: vagrant_default_1516452195026_53624
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 5000 (guest) => 5000 (host) (adapter 1)
default: 7474 (guest) => 7474 (host) (adapter 1)
default: 7687 (guest) => 7687 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Resized disk: old 10240 MB, req 51200 MB, new 51200 MB
==> default: You may need to resize the filesystem from within the guest.
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

Run
vagrant destroy

Upgrade Virtualbox and do the vagrant up again

OSX disk media is not present

Trying to mount an ext2 / ext3 / ext4 device using external drivers on OSX might bring up the following error:

disk media is not present

in:
sudo dmesg

To fix that a virtual machine helped.

Attaching the external drive using usb, creating a filter for that usb device to forward it to the ubuntu based VM.

Run
fdisk -l

to find the right device.
E.g. /dev/sdd

Now go with fsck.ext3 (for ext3 only)

fsck -y /dev/sdd

-y means answer every question with yes.

For a 2 TB HDD that might take up to several hours, but after that is finished, you can try to mount the drive again.

eSATA Drive in QNAP

If you want to use a eSATA drive in a QNAP device without plug and play, read the following.

Attach drive to eSATA drive.
ssh admin@yourip
#dmsg

Check for:

[11936.459226] ata5: SATA link up 1.5 Gbps (SStatus 113 SControl F310)
[11936.499252] ata5.00: ATA-8: WDC …., 04.05G09, max UDMA/133
[11936.499295] ata5.00: 3907029168 sectors, multi 0: LBA48 NCQ (depth 31/32)
[11936.539268] ata5.00: configured for UDMA/133
[11936.539323] ata5: EH complete
[11936.539646] scsi 4:0:0:0: Direct-Access WDC WD…. 04.0 PQ: 0 ANSI: 5
[11936.549494] Check proc_name[sata_mv].
[11936.559626] sd 4:0:0:0: [sdza] 3907…. 512-byte logical blocks: (2.00 TB/1.81 TiB)
[11936.559899] sd 4:0:0:0: [sdza] Write Protect is off

Important is sdza

Format the drive:

mke2fs -t ext3 /dev/sdza

Mount the device

mount /dev/sdza1 esata/

Be happy

Convert vmdk to raw / dd

Found a vmdk file / image of a virtual server and want to investigate it? Most forensic tools work with image files (such as DD output or raw) and a small tool can help you to convert it:

Install qemu:

apt-get install qemu

qemu-img convert -p -O raw source.vmdk destination.raw
(0.00/100%)

OpenOffice problem window restore

If your OpenOffice crashed running Apple OSX, you might run into a problem where a dialog is asking you wether you would like to restore your old windows / documents.

When you click one of the two options, nothing happens.

You can solve the problem (make a backup of the folder before deleting it):

THIS IS ON YOUR OWN RISK!

Quit open office (using task manager or alt+cmd+esc)
Open Terminal
cd  ~/Library/Saved Application State/org.openoffice.script.savedState
rm -rf *

That will delete all content of that folder.

Adding your own crt from a CA to ubuntu local ca store

If you are trying to for example develop python and accessing something encrypted with SSl and that SSL certificate is not signed by a well known CA you might get an error.

That is because your CA is not added to the local CA store of e.g. Ubuntu.

You can add your signatures by:

sudo mkdir /usr/share/ca-certificates/extra
sudo cp FOO.crt /usr/share/ca-certificates/extra/FOO.crt
sudo dpkg-reconfigure ca-certificates

Then the new certificates will be added to your local store.
(please be careful as sudo dpkg-reconfigure ca-certificates is only checking for files *.crt, so no *.cer etc).

How to do housekeeping with a lot of text files

If you save a lot of textfiles, e.g. you store historical versions of webpages, you do not want to store empty files or duplicate files.

Housekeeping can be done that way:
1. find empty files

find $PATH -type f -empty

if you want to delete them:

find $PATH -type d -empty -delete

2. find duplicate files

fdupes -r $PATH

In order to delete the duplicate files:

fdupes -rdN $PATH

r - recursive
d - preserver first file, delete other dupes
N - run silently (no prompt)

(from: http://askubuntu.com/questions/177346/how-to-use-fdupes)

That will result in a reduced number of files and in a reduced number of duplicate content.