How to Find the Time Between two Unix Time Stamps

This article explains how to find the time interval between two Unix time stamps. The default time format in Unix is like this: “Sun 9 Aug 12:50:08 BST 2020”. It appears in many places on the system and is the default produced by the “date” command.

For example, it might appear in application log files, like this::

Start time: Sun 9 Aug 10:05:00 BST 2020
End Time:   Sun 9 Aug 12:51:12 BST 2020

This article explains how to subtract one time from the other in Bash, and obtain the intervening time in seconds.

Continue reading

Recovering Data from a Corrupted SD Card

SD cards are used in digital cameras, phones and other devices, where their speed and large capacity makes them useful for storing pictures, video and other voluminous multi-media items. It is quite common these days for a mobile device to contain a 16 Gb or 32 Gb SD card.

With the devices being so mobile, backups are easily overlooked. And it is quite easy for an SD card to become corrupted, for example if the card is removed while the device is on, or the battery is taken out while a video is being shot.

I was given a corrupted 16 Gb card and asked to recover the files, if possible. The rest of this post explains how the data was safely restored using simple Linux tools. Continue reading

Format and Relabel a Flash Drive in Linux

Flash drives (as in memory sticks) are a popular choice for backups. A 64 Gb drive can be bought for just over £20 at the time of writing. Once your data is backed up to the drive, it is easy to store in a safe place or transport off site for added protection. Actually that applies to any portable hard drive, as does the following procedure.

Most flash drives come formatted as FAT32. That is fine from day-to-day but there is a strict 4 GB limit applying to the size of any file. Backup software is likely to produce large archive files well over 4 GB, so won’t work well with FAT32. What’s needed therefore, is a better file system. Continue reading

Solaris Disk EFI Headers

“format” is the Solaris tool used to initialize disks. Format can sometimes have a problem with disks that bear an EFI disk label. In which case, replacing the EFI label with a more traditional VTOC disk label can help.

The problem appears when an attempt is made to label the disk using format. The label operation fails with “Current disk is unformatted”. Many other format options fail with the same message. Newfs will not recognise the disk and it is therefore impossible to create a file system. Continue reading