Simple clear advice in plain English

Unix - Tar for the memory

Having explored the simple use of tar, the tape archiver, Chris Bidmead shifts up a gear to show you how to access individual files on a multi-archive tape and craftily labels a tarball.

Last month we explored the simple use of tar with a local device,idmead shifts up a gear to show you how to access individual files on a multi-archive tape and craftily labels a tarball. like this:

tar cvf /dev/st0

which backs up to the local tape device /dev/st0.

If you address the tape as /dev/st0 it rewinds to position 0 every time you try to talk to it. I found that addressing the tape instead as

/dev/nst0

(the "n" standing for "non-rewinding") didn't disturb the current tape position.

When you write an archive to /dev/nst0 a filemark gets written at the end of the file and the tape stays in that position. If you immediately write another archive it won't overwrite the first and you'll end up with two separate archives on the tape.

Repeat this exercise n times (and with a 24Gb device like the HP24DAT, n can be very large!) and you have a multi-archive tape.

So how do you get to individual archives on such a tape? One way would be to read out each archive in turn until you get to the one you need.

You don't actually need to restore each archive; it's enough just to list them, thus:

tar tf /dev/nst0

So, to get to the fifth archive on the tape for example, I simply run the above command line four times, remembering to use /dev/st0 for the first command to ensure I start at the beginning of the tape.

There must be a better way of doing this. And, of course, there is. But not within tar. To position and generally manipulate the tape you run a special utility called mt. With mt you can forget about /dev/st0 altogether.

Any time you need to rewind the tape you simply give the command:

mt /dev/nst0 rewind

In fact, while we're about it, let's dispense with the need to mention the tape device by name each time. Now that we're just dealing with a single device we can set a shell variable:

TAPE=/dev/nst0 ; export TAPE

to tell both tar and mt to use this as the default device. Mt can move your tape directly to any particular point on the tape. For example:

mt /dev/nst0 seek 2210

will move the tape directly to block 2210. (One complication is that blocks can be different sizes, so for now I'm just sticking to the default size and ignoring this point. And things work fine.)

Now you can use mt tell to report the current position (in terms of the number of blocks from the start of the tape).

Similarly, mt eod will move to the "end of data" which is the place to write the next archive without overwriting the existing tape contents.

Labelling archives with GNU tar

Here's a simple manual system I devised for handling multiple tape archives.

It uses a feature of GNU tar we haven't mentioned yet - the ability to attach meaningful labels to archives. So, for example:

tar cvV "Total Backup" /

will backup all your files below the root and label the archive "Total Backup". V stands for volume, the old parlance for a tar archive, which you'll also find is sometimes called a "tarball".

- Here's a little tip: It took me ages to realise that there's no point labelling a backup "Backup" - of course it's a backup. You can put the label space to better use by inserting the current date using command substitution:

tar cvV "'date' Total" /

Now, we know how to position tape and to write and read archives. What I like about this is that we're working at the command line, taking control at a low level which lets us understand exactly what's going on. I also relish the fact that everything we are learning at this level is platform, hardware and manufacturer independent.

Next month we'll move up to the next level and assemble what we've learned into a simple shell script.

ISDN routers and IP-Masquerading

Your email to me shows much more interest than I'd dared hope in my rather flash ZyXEL ISDN router (PCW, February) and the fast internet connection it provides, pretty well automatically, to all the machines on my network.

I've dared suggest that a dedicated router like this, with a basic street price of what one used to pay for a decent modem a year or so ago, renders obsolete the complexities of a dedicated Linux machine with IP-Masquerading.

Reader, Richard Oxborrow is among those arguing that I'm being too simplistic about this. He's taken the trouble to put up a helpful web page on setting up a Linux machine as an ISDN router, at www.micrologic-ltd.co.uk/linux. Thanks, Richard.

Book review - UNIX Unleashed: Internet Edition

I suppose the publisher didn't want to call it UNIX Unleashed, Volume 2 because that would have made it a hard sell to someone who hasn't already got volume one. This is a pricey product, even for a hardback of over 1,000 pages. But then again, if its content saves you half a day or whatever sorting out some problem, the book would easily pay for itself.

I wasn't quite clear about this volume 1/volume 2 business when I first got the book - the misleading title seems to suggest that it's a second, updated edition - and I wondered why so much of the basics of UNIX were missing. The answer is that they're in volume 1, the proper title of which is UNIX Unleashed: System Administrator's Edition. In fact they're not missing because the whole of the original book is supplied on CD, together with a complete electronic version of this latest edition.

These HTML pages are probably the most useful thing about the publication.

The contents of both books ranges across a number of different Unices, including AIX, HP-UX, Silicon Graphics' IRIX and Linux. Unfortunately this makes the coverage rather shallow, despite both books being rated intermediate/advanced by the publisher, Sams.

There are also some strange omissions. For example, given the title of the second book I would have expected to have found at least a mention of, and perhaps even a chapter about, Apache, the most widely used (and incidentally, free) web server. The word "Apache" doesn't even appear in the index - although oddly enough, the software is included on the CD.

As well as the text, the CD also contains complete installable versions of Linux and FreeBSD, together with a number of freeware and shareware utilities. This is very handy if you don't have a net connection, although the software provided on the CD tends to be one or two versions behind what you'd get if you fished for it yourself. The Linux, for example, is RedHat 4.2 and at the time I'm writing this you can either download RedHat 5.0 from www.redhat.com or (recommended) send off a couple of quid to The Linux Emporium and get the CD by snail mail.

This does rather raise the question of what, exactly, imposing tomes like this are for in these days of internet access. For example, on page 975, the book goes out of its way to tell me that the current version of Netscape is 3.01. At the time I'm writing this, Netscape happens to be up to version 4.x but things move so fast these days I wouldn't even dare make an assertion about "the current version" of anything even in this magazine, let alone in a hardcover book with a shelf life of at least a year. Details like this really only belong on a frequently updated web page.

Price #54.95

Contact Computer Manuals 0121 706 6000 www.compman.co.uk

A number of readers, including Glen Grey , David Coulson and Geoff Roughton , have been urging me to cover their favourite X Window Manager, Enlightenment.

If you are artistically inclined, it opens up all kinds of possibilities, as you can see from this pyrotechnic desktop borrowed from Enlightenment guru Carsten Haitzler's web page at www.rasterman.com

Questions & Answers

This month I have received a whole list of questions from reader, Geoff Wexler g.wexler@open.ac.uk

Q: I'm getting much correspondence about the superior reliability of Linux/UNIX over any version of Windows. Do you agree?

A: No question, Geoff. I wouldn't bother doing this column if I thought otherwise. Actually, it's not just reliability that's the issue. UNIX has an entirely different philosophical approach to the question of what an operating system is for, but that's a longer story.

Q: I might be buying a new computer soon and am tempted to start by partitioning part of the hard disk and reserving a part of it for UNIX. Do you think that would be sensible? If so, could advise me how to find out more?

A: In answer to the first part of your question, yes, and it's very easy to do these days, now that 2Gb drives seem to be the entry level. (My first hard drive was 3Mb - yes, that's megabytes!) Windows 95 is still going to leave you plenty of room for an extra, say, 800Mb, which is fine for a full Linux installation.

Visit www.linux.org and follow the documentation link there (it's embedded in text) to the HOWTOs. There are several mini-HOWTOs on running dual- and multi-boot Linux systems. At www.linux.org/help/projectguide you'll find several online books including "Installation and Getting Started Guide" (recommended). Also visit www.ora.com and find out how to get hold of the hard copy of "Running Linux".

You also ask me "Is it a steep learning curve?" I never know what this expression means. Literally, a steep learning curve would mean that you learn quickly, assuming the usual (horizontal) position of the time axis!

To be frank, you probably won't have the impression of learning quickly with UNIX. It's nearly a 30-year-old operating system and a lot of wisdom has accumulated around it and within it.

Documentation is freely available by the ton, but it's sometimes contradictory and some of it is out of date. Windows gets you started more quickly and manages to give you the impression of learning fast, but in my opinion the knowledge you acquire is shallow and doesn't help you out of a fix when things go wrong. Acquiring UNIX knowledge tends to be a slower burn, but things fit together better and you get more insight into what goes on below the water line. Eventually, this all adds up to a sense of understanding and control that you'll never achieve with Windows.

Q: Can you type Greek letters and maths symbols in UNIX?

A: Yes. UNIX has been used by scientists and academics pretty much since its inception. It's the home of TeX, a pioneering computer text compositing system (see, for example, sunsite.doc.ic.ac.uk/packages/TeX) and there are many other approaches to the same task available under UNIX.

Email Chris Bidmead at unix@pcw.co.uk.

Reader Comments

   

Add your comment

All fields must be completed. Your email address will not be displayed or used to send marketing messages.

All messages will be checked by moderators before appearing on the site.

See our Privacy Policy for more information.

Related articles

Unix: Compiling that code

Turning source code into binaries is a simple matter of DIY, as Chris Bidmead of Personal Computer World explains.

Hands On - Unix - Do the right thing

It's not fun, it's far from exciting, but it's absolutely crucial that you do it: backup, that is. You've got to get it right first time, advises Chris Bidmead, as he offers a helping hand....

Hands On - Unix - Fast track

Chris Bidmead plucks a FreeBSD installation out of thin air - actually, from the internet, and it's so easy. But it would not have been possible without his new, fast Zyxel ISDN router....

Question & Answer

Q.Why are some of the keys on my keyboard doing strange...

> Read the answer

Q.Is my phone’s Bluetooth any use?

> Read the answer

Q.Can I switch boot drives so that I can work on older...

> Read the answer

Best deals on the web

img

Samsung RV520-A07

£359.98- Buy it now

img

Acer Aspire 5750G (LX.RXP02.019)

£399.99- Buy it now

img

Apple MacBook Pro (MD313B/A)

£904.37- Buy it now

Latest issue & subscription deals

Poll

Are you concerned about viruses that target mobile phones?

Jargon Buster

Computing terms explained in plain English

Restore point

A Windows backup of system files and settings.

Great shopping deals from Computeractive