Files and Filesystems: How to Mount ISO Images

Most modern Linux kernels support the loop mount option. One of the nifty things about the loop filesystem option is that it allows you to mount an ISO image directly into the filesystem without having to burn the image onto a CD first. You could simply run the command

to mount foo.iso on the /mnt mountpoint. The type should be auto-detected (iso9660). If things don’t auto-detect, explicitly state them by running a command something along the lines of:

How to Update Volume Configuration within Netbackup

This is for an old version (4.5) of Veritas NetBackup.


Obviously, your robot type (-rt) may be different. Here, we see that the volume configuration is already up to date, thus no changes are made.

Launching Simultaneous Processes and Monitoring Exit Statuses

Let’s say you have three scripts. You want to execute them simultaneously (or as close to simultaneous as is practicable). You then want to examine all of their exit statuses, and maybe perform some actions accordingly.

The easiest way is using a script such as the following, capturing the PID of each process as it is launched, and then using wait to wait for the specified process to return its termination status. For example:

Terminals: How to Sanitise Your Haywire Terminal

We’ve all done it - issuing a nonsense command such as cat /bin/ln can really screw up your terminal! In order to sanitise your terminal, you can try three things. First of all, try the reset command. If that doesn’t work (or isn’t supported), try stty sane. That should be supported, but doesn’t always work. I find the command that gets me out of trouble is

The ^O is produced by typing CTRL-V CTRL-O. This should return your terminal to a sensible state.

How to Set up a BIND DLZ Nameserver with MySQL Replication

Disclaimer: This post was originally posted in 2008 as an article on the now-defunct website zazzybob.com. While the software version and actual commands used may vary, the concepts are still similar and give a general idea of how to approach a given problem.

This article sets out to describe the process used to set up a BIND nameserver with Dynamically Loadable Zones (DLZ) running with a MySQL backend (with replication).

DLZ allows us to maintain a dynamic database of zone information, located either locally or across the network (and with replication, highly-available). Thus we eliminate the need for zone transfers. Further information on BIND DLZ can be found at the BIND DLZ SourceForge site.

Continue reading

Code Snippets: Link Checking with curl

Even though there are many link checking utilities and scripts available, a simple concise report can be generated using curl.

Create a script, link_checker.sh, and paste the following code:

Now, place your links, one per line, in the file links, e.g.

Then, make the script executable and run it. Links will be checked, and the HTTP status code of each one returned.

Text Manipulation: Multiple Line Regex Deletions Using Perl

Removing portions of files that match a multiple line regular expression can be tricky, unless you’re using perl. Let’s take an example file:

We would like to remove all headers that are not followed by any data. Not much of an example but it’ll demonstrate the technique nethertheless! The easiest way to do this with perl is to read the entire file into a single scalar variable, and then just parse that substituting our multiple line regular expression with nothing. Observe:

Obviously you’ll need to redirect the output of this file, or just write $data out to a new file within the perl script itself.

Running the script on the example data gives the expected output:

Using this method, you can easily modify the regular expression in the perl script to suit your needs.

Files and Filesystems: Determining the End of Line Character for a File

You would like to find out which end of line characters are used in a file. Run a command similar to the following:

For a DOS file, you get:

For a UNIX file, you get:

Where cr is a carriage return (\r), and nl is a newline (\n).

Alternatively,

gives the slightly more logical output of

for a DOS file, or

for a UNIX file.

Mac files terminate with \r only.

Text Manipulation: How to Delete the First Line of Text in a Large File

Editing a very large file can be a resource- (and time-) consuming nightmare. Having a requirement to delete the first line in such a file in-place whilst avoiding opening the file up in SomeEditor(TM) can be done in various ways, with various resource overheads.

Let me introduce you to the three methods we’ll be trying. The first uses GNU sed and the -i (inplace) option to edit the file in-place.

The second methods uses perl to get the job done.

The final example uses printf (so use a shell that supports it) and ex (command-line vi).

Let’s use these methods and time them…

So the moral of this tip? Use perl for performing edits on extremely large files!

How to Get Started with Solaris Containers

Disclaimer: This post was originally posted in 2008 as an article on the now-defunct website zazzybob.com. While the software version and actual commands used may vary, the concepts are still similar and give a general idea of how to approach a given problem.

Solaris Containers, available starting with Solaris 10, allow us to portion a physical server into one or more logical units. Whilst Containers are a form of virtualisation, they are not in the traditional sense (multiple OS instances with VMware, or hardware partitioning with LDoms).

The container can be thought of more like a “chroot” environment (in the case of sparse zones) where system resources are also in effect “chrooted” so that processes cannot run away and consume all of the resources of physical parent (the global zone), thus rendering the system inoperable. Only a single instance of Solaris 10 is ever installed (in the global zone) making package and patch management simple. Just apply the patch to the global zone, and all child zones will use the same binary set.

Some, or all, of the parent’s filesystems can be mounted read-write or read-only within the zone. Special care must be taken when mounting a global zone filesystem read-write, as the child zone may be able to cause a denial of service to the global zone by filling a disk.

Up until recently, Solaris Containers could only inherit the global (i.e. physical parent) zones TCP/IP stack. Now, we can assign exclusive phyical interfaces to the Container, but in this article I’ll be creating a dynamic link aggregation of three NICs in the global zone, and then allowing the zones to create virtual interfaces on this aggregation.

There are many more features of Solaris Containers I’ve not had time to mention - Sun do a perfectly good job of this over at docs.sun.com - as can other elimentary topics that have not been covered in this discussion.

Continue reading