In Chapter 11 we looked at hard disks. In this chapter, we'll consider how to guard against data loss, and how to transfer data from one location to another. These are functions that UNIX traditionally performs with tapes, and we'll look at them in the next sections. Because FreeBSD runs on PCs, however, you can't completely escape
No matter how reliable your system, you are never completely protected against loss of data. The most common reasons are
UNIX talks about archives, which are copies of disk data in a form
Traditionally, PCs use
By contrast, a single
A number of cheaper
You can also use writeable "CD-ROMs" (CD-Rs) for backup purposes. By modern standards, the media are small (up to 700 MB), but they have the advantage of being readily accessible on other systems. We looked at CD-Rs in Chapter 13.
FreeBSD tape devices have names like /dev/nsa0 (see page 196). Each letter has a significance:
n means non-rewinding . When the process that accesses the tape closes it, the tape remains at the same position. This is inconvenient if you want to remove the tape (before which you should r stands for raw, in other words a sa stands for serial access, and is always SCSI. You can also get 0 is the unit number. If you have more than one tape, the next will be called /dev/nsa1, and so on.
FreeBSD does not require special "
tar, the tape archiver, performs the following functions:
tar does not compress the data. The resulting archive is slightly larger than the sum of the files that it contains, since it also contains a certain amount of header information. You can, however, use the gzip program to compress a tar archive, and tar invokes it for you automatically with the -z option. The size of the resultant archives depends strongly on the data you put in them. JPEG images, for example, hardly compress at all, while text compresses quite well and can be as much as 90% smaller than the original file.
Create an archive with the c option. Unlike most UNIX programs, tar does not require a
# tar cvf source-archive.tar /usr/src/sys tar: Removing leading / from absolute path names in the archive. usr/src/sys/ usr/src/sys/CVS/ usr/src/sys/CVS/Root usr/src/sys/CVS/Repository usr/src/sys/CVS/Entries usr/src/sys/compile/ usr/src/sys/compile/CVS/ (etc)
The parameters have the following meaning:
cvf are the options. c stands for create an archive, v specifies verbose operation (in this case, this causes tar to produce the list of files being archived), and f specifies that the next parameter is the name of the source-archive.tar is the name of the archive. In this case, it's a disk file./usr/src/sys is the name of the directory to archive. tar archives all files in the directory, including most devices. For historical reasons, tar can't back up devices with minor numbers greater than 65536, and changing the format would make it The message on the first line (Removing leading / ...) indicates that, although the directory name was specified as /usr/src/sys, tar treats it as usr/src/sys.. This makes it possible to restore the files into another directory at a later time.
You can back up to tape in exactly the same way:
# tar cvf /dev/nsa0 /usr/src/sys
There is a simpler way, how ever: if you don't specify a file name, tar looks for the environment variable TAPE. If it finds it, it interprets it as the name of the
TAPE=/dev/nsa0 export TAPE for sh and bash setenv TAPE /dev/nsa0 for csh and tcsh
After this, the previous example simplifies to:
# tar cv /usr/src/sys
To list an archive, use the option t:
# tar t from tape usr/src/sys/ usr/src/sys/CVS/ usr/src/sys/CVS/Root usr/src/sys/CVS/Repository usr/src/sys/CVS/Entries usr/src/sys/compile/ usr/src/sys/compile/CVS/ usr/src/sys/compile/CVS/Root (etc) # tar tvf source-archive.tar from disk drwxrwxrwx root/bin 0 Oct 25 15:07 1997 usr/src/sys/ drwxrwxrwx root/bin 0 Oct 25 15:08 1997 usr/src/sys/CVS/ -rw-rw-rw- root/wheel 9 Sep 30 23:13 1996 usr/src/sys/CVS/Root -rw-rw-rw- root/wheel 17 Sep 30 23:13 1996 usr/src/sys/CVS/Repository -rw-rw-rw- root/bin 346 Oct 25 15:08 1997 usr/src/sys/CVS/Entries drwxrwxrwx roo t/bin 0 Oct 27 17:11 1997 usr/src/sys/compile/ drwxrwxrwx root/bin 0 Jul 30 10:52 1997 usr/src/sys/compile/CVS/ (etc)
This example shows the use of the v (verbose) option with t. If you don't use it, tar displays only the names of the files (first example, from tape). If you do use it, tar also displays the permissions, ownerships, sizes and last modification date in a form reminiscent of ls -l (second example, which is from the disk file source-archive.tar).
To extract a file from the archive, use the x option:
#tar xv usr/src/sys/Makefile from tape usr/src/sys/Makefile confirms that the file was extracted
As with the c option, if you don't use the v option, tar does not list any file names. If you omit the names of the files to extract, tar extracts the complete archive.
You can combine gzip with tar by specifying the z option. For example, to create the archive source-archive.tar.gz in compressed format, write:
# tar czf source-archive.tar.gz /usr/src/sys
You must specify the z option when listing or extracting compressed archives, and you must not do so when listing or extracting non-compressed archives. Otherwise you get messages like:
# tar tzvf source-archive.tar gzip: stdin: not in gzip format tar: child returned status 1 # tar tvf source-archive.tar.gz tar: only read 2302 bytes from archive source-archive.tar.gz
I don't like floppy disks. UNIX doesn't like floppy disks. Probably you don't like floppy disks either, but we
FreeBSD uses
So why use floppies? The only good reasons are:
In the following sections, we'll look at how to handle floppies under FreeBSD, with particular regard to
Even if you buy preformatted floppies, it's a good idea to
On Microsoft platforms, you format floppies with the FORMAT program, which performs two different functions when invoked on floppies: it performs both a low-level format, which rewrites the physical sector information, and then it performs what it calls a high-level format, which writes the information necessary for Microsoft platforms to use it as a file system. UNIX calls the second operation creating a file system. It's not always necessary to have a file system on the
To format a
$ fdformat /dev/fd0 Format 1440K floppy '/dev/fdC? (y/n): y Processing --------------------------------
Each
Processing VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV done.
It's possible to use floppies as file systems under FreeBSD. You can create a UFS file system on a floppy just like on a hard disk. This is not necessarily a good idea: the UFS file system is designed for performance, not maximum capacity. By default, it doesn't use the last 8% of disk space, and it includes a lot of structure information that further reduces the space available on the disk. Here's an example of creating a file system, mounting it on the directory /A , and listing the remaining space available on an empty 3,5" floppy. Since release 5, FreeBSD no longer requires a
# newfs -O1 /dev/fd0 create a new file system
/dev/fd0: 1.4MB (2880 sectors) block size 16384, fragment size 2048
using 2 cylinder groups of 1.00MB, 64 blks, 128 inodes.
super-block backups (for fsck -b #) at:
32, 2080
# mount /dev/fd0 /A mount the floppy on /A
# df -k /A display the space available
Filesystem 1024-blocks Used Avail Capacity Mounted on
/dev/fd0 1326 2 1218 0% /A
Let's look at this in a little more detail:
/A.-k option to display it in -k option. See page 128 for more details of environment variables.The output of df looks terrible! Our fbppy only has 1218 kB left for normal
# umount /A first unmount the floppy # tunefs -m 0 /dev/fd0 and changethe minimum free to 0 tunefs: minimum percentage of free space changes from 8% to 0% tunefs: should optimize for space with minfree < 8% # tunefs -o space /dev/fd0 changethe optimization tunefs: optimization preference changes from time to space # mount /dev/fd0 /A mount the file system again # df /A and takeanother look Filesystem 1024-blocks Used Avail Capacity Mounted on /dev/fd0 1326 2 1324 0% /A
Still, this is a far cry from the claimed
To create a Microsoft FAT12,
$ newfs_msdos -f 1440 /dev/fd0
The specification -f 1440 tells newfs_msdos that this is a 1.4 MB floppy. Alternatively, you can use the mformat command:
$ mformat A:
You can specify the number of tracks with the -t option, and the number of sectors with the -s option. To explicitly specify a fbppy with 80 tracks and 18 sectors (a standard 3,5" 1.44 MB floppy), you could enter:
$ mformat -t 80 -s 18 A:
mformat is one of the mtools that we look at in the next section.
Well, you could take the disks out of the cover and use them as a kind of frisbee. But there is one other useful thing you can do with floppies: as an archive medium, they don't need a file system on them. They just need to be
$ tar cvfM /dev/fd0. ./ .xfmrc .x6530mcdkey .uwmrc .twmrc .rnsoft .rnlast ...etc Prepare volume #2 for /dev/fd0 and hit return:
Note also the solitary dot (.) at the end of the command line. That's the name of the
To extract the data again, use tar with the x option:
$ tar xvfM /dev/fd0. ./ .xfmrc .x6530modkey .uwmrc ...etc
See the man page tar(1) for other things you can do with tar.
Of course, most of the time you get data on a floppy, it's not in tar format: it has a Microsoft file system on it. We've already seen the Microsoft file system type on page 190, but that's a bit of
$ mdir list the current directory on A
Volume in drive A is MESSED OS Directory for A:/
Directory for A:/
IO SYS 33430 4-09-91 5:00a
MSDOS SYS 37394 4-09-91 5:00a
COMMAND COM 47845 12-23-92 5:22p
NFS <DIR> 12-24-92 11:03a
DOSEDIT COM 1728 10-07-83 7:40a
CONFIG SYS 792 10-07-94 7:31p
AUTOEXEC BAT 191 12-24-92 11:10a
MOUSE <DIR> 12-24-92 11:09a
12 File(s) 82944 bytes free
$ mcd nfs change to directory A:\NFS
$ mdir and list the directory
Volume in drive A is MESSED OS
Directory for A:/NFS
. <DIR> 12-24-92 11:03a
.. <DIR> 12-24-92 11:03a
HOSTS 5985 10-07-94 7:34p
NETWORK BAT 103 12-24-92 12:28p
DRIVES BAT 98 11-07-94 5:24p
and many more
51 File(s) 82944 bytes free
$ mtype drives.bat type the contents of DRIVES.BAT
Net use c: presto:/usr/dos
C:
Cd\nfs
#net use f:Porsche:/dos
#net use g:Porsche:/usr
$ mcopy a:hosts.
Copying HOSTS
$ ls-l hosts and list it
-rw-rw-rw- 1 root wheel 5985 Jan 28 18:04 hosts
You must specify the drive letter to mcopy, because it uses this indication to decide whether the file name is a UNIX or a Microsoft file name. You can copy files from FreeBSD to the floppy as well, of course.
A word of warning. UNIX uses a different text data format from Microsoft: in UNIX, lines end with a single character, called New line, and represented by the characters \n in the C programming language. It corresponds to the ASCII character Line Feed (represented by ^J). Microsoft uses two characters, a Carriage Return (^M) followed by a Line Feed. This unfortunate difference causes a number of unexpected compatibility problems, since both characters are usually invisible on the screen.
In FreeBSD, you won't normally have many problems.
net use c: presto:/usr/dos~M c:M cd \nfs"M #net use f: porsche:/dos~M #net use g: porsche:/usr~M
This may seem relatively harmless, but it confuses some programs, including the C compiler and pagers like more, which may react in confusing ways. You can remove them with the -t option of mcopy:
$ mcopy -t a:drives.bat
Transferring files in the other direction is more likely to cause problems. For example, you might edit this file under FreeBSD and then copy it back to the porsche to freedom, and then copied the file back to the
C:> type drives.bat net use c: presto:/usr/dos c: cd \nfs #net use f: freedom:/dos #net use g: freedom:/usr
This is a typical result of removing the Carriage Return characters. The -t option to mcopy can help here, too. If you use it when copying to a Microsoft file system, it reinserts the Carriage Return characters.
In Chapter 11 we looked at hard disks. In this chapter, we'll consider how to guard against data loss, and how to transfer data from one location to another. These are functions that UNIX traditionally performs with tapes, and we'll look at them in the next sections. Because FreeBSD runs on PCs, however, you can't completely escape
No matter how reliable your system, you are never completely protected against loss of data. The most common reasons are
UNIX talks about archives, which are copies of disk data in a form
Traditionally, PCs use
By contrast, a single
A number of cheaper
You can also use writeable "CD-ROMs" (CD-Rs) for backup purposes. By modern standards, the media are small (up to 700 MB), but they have the advantage of being readily accessible on other systems. We looked at CD-Rs in Chapter 13.
FreeBSD tape devices have names like /dev/nsa0 (see page 196). Each letter has a significance:
n means non-rewinding . When the process that accesses the tape closes it, the tape remains at the same position. This is inconvenient if you want to remove the tape (before which you should r stands for raw, in other words a sa stands for serial access, and is always SCSI. You can also get 0 is the unit number. If you have more than one tape, the next will be called /dev/nsa1, and so on.
FreeBSD does not require special "
tar, the tape archiver, performs the following functions:
tar does not compress the data. The resulting archive is slightly larger than the sum of the files that it contains, since it also contains a certain amount of header information. You can, however, use the gzip program to compress a tar archive, and tar invokes it for you automatically with the -z option. The size of the resultant archives depends strongly on the data you put in them. JPEG images, for example, hardly compress at all, while text compresses quite well and can be as much as 90% smaller than the original file.
Create an archive with the c option. Unlike most UNIX programs, tar does not require a
# tar cvf source-archive.tar /usr/src/sys tar: Removing leading / from absolute path names in the archive. usr/src/sys/ usr/src/sys/CVS/ usr/src/sys/CVS/Root usr/src/sys/CVS/Repository usr/src/sys/CVS/Entries usr/src/sys/compile/ usr/src/sys/compile/CVS/ (etc)
The parameters have the following meaning:
cvf are the options. c stands for create an archive, v specifies verbose operation (in this case, this causes tar to produce the list of files being archived), and f specifies that the next parameter is the name of the source-archive.tar is the name of the archive. In this case, it's a disk file./usr/src/sys is the name of the directory to archive. tar archives all files in the directory, including most devices. For historical reasons, tar can't back up devices with minor numbers greater than 65536, and changing the format would make it The message on the first line (Removing leading / ...) indicates that, although the directory name was specified as /usr/src/sys, tar treats it as usr/src/sys.. This makes it possible to restore the files into another directory at a later time.
You can back up to tape in exactly the same way:
# tar cvf /dev/nsa0 /usr/src/sys
There is a simpler way, how ever: if you don't specify a file name, tar looks for the environment variable TAPE. If it finds it, it interprets it as the name of the
TAPE=/dev/nsa0 export TAPE for sh and bash setenv TAPE /dev/nsa0 for csh and tcsh
After this, the previous example simplifies to:
# tar cv /usr/src/sys
To list an archive, use the option t:
# tar t from tape usr/src/sys/ usr/src/sys/CVS/ usr/src/sys/CVS/Root usr/src/sys/CVS/Repository usr/src/sys/CVS/Entries usr/src/sys/compile/ usr/src/sys/compile/CVS/ usr/src/sys/compile/CVS/Root (etc) # tar tvf source-archive.tar from disk drwxrwxrwx root/bin 0 Oct 25 15:07 1997 usr/src/sys/ drwxrwxrwx root/bin 0 Oct 25 15:08 1997 usr/src/sys/CVS/ -rw-rw-rw- root/wheel 9 Sep 30 23:13 1996 usr/src/sys/CVS/Root -rw-rw-rw- root/wheel 17 Sep 30 23:13 1996 usr/src/sys/CVS/Repository -rw-rw-rw- root/bin 346 Oct 25 15:08 1997 usr/src/sys/CVS/Entries drwxrwxrwx roo t/bin 0 Oct 27 17:11 1997 usr/src/sys/compile/ drwxrwxrwx root/bin 0 Jul 30 10:52 1997 usr/src/sys/compile/CVS/ (etc)
This example shows the use of the v (verbose) option with t. If you don't use it, tar displays only the names of the files (first example, from tape). If you do use it, tar also displays the permissions, ownerships, sizes and last modification date in a form reminiscent of ls -l (second example, which is from the disk file source-archive.tar).
To extract a file from the archive, use the x option:
#tar xv usr/src/sys/Makefile from tape usr/src/sys/Makefile confirms that the file was extracted
As with the c option, if you don't use the v option, tar does not list any file names. If you omit the names of the files to extract, tar extracts the complete archive.
You can combine gzip with tar by specifying the z option. For example, to create the archive source-archive.tar.gz in compressed format, write:
# tar czf source-archive.tar.gz /usr/src/sys
You must specify the z option when listing or extracting compressed archives, and you must not do so when listing or extracting non-compressed archives. Otherwise you get messages like:
# tar tzvf source-archive.tar gzip: stdin: not in gzip format tar: child returned status 1 # tar tvf source-archive.tar.gz tar: only read 2302 bytes from archive source-archive.tar.gz
I don't like floppy disks. UNIX doesn't like floppy disks. Probably you don't like floppy disks either, but we
FreeBSD uses
So why use floppies? The only good reasons are:
In the following sections, we'll look at how to handle floppies under FreeBSD, with particular regard to
Even if you buy preformatted floppies, it's a good idea to
On Microsoft platforms, you format floppies with the FORMAT program, which performs two different functions when invoked on floppies: it performs both a low-level format, which rewrites the physical sector information, and then it performs what it calls a high-level format, which writes the information necessary for Microsoft platforms to use it as a file system. UNIX calls the second operation creating a file system. It's not always necessary to have a file system on the
To format a
$ fdformat /dev/fd0 Format 1440K floppy '/dev/fdC? (y/n): y Processing --------------------------------
Each
Processing VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV done.
It's possible to use floppies as file systems under FreeBSD. You can create a UFS file system on a floppy just like on a hard disk. This is not necessarily a good idea: the UFS file system is designed for performance, not maximum capacity. By default, it doesn't use the last 8% of disk space, and it includes a lot of structure information that further reduces the space available on the disk. Here's an example of creating a file system, mounting it on the directory /A , and listing the remaining space available on an empty 3,5" floppy. Since release 5, FreeBSD no longer requires a
# newfs -O1 /dev/fd0 create a new file system
/dev/fd0: 1.4MB (2880 sectors) block size 16384, fragment size 2048
using 2 cylinder groups of 1.00MB, 64 blks, 128 inodes.
super-block backups (for fsck -b #) at:
32, 2080
# mount /dev/fd0 /A mount the floppy on /A
# df -k /A display the space available
Filesystem 1024-blocks Used Avail Capacity Mounted on
/dev/fd0 1326 2 1218 0% /A
Let's look at this in a little more detail:
/A.-k option to display it in -k option. See page 128 for more details of environment variables.The output of df looks terrible! Our fbppy only has 1218 kB left for normal
# umount /A first unmount the floppy # tunefs -m 0 /dev/fd0 and changethe minimum free to 0 tunefs: minimum percentage of free space changes from 8% to 0% tunefs: should optimize for space with minfree < 8% # tunefs -o space /dev/fd0 changethe optimization tunefs: optimization preference changes from time to space # mount /dev/fd0 /A mount the file system again # df /A and takeanother look Filesystem 1024-blocks Used Avail Capacity Mounted on /dev/fd0 1326 2 1324 0% /A
Still, this is a far cry from the claimed
To create a Microsoft FAT12,
$ newfs_msdos -f 1440 /dev/fd0
The specification -f 1440 tells newfs_msdos that this is a 1.4 MB floppy. Alternatively, you can use the mformat command:
$ mformat A:
You can specify the number of tracks with the -t option, and the number of sectors with the -s option. To explicitly specify a fbppy with 80 tracks and 18 sectors (a standard 3,5" 1.44 MB floppy), you could enter:
$ mformat -t 80 -s 18 A:
mformat is one of the mtools that we look at in the next section.
Well, you could take the disks out of the cover and use them as a kind of frisbee. But there is one other useful thing you can do with floppies: as an archive medium, they don't need a file system on them. They just need to be
$ tar cvfM /dev/fd0. ./ .xfmrc .x6530mcdkey .uwmrc .twmrc .rnsoft .rnlast ...etc Prepare volume #2 for /dev/fd0 and hit return:
Note also the solitary dot (.) at the end of the command line. That's the name of the
To extract the data again, use tar with the x option:
$ tar xvfM /dev/fd0. ./ .xfmrc .x6530modkey .uwmrc ...etc
See the man page tar(1) for other things you can do with tar.
Of course, most of the time you get data on a floppy, it's not in tar format: it has a Microsoft file system on it. We've already seen the Microsoft file system type on page 190, but that's a bit of
$ mdir list the current directory on A
Volume in drive A is MESSED OS Directory for A:/
Directory for A:/
IO SYS 33430 4-09-91 5:00a
MSDOS SYS 37394 4-09-91 5:00a
COMMAND COM 47845 12-23-92 5:22p
NFS <DIR> 12-24-92 11:03a
DOSEDIT COM 1728 10-07-83 7:40a
CONFIG SYS 792 10-07-94 7:31p
AUTOEXEC BAT 191 12-24-92 11:10a
MOUSE <DIR> 12-24-92 11:09a
12 File(s) 82944 bytes free
$ mcd nfs change to directory A:\NFS
$ mdir and list the directory
Volume in drive A is MESSED OS
Directory for A:/NFS
. <DIR> 12-24-92 11:03a
.. <DIR> 12-24-92 11:03a
HOSTS 5985 10-07-94 7:34p
NETWORK BAT 103 12-24-92 12:28p
DRIVES BAT 98 11-07-94 5:24p
and many more
51 File(s) 82944 bytes free
$ mtype drives.bat type the contents of DRIVES.BAT
Net use c: presto:/usr/dos
C:
Cd\nfs
#net use f:Porsche:/dos
#net use g:Porsche:/usr
$ mcopy a:hosts.
Copying HOSTS
$ ls-l hosts and list it
-rw-rw-rw- 1 root wheel 5985 Jan 28 18:04 hosts
You must specify the drive letter to mcopy, because it uses this indication to decide whether the file name is a UNIX or a Microsoft file name. You can copy files from FreeBSD to the floppy as well, of course.
A word of warning. UNIX uses a different text data format from Microsoft: in UNIX, lines end with a single character, called New line, and represented by the characters \n in the C programming language. It corresponds to the ASCII character Line Feed (represented by ^J). Microsoft uses two characters, a Carriage Return (^M) followed by a Line Feed. This unfortunate difference causes a number of unexpected compatibility problems, since both characters are usually invisible on the screen.
In FreeBSD, you won't normally have many problems.
net use c: presto:/usr/dos~M c:M cd \nfs"M #net use f: porsche:/dos~M #net use g: porsche:/usr~M
This may seem relatively harmless, but it confuses some programs, including the C compiler and pagers like more, which may react in confusing ways. You can remove them with the -t option of mcopy:
$ mcopy -t a:drives.bat
Transferring files in the other direction is more likely to cause problems. For example, you might edit this file under FreeBSD and then copy it back to the porsche to freedom, and then copied the file back to the
C:> type drives.bat net use c: presto:/usr/dos c: cd \nfs #net use f: freedom:/dos #net use g: freedom:/usr
This is a typical result of removing the Carriage Return characters. The -t option to mcopy can help here, too. If you use it when copying to a Microsoft file system, it reinserts the Carriage Return characters.
Для получения официальных документов о завершении программы дополнительного профессионального образования (удостоверения о повышении квалификации, дипломов о профессиональной переподготовке и MBA) необходимо предоставить:
Внимание! Вы можете не заказывать доставку бумажной версии официального документы, а скачать его в электронном виде и распечатать самостоятельно. Информация о выданном документе в течение 1 месяца загружается в Федеральную информационную систему «Федеральный реестр сведений о документах об образовании и (или) о квалификации, документах об обучении» - ФИС ФРДО.
Доступ на новый сайт осуществляется с использованием адреса электронной почты, который был указан вами при регистрации на "старом". Мы постарались перенести все ваши данные с прежнего ресурса, однако не исключена вероятность потери части информации.
При возникновении проблемы со входом, воспользуйтесь функцией сброса пароля
Если вы обнаружите несоответствия, пожалуйста, сообщите нам.