Using Removable Media in Linux, or How to Back Up Your Linux Account

by Joe "VI" Erker


Table of Contents


Introduction

Whether you have a Linux account in the department or you run Linux at home, it is a good idea to back up your files regularly. The issue of backing up aside, some people like to do their computing at home in addition to the lab or office. Or sometimes it is necessary to travel with one's data for a conference or other work-related trip. Whatever the case, one should know how to read from and write to removable media – ZIP disks, CD's, and diskettes – in the Linux system.

Here, we go into ways to transfer data between the hard drive and removable media via drag and drop, other GUI's, and old-fashioned commands.


Using Zip Disks and Diskettes

Use of removable disks has become remarkably easy in Linux. It has even gotten to the point where there is a graphical user interface (GUI) for the file systems, and one can "drag and drop" files between the hard drive and removable disk, like in the Windows or Mac environment.

In the recent versions of Red Hat Linux (7.3 and above), it is very easy to mount a disk for reading and writing. Here's how:

  1. Insert the disk.
  2. Right click the mouse in the desktop background. Choose "Disks" in the pop-up menu, then "floppy" or "zip" (or, for reading a CD, "cdrom"), depending on the disk you inserted.
  3. After a few seconds, an icon will pop up in the desktop. To see the contents of the disk, double-click the icon.
  4. If you want to transfer files between the removable disk and hard drive, click on the "Home" icon on the desktop. Now you'll have a window for your removable disk and hard drive, and files can traverse directories and "drag and drop" files just as in a Mac or Windows environment.
  5. When finished with the disk, unmount by repeating step 2, this time "unchecking" the "floppy" or "zip" menu option.

Reading removable disks with commands:

  1. Insert the disk.
  2. Enter mount /mnt/floppy at the command prompt for a diskette or mount /mnt/zip for a ZIP disk. ( Note: on older versions of Red Hat, mount /mnt/zip100.0 for ZIP disks.)
  3. With the filesystem mounted in your linux session, you can now move files back and forth as you normally would in Linux, with the mv and cp commands. The files on the removable disk are "in" the /mnt/floppy/ directory for a diskette, /mnt/zip for a ZIP disk, and /mnt/cdrom for a readable CD.
  4. Unmount the disk with the command umount /mnt/floppy or umount /mnt/zip .
Note on mounting: Linux is very particular about mounting and unmounting the disk properly. Unmounting will not work if there is a window open that displays the contents of the disk, or if the mounted file system is the "current directory"

Note on CD's: To read data from a CD-ROM, mimic the commands above, substituting the word "CDROM" where "zip" or "floppy" appears. For writing to CD's, see the instructions below.


Notes on Various Types of Disks and Disk Drives


Writing Data to CD's

The most recent version of Red Hat Linux, 9.0 comes with a program called xcdroast , which has been found very buggy. This is unfortunate, since it provides a graphical user interface that is supposed to make the process of writing data to a CD, or "burning" very easy in Linux. Fortunately, burning via Linux commands is fairly simple. As an example, we now see how to back up your account onto a CD.
  1. Make sure the computer you are using has a CD-writable or rewritable drive.
  2. Insert a writable CD into the drive. If you are unsure as to whether the CD is blink or already has data on it, try to mount it (see instructions elsewhere in this document). If it can't be mounted, the CD is likely blink, and ready for use.
  3. Suppose the files in your account are in the directory /home/username/ . Enter the command mkisofs -o /var/tmp/<name>.cd -R /home/username The command mkisofs converts all your files into one 'iso' file. The -R flag ensures that all file names stay intact. The file name name is of your choice. The directory /var/tmp/ is where the iso file is placed temporarily, and from where the data is read by the CD drive. (The extension of .cd is not necessary; it is just a reminder to ourselves that it is a file that is to be burned onto a CD.)
  4. Enter cdrecord -v dev=0,0,0 speed=## -data /var/tmp/<name>.cd The number for the speed argument should be the writing speed on the CD drive. On most CD drives, this is indicated on the front of the drive. In this case, there are three numbers. The highest is the reading speed, the smallest is the rewriting speed, and the middle is the writing speed. That number takes the place of ## in the above command. On the computers in the grad labs, the writing speed is 40. The -v flag is optional. It stands for "verbose", which means you will be shown on the screen what is happening during the burning process.
  5. At this point, you have your backed up data. Finally, you should clean up by deleting the iso file:
    rm /var/tmp/<name>.cd
You don't have to back up your entire account. Suppose for example that you are a graduate student who wishes to back up only the files that make up your thesis. Suppose that these files are all in the directory /home/username/thesis. Then, to back up your thesis:
  1. Enter a blink writable CD into the CD drive.
  2. Enter mkisofs -o /var/tmp/thesis.cd -R /home/username/thesis/
  3. Enter cdrecord -v dev=0,0,0 speed=## -data /var/tmp/thesis.cd (Remember to be aware of the writing speed of the CD drive, and fill in that number appropriately.)
  4. rm /var/tmp/thesis.cd
In this case, it is not necessary, to use the name thesis.cd. You can use whatever name you want. All subdirectories of the thesis directory will be included in the backup. Also, one can back up two directories at the same time. Suppose in addition to the thesis directory, one has a directory called "research". Then in item 2 in the above example, one can type

mkisofs -o /var/tmp/backup.cd -R /home/username/thesis/ /home/username/research/


Reading CD's

Reading data from CD's, and thereby enabling one to copy files from a CD to a hard drive is very easy. The procedure for doing so is completely analogous to that for diskettes and ZIP disks (see above), whether using commands or graphical 'drag and drop' for transferring files between the CD and hard drive. When a CD is mounted, the files are accessed in the /mnt/cdrom directory.

A Note on Tapes and Tape Drives

The departmental file servers are backed up regularly with tapes. Tapes are useful in that they can hold large amounts of information. However, for individual users, backing up with tapes is not recommended, for several reasons. First of all, using other media is much simpler. Secondly, for most people the amount of data that needs to be backed up can fit on a CD (650 Megabytes). Thirdly, CD and ZIP disks and drives drives are much cheaper than tapes and their drives. For the small number of those who have gigabytes of data that needs to be backed up, it is recommended to have a second hard drive that acts as a "mirror" to the one that is used. One can back up an entire hard drive to another hard drive in much less time than to a tape. Ideally, the security-minded user would have a second hard drive for day to day backups and a CD drive for less frequent permanent backups of the most important data, which of course can be taken away from the office for extra security.

Currently in the department, we are gradually switching from tapes to CD's as the primary source of backing up for the computers of individual faculty members. Graduate students are encouraged to occasionally back up their data using the ZIP and CD-writable drives, which are available in the graduate student computer labs.

http://math.arizona.edu/~swig/documentation/disks/index.php
Last modified: Fri, 14 Dec 2007 15:50:51 -0700
E-mail: swig@math.arizona.edu
Valid XHTML 1.0! Valid CSS!