Hibernate mode of OSX

I have been happy since I bought my Mac Book Air but I realized that its disk was running out of space, so I have checked various files and directories on it. I found that /private directory had over 6.0 GB (including some swapfiles) and there were a file called sleepimage on /private/var/vm (The real one was on /var/vm), which was 4.0GB.

I investigated what was the sleepimage, I found out that it seemed to be the one that was used for hibernate mode of OSX, which was a temporary reserved for physical memory.

Based on some information in the Internet, it seems to be that when the battery is running out, the contents of the physical memory is backed up in the sleepimage file (/var/vm/sleepimage) temporarily, after that, OS goes down.

My decision is to make the hibernate mode off and remove sleepimage file. That’s it. Because I don’t care whether the work-in-progress files are recovered when the battery goes down. I believe that I am going to just power on or reboot!

I am Happy to get an additional 4.0 GB!

$ sudo pmset -a hibernatemode 0
$ sudo rm /var/vm/sleepimage

As a reference)

ネットブックでHackintosh – Hibernateは動作するか?
OSX: Changing Hibernation Mode – UPDATED



Amazon Web Services and Eucalyptus to better interoperability

Amazon Web Services (AWS) and Eucalyptus Partner to Bring Additional Compatibility Between AWS and On-premises IT Environments (Nes & Events – Eucalyptus.com)

This announcement caught my attention. Soon after I read this, I came up with an idea that this could be a next standard infrastructure in future. I have been thinking that enterprise organizations need a standardized virtualization solution which enables them to make their systems portable. I felt like the same thing between Microsoft vs. Linux and VMware vs. Eucalyptus for future.


Can javascript run in a post on wordpress.com?

I wanted to run a javascript script in a post on wordpress.com, but it seems to be not allowed.

WordPress.com Support – Writing & Editing Code


Users are not allowed to post JavaScript on WordPress.com blogs. JavaScript can be used for malicious purposes. As an example, JavaScript has taken sites such as MySpace.com and LiveJournal offline in the past. The security of all WordPress.com blogs is a top priority for us, and until we can guarantee scripting languages will not be harmful, they will not be permitted.

JavaScript from trusted partners, such as YouTube and Google Video, is converted into a WordPress shortcode when a post is saved.

OK. I am going to seek another way for that.

how to convert line endings in text file

We often encounter the difference of the line endings among several operating systems. I guess that this is not a common tool all over the world. Using nkf command, you can easily convert line endings like the below:

  • -Lu :change to LF
  • -Lw:change to CRLF
  • -Lm:change to CR

i.e) To convert to unix-style from windows-style, run like the below.

$ nkf - Lu crlf-file.csv  > unix-lf-file.csv

Health check for Linux

As a first entry to this blog, I post how to check Linux status.


To check CPU usage, top and w commands would be useful. The below shows 99.2% as idle time, which means no problem. In general, it is good if the load average is less than 1 and it is high load if between 2 and 3. Should it be more than that, CPU might be able to be bottleneck.

# top
top - 16:14:18 up 3 days, 10:04,  1 user,  load average: 0.20, 0.66, 0.34
Tasks: 102 total,   1 running, 101 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.1%us,  0.3%sy,  0.0%ni, 99.2%id,  0.3%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    380192k total,   373544k used,     6648k free,    60604k buffers
Swap:  1048568k total,        0k used,  1048568k free,   129924k cached

# w
 16:17:33 up 3 days, 10:07,  1 user,  load average: 0.00, 0.34, 0.26
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    16:14    0.00s  0.01s  0.00s w


At first, hit top command which shows memory information. 373MB is using in total 380MB on the below, but Linux seems to move an extra part of the memory into Cache. to check it, use free command.

The below sample shows 183MB is available.

# free
             total       used       free     shared    buffers     cached
Mem:        380192     374288       5904          0      61088     129940
-/+ buffers/cache:     183260     196932
Swap:      1048568          0    1048568

Disk usage

To check if disk usage is fine, use vmstat. The below sample means it checks 5 times a second. Note the value of bi and bo.

# vmstat 1 5
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0   5780  61208 129944    0    0    10     7  611   95  0  0 99  0  0
 0  0      0   5780  61208 129968    0    0     0     0  613   99  0  0 100  0  0
 0  0      0   5780  61208 129968    0    0     0     0  597   76  0  0 100  0  0
 0  0      0   5780  61208 129968    0    0     0     0  606   93  0  0 100  0  0
 0  0      0   5780  61208 129968    0    0     0     0  584   83  0  0 100  0  0


To check network usage, count number of connections with netstat. Less than a hundred thousand connections would be fine, or regard it as fine. If it is more than that, increasing servers needs to be considered.

# netstat -an|wc -l

Please note that this is just an easy way of health check for OS. Those for an application should be needed. But this should come in handy.