February 24, 2013

How to find the count of physical processors, cores and threads on Solaris?

Let’s first understand the terms and relationship between the same quickly.

Physical processor – processor that is actually / physically present
Core – further division of physical processor i.e. a physical processor can contain multiple cores
Thread – a distinct execution path provided by a core i.e. a core can support multiple threads
Virtual processor – can be considered equivalent to a thread

That means, Number of virtual processors in a physical processor = count (cores) * count(threads).

psrinfo -p gives the number of physical processors

psrinfo -pv gives the number of virtual processors per each physical processor

But, how does one find the number of cores / threads on a physical processor? The only way that this could be found out is by going to the specs page on Sun/Oracle website. However, recent updates of Solaris 10 did include a fix to report this kind of detail. In case the fix is not there, it can still be found out from the command “kstat cpu_info”. For more details, you may refer to http://blogs.oracle.com/sistare/entry/cpu_to_core_mapping.

February 16, 2013

Unix: Why do “df” and “du” report different disk usages?

Let's understand the fundamental difference between the two commands first.

  • "df" reports usage based on details available at filesystem-level (inodes)
  • "du" reports usage based on the actual contents (files) of a directory

There are many reasons for the discrepancy between the numbers reported by the two commands. However, it is _mostly_ because of removal of a large file, the file handle of which is still present with a process (the file was opened by the process). When a file is removed, "du" no longer takes it into consideration although "df" counts it as the file inode is still present because of the open file handle - which is why "du" reports free usage where as "df" does not.

How do you fix the discrepancy in such cases? Simplest is by not removing the files that are held open by some process. However, if you do run into a situation of accidentally removing such files, restart the application/process that held the open file descriptor - this is the proper way to clean up. There is also a workaround of clearing the file descriptor manually/directly although it is not recommended procedure.

Another reason for the mismatch is that "df" counts the complete blocks (8 KB blocks, for example, as seen in the above techbit) where as "du" counts the actual file sizes (like 1 KB if the file is actually only 1 KB). If there is a large number of such small files, then the difference can show up significantly.

There are many other possible reasons as well for the mismatch. Provided below are few links for further reading:

http://linuxshellaccount.blogspot.com/2008/12/why-du-and-df-display-different-values.html
http://blog.thilelli.net/post/2008/10/18/Discrepancies-Between-df-And-du-Outputs
http://sysunconfig.net/aixtips/df_du_diff_out.txt

February 9, 2013

HJSplit: Split & Join Files

Have you ever wished you had the ability split a huge file into smaller files and then merge the smaller files back to recreate the original file?

Maybe, when you wanted to transfer the file from a computer to another using a USB drive but the USB cannot hold the whole file due to insufficient capacity? Or how about when you want to send a file over email but cannot either because the mail server does not allow attachments beyond a specific size? Or may be, the mail server allows but you want to avoid any issues with intermittent network connectivity breaks / issues by sending over the file in several different chunks?

If you answered a "Yes" to any of the above questions or if it simply sounds interesting/useful to you, then you should try HJSplit. It is a free file splitter and merger. It is obtainable from http://www.hjsplit.org/.

By the way, do let me know if you have any comments. If you find the posts helpful or if you think someone else can benefit from them, feel free to share the same.

February 3, 2013

TrueCrypt: Disk Encryption Software

Here is an excellent open-source disk encryption software: TrueCrypt @ http://www.truecrypt.org/.

TrueCrypt can be used to realize wonderful use-cases from a security standpoint.

For example, what if you wanted a document like text file or an excel or a word document or a PDF on your computer that ONLY you should be able to access? TrueCrypt can do it for you.

As another example, you've a USB stick that is currently unprotected i.e. if you lose your USB stick, then whoever finds it has access to all of your data! TrueCrypt can create an entire encrypted partition on the storage device to meet this need.