One of the most important parts of running any computer system is handling data on disk. We have already looked at UNIX
When you installed FreeBSD, you created file systems on at least one hard disk. At a later point, you may want to install additional drives. There are two ways to do this: with sysinstall and with the traditional UNIX command-line utilities.
There was a time when it was dangerous to use sysinstall after the system had been installed: there was a significant chance of shooting yourself in the
We've been through all the details of disk layout and slices and partitions in Chapter 2, so I won't repeat them here. Basically, to add a new disk to the system, you need to:
These are the same operations that we performed in Chapter 5.
Before you can do anything with the disk, you have to install it in the system. To do this, you must normally shut down the system and turn the power off, though high-end SCSI
Adding a SCSI disk is more complicated. You can connect up to 15
What ever kind of disk you're adding, look at the boot messages, which you can retrieve with the dmesg command. For example, if you're planning to add a
sym0: <875> port 0xc400-0xc4ff mem 0xec002000-0xec002fff,0xec003000-0xec0030ff irq 10 at device 9.0 on pci0 sym0: Symbios NVRAM, ID 7, Fast-20, SE, NO parity sym0: open drain IRQ line driver, using on-chip SRAM sym0: using LOAD/STORE-based firmware. sym0: SCAN FOR LUNS disabled for targets 0. sym1: <875> port 0xc800-0xc8ff mem 0xec001000-0xec001fff,0xec000000-0xec0000ff irq 9 at device 13.0 on pci0 sym1: No NVRAM, ID 7, Fast-20, SE, parity checking further down... Waiting 3 seconds for SCSI devices to settle sa0 at sym0 bus 0 target 3 lun 0 sa0: <EXABYTE EXB-8505SMBANSH2 0793> Removable Sequential Access SCSI-2 device sa0: 5.000MB/s transfers (5.000MHz, offset 11) sa1 at sym0 bus 0 target 4 lun 0 sa1: <ARCHIVE Python 28849-XXX 4.CM> Removable Sequential Access SCSI-2 device sa1: 5.000MB/s transfers (5.000MHz, offset 15) sa2 at sym0 bus 0 target 5 lun 0 sa2: <TANDBERG TDC 3800 -03:> Removable Sequential Access SCSI-CCS device sa2: 3.300MB/s transfers pass4 at sym0 bus 0 target 4 lun 1 pass4: <ARCHIVE Python 28849-XXX 4.CM> Removable Changer SCSI-2 device pass4: 5.000MB/s transfers (5.000MHz, offset 15) cd0 at sym0 bus 0 target 6 lun 0 cd0: <NRC MBR-7 110> Removable CD-ROM SCSI-2 device cd0: 3.300MB/s transfers cd0: cd present [322265 x 2048 byte records] da0 at sym1 bus 0 target 3 lun 0 da0: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device da0: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da0: 4095MB (8386733 512 byte sectors: 255H 63s/t 522C)
This output shows two Sym bios
External
Alternatively, you can add the device at the end of the chain. Remove the terminator or turn off the termination, and plug your cable into the
You can add external camcontrol rescan. For example, if you added a second
# camcontrol rescan 1 dal at syml bus 0 target 0 lun 0 dal: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device dal: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da1: 4095MB (8386733 512 byte sectors: 255H 63s/t 522C) Re-scan of bus 1 was successful
There's a problem with this approach: note that /dev/dal has ID 0, and the already present /dev/da0 has ID 3. If you now reboot the system, they will come up with the device names the other way round. We'll look at this issue in more detail in the next section.
Installing an internal
In this chapter, we'll look at two ways of installing a drive in an existing SCSI chain. We could be in for a surprise: the device ID we get for the new drive depends on what is currently on the chain. For example, consider our example above, where we have a chain with a single drive on it:
da0 at sym1 bus 0 target 3 lun 0 da0: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device da0: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da0: 4095MB (8386733 512 byte sectors: 255H 63S/T 522C)
This drive on target (ID) 2. If we put our new drive on target 0 and reboot, we see:
da0 at sym1 bus 0 target 0 lun 0 da0: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device da0: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da0: 4095MB (8386733 512 byte sectors: 255H 63S/T 522C) da1 at sym1 bus 0 target 3 lun 0 da1: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device da1: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da1: 4095MB (8386733 512 byte sectors: 255H 63S/T 522C)
At first glance, this looks reasonable, but that's only because both disks are of the same type. If you look at the target numbers, you'll notice that the new disk is /dev/da0,not /dev/dal. The target ID of the new disk is lower than the target ID of the old disk, so the system recognizes the new disk as /dev/da0, and our previous /dev/da0 has become /dev/dal .
This change of disk ID can be a problem. One of the first things you do with a new disk is to create new
Formatting is the process of rewriting every sector on the disk with a specific data pattern, one that the electronics find most difficult to
If you have anything you want to keep, back it up before formatting. Most modern disks don't need formatting unless they're damaged. In particular, formatting will not help if you're having configuration problems, if you can't get PPP to work or you're running out of
If you do need to format a SCSI disk, use camcontrol. camcontrol is a control program for
# camcontrol format dal
Remember that formatting a disk destroys all data on the disk. Before using the command, make sure that you need to do so: there are relatively few cases that call for formatting a disk. About the only reasons are if you want to change the physical sector size of the disk, or if you are getting "medium format corrupted" errors from the disk in response to read and write requests.
FreeBSD can format only floppies and SCSI disks. In general it is no longer possible to
# dd if=/dev/zero of=/dev/ad1 bs=128k
If this doesn't work, you may find formatting programs on the manufacturer's web site. You'll probably need to run them under a Microsoft platform.
If you can, use sysinstall to partition your disk. Looking at the dmesg output for our new disk, we see:
dal at syml bus 0 target 0 lun 0 dal: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device dal: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da1: 4095MB (8386733 512 byte sectors: 255H 63s/t 522C)
You see the standard installation screen (see Chapter 5, page 60). Select Index, then Partition, and you see the following screen:
(рис 11.1) Disk selection menu
In this case, we want to partition /dev/dai, so we position the cursor on da1 (as shown) and press Enter. We see the disk partition menu, which shows that the disk currently contains three partitions:
We want a FreeBSD partition, not a Microsoft partition. At this point, we have a number of choices:
(рис 11.2) Disk partition menu
f command.To use the whole disk, we first delete the current partition: we press the cursor down key until it highlights the FreeBSD partition. Then we press d, and the three partitions are joined into one, marked unused.
The next step is to create a new partition using the entire disk. If we press f, we get the following message:
We don't get this message if we use the a command: it just automatically assumes Yes. In this case we've decided to use the whole disk, so we move the cursor right to No and press Enter. That gives us a
This isn't a None as indicated. Then we press q to exit the
The important information on this rather empty looking menu is the information at the top about the free space available. We want to create two partitions: first, a swap partition of 512 MB, and then a file system taking up the rest of the disk. We press C, and are shown a
Next, we press c again to create a new partition. This time, we accept the offer of the rest of the space on the disk, 7338157 sectors, we select A file system , and we are presented with yet another menu asking for the name of the file system. We enter the name, in this case /S:
After pressing Enter, we see:
Finally, we press W to tell the
We're doing this online, so that's OK. We select Yes, and sysinstall creates the file system and mounts both it and the swap partition. This can take quite a while. Don't try to do anything with the drive until it's finished.
Unfortunately, sometimes you may not be able to use the sysinstall method. You may not have access to sysinstall, or you may want to use options that sysinstall doesn't offer. That leaves us with the old way to add disks. The only difference is that this time we need to use different tools. In the following sections, we'll look at what we have to do to install this same 4 GB Seagate drive manually. This time we'll change the partitioning to contain the following partitions:
We've called this file system /newhome to use it as an example of moving file systems to new disks.
The first step is to create a PC BIOS style fdisk. In the following discussion, you'll find a
If the disk is not brand new, it will have existing data of some kind on it. Depending on the nature of that data, fdisk could get sufficiently confused to not work correctly. If you don't format the disk, it's a good idea to overwrite the beginning of the disk with dd:
# dd if=/dev/zero of=/dev/da1 count=100 100+0 records in 100+0 records out 51200 bytes transferred in 1 sees (51200 bytes/sec)
We'll as sign 1 GB for Microsoft and use the remaining approximately 3 GB for FreeBSD. Our resulting
(рис 11.3) Partition table on second FreeBSD disk
The fdisk performs as good as no checking. You can easily create a
fdisk calls sysid. This is a number describing what the partition is used for. FreeBSD partitions have partition type 165, and modern (MS-DOS Release 4 and later) Microsoft partitions have type 6.start sector, the first sector in the partition.end sector for the partition.In addition, we need to decide which partition is the active partition, the partition from which we want to boot. In this case, it doesn't make any difference, because we won't be booting from the disk, but it's always a good idea to set it anyway.
We specify the partitions we don't want by giving them a type, start sector and end sector of 0. Our disk has 8386733 sectors, numbered 0 to 8386732. Partitions should start and end on a cylinder boundary, and we want the Microsoft partition to be about 1 GB. 1GB is 1024 MB, and 1 MB is 2048 sectors of 512 bytes each, so
# fdisk dal
******* Working on device /dev/dal *******
parameters extracted from in-core disklabel are:
cylinders=13726 heads=13 sectors/track=47 (611 blks/cyl)
Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=13726 heads=13 sectors/track=47 (611 blks/cyl)
fdisk: invalid fdisk partition table found
Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
<UNUSED>
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 47, size 8386539 (4094 Meg), flag 80 (active)
beg: cyl 0/ head 1/ sector 1;
end: cyl 413/ head 12/ sector 47
You'll notice that /fdisk has decided that there is a FreeBSD partition in partition 4. That happens even if the disk is brand new. In fact, this is a less desirable feature of /fdisk: it "suggests" this partition, it's not really there, which can be really confusing. This
We use the remaining space for the FreeBSD partition. How much? Well, dmesg tells us that there are 8386733 sectors, but if you look at the geometry that /fdisk outputs, there are 13726 cylinders with 13
| Partition number | Partition | Start | Size |
|---|---|---|---|
| 1 | 6 | 1 | 2091453 |
| 2 | 165 | 2091453 | 6295133 |
| 3 | 0 | 0 | |
| 4 | 0 | 0 |
Next we run fdisk in earnest by specifying the -i option. During this time, you may see messages on the console:
da1: invalid primary partition table: no magic
The message no magic doesn't mean that fdisk is out of purple smoke. It refers to the fact that it didn't find the so-called magic number, which identifies the
fdisk prompts interactively when you specify the -i flag:
# fdisk -i dal
******* Working on device /dev/da1 *******
parameters extracted from in-core disklabel are:
cylinders=13726 heads=13 sectors/track=47 (611 blks/cyl)
Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=13726 heads=13 sectors/track=47 (611 blks/cyl)
Do you want to change our idea of what BIOS thinks ? [n] Enter pressed Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblack is:
The data for partition 1 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 0, size 8386733 (4095 Meg), flag 80 (active)
beg: cyl 0/ head 0/ sector 1;
end: cyl 522/ head 12/ sector 47
Do you want to change it? [n] y
Supply a decimal value for "sysid (165=FreeBSD)" [0] 6
Supply a decimal value for "start" [0] Enter pressed Supply a decimal value for "size" [0] 2091453
Explicitly specify beg/end address ? [n] Enter pressed
sysid 6,(Primary 'big' DOS (> 32MB))
start 0, size 2091453 (1021 Meg), flag 0
beg: cyl 0/ head 0/ sector 1;
end: cyl 350/ head 12/ sector 47
Are we happy with this entry? [n] y
The data for partition 2 is:
<UNUSED>
Do you want to change it? [n] y
Supply a decimal value for "sysid (165=FreeBSD)" [0] 165 Supply a decimal value for "start" [0] 2091453
Supply a decimal value for "size" [0] 6295133
Explicitly specify beg/end address ? [n] Enter pressed
sysid 165,(FreeBSD/NetBSD/386BSD)
start 2091453, size 6295133 (3073 Meg), flag 0
beg: cyl 351/ head 0/ sector 1;
end: cyl 413/ head 12/ sector 47
Are we happy with this entry? [n] y
The data for partition 3 is:
<UNUSED>
Do you want to change it? [n] Enter pressed
The data for partition 4 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 47, size 8386539 (4094 Meg), flag 80 (active)
beg: cyl 0/ head 1/ sector 1;
end: cyl 413/ head 12/ sector 47
Do you want to change it? [n] y
The static data for the DOS partition 4 has been reinitialized to:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 47, size 8386539 (4094 Meg), flag 80 (active)
beg: cyl 0/ head 1/ sector 1;
end: cyl 413/ head 12/ sector 47
Supply a decimal value for "sysid (165=FreeBSD)" [165] 0 Supply a decimal value for "start" [47] 0
Supply a decimal value for "size" [8386539] 0
Explicitly specify beg/end address ? [n] Enter pressed
<UNUSED>
Are we happy with this entry? [n] y
Do you want to change the active partition? [n] y
Supply a decimal value for "active partition" [1] 2
Are you happy with this choice [n] y
We haven't changed the partition table yet. This is your last chance, parameters extracted from in-core disklabel are:
cylinders=13726 heads=13 sectors/track=47 (611 blks/cyl)
Figures below won't work with BIOS for partitions not in cyl 1 parameters to be used for BIOS calculations are:
cylinders=13726 heads=13 sectors/track=47 (611 blks/cyl)
Information from DOS bootblack is:
1: sysid 6,(Primary 'big' DOS (> 32MB))
start 0, size 2091453 (1021 Meg), flag 0
beg: cyl 0/ head 0/ sector 1;
end: cyl 350/ head 12/ sector 47
2: sysid 165,(FreeBSD/NetBSD/386BSD)
start 2091453, size 6295133 (3073 Meg), flag 80 (active)
beg: cyl 351/ head 0/ sector 1;
end: cyl 413/ head 12/ sector 47
3: <UNUSED>
4: <UNUSED>
Should we write new partition table? [n] y
You'll notice a couple of things here:
The problem here is overflow: once upon a time, the maximum cylinder value was 1023, and /fdisk still thinks this is the case. The numbers we're seeing here are the
Once we have a valid PC BIOS
The first thing we need is the disk (slice) label, which supplies general information about the slice:
The only information we need to input is the kind, size and locations of the partitions. In this case, we have decided to create a file system on
partition h (/dev/da1s2h) and b (/dev/dalslb). The
h partition and not the a partition, so we'll stick to that tradition, though there's nothing to stop you from using the
a partition if you prefer. In addition, we need to define the c partition, which represents the whole slice. In summary,
the FreeBSD slice we want to create looks like:
| /dev/da1s2b: FreeBSD swap, 512 MB |
|---|
| /dev/da1s2h: /newhome file system, 2.5 GB |
The program that writes the
# bsdlabel -w /dev/da1s2 auto
This creates the label with a single partition c. You can look at the label with bsdlabel without options:
#bsdlabel /dev/da1s2 #/dev/da0s2: 8partitions: # size offset fstype [fsize bsize bps/cpg] c: 6295133 0 unused 0 0 # "raw" part, don't edit
At this point, the only partition you have is the "whole disk" partition c. You still need to create partitions b and h and specify their location and size. Do this with bsdlabel -e, which starts an editor with the output you see above. Simply add additional partitions:
8partitions: # size offset fstype [fsize bsize bps/cpg] c: 6295133 0 unused 0 0 # "raw" part, don't edit b: 1048576 0 swap 0 0 h: 5246557 1048576 unused 0 0
You don't need to maintain any particular order, and you don't need to specify that partition h will be a file system. In the next step , newfs does that for you automatically.
Using the old disklabel program used to be like
–w option), you may find:
# bsdlabel -w da1s2 bsdlabel: /dev/da1s2c: Undefined error: 0
This message may be the result of the kernel having out-of-date information about the slice in memory. If this is the case, a reboot may help.
No disk label on disk is straightforward enough. You tried to use bsdlabel to look at the label before you had a label to look at.Label magic number or checksum is wrong! tells you that bsdlabel thinks it has a label, but it's invalid. This could be the result of an incorrect previous attempt to label the disk. It can be difficult to get rid of an incorrect label. The best thing to do is to repartition the disk with the label in a different position, and then copy /dev/zero to where the label used to be:
# dd if=/dev/zero of=/dev/da1 bs=128k count=
Then you can repartition again the way you want to have it.
Open partition would move or shrink probably means that you have specified incorrect values in your slice definitions. Check particularly that the c partition corresponds with the definition in the write: Read-only file system means that you are trying to do something invalid with a valid fixlabel: raw partition size > slice size or fixlabel: raw partitions offset != slice offset
The meanings of these messages should be obvious.
Once we have a valid label, we need to create the file systems. In this case, there's only one file system, on /dev/da1s2/z. Mercifully, this is easier:
# newfs -U /dev/da1s2h
/dev/vinum/da1s2h: 2561.8MB (5246556 sectors) block size 16384, fragment size 2048
using 14 cylinder groups of 183.77MB, 11761 blks, 23552 inodes.
with soft updates
super-block backups (for fsck -b #)at:
160, 376512, 752864, 1129216, 1505568, 1881920, 2258272, 2634624, 3010976, 3387328,
3763680, 4140032, 4516384, 4892736
The -U flag tells newfs to enable soft updates, which we looked at on page 191.
Finally the job is done. Well, almost. You still need to mount the file system, and to tell the system that it has more swap. But that's not much of a problem:
# mkdir /newhome make sure we have a directory to mount on # mount /dev/da1s2h/newhome and mount it # swapon /dev/da1s2b # df show free capacity and mounted file systems Filesystem 1024-blocks Used Avail Capacity Mounted on /dev/ad0s1a 19966 17426 944 95% / /dev/ad0s1e 1162062 955758 113340 89% /usr procfs 4 4 0 100% /proc presto:/ 15823 6734 8297 45% /presto/root presto:/usr 912271 824927 41730 95% /presto/usr presto:/home 1905583 1193721 521303 70% /presto/home presto:/S 4065286 3339635 563039 86% /S /dev/da1s2h 2540316 2 2337090 0% /newhome # pstat -s show swap usage Device 1K-blocks Used Avail Capacity Type /dev/ad0s4b 524160 0 524160 0% Interleaved /dev/da1s2b 524160 0 524160 0% Interleaved Total 1048320 0 1048320 0%
This looks fine, but when you reboot the system, /newhome and the additional swap will be gone. To ensure that they get mounted after booting, you need to add the following lines to /etc/fstab:
/dev/da1s2b none swap sw 0 0 /dev/da1s2h /newhome ufs rw 0 0
Very frequently, you add a new disk to a system because existing disks have run out of space. Let's consider the disk we have just added and assume that currently the files in /home are
#cd /home #tar cf - . | (cd /newhome; tar xvf – 2>/var/tmp/tarerrors)
This writes any error messages to the file /var/tmp/tarerrors. if you don't do this, any errors will get lost.
# rm -rf /usr/home
#rm /home #mkdir /home
You don't need to do this if /home was already a directory (for example, if you're moving a complete file system).
/dev/da1s2h /home ufs rw 0 0
#umount /newhome #mount /home
Modern hard disks are a miracle in
At the same time, reliability has gone up, but disks are still relatively
Modern disks make
# camcontrol modepage dal -m 1 -e
This command will start up your favorite editor (either the one specified in the EDITOR
AWRE (Auto Write Reallocation Enbld): 0 ARRE (Auto Read Reallocation Enbld): 0 TB (Transfer Block): 1 EER (Enable Early Recovery): 0 PER (Post Error): 1 DTE (Disable Transfer on Error): 0 DCR (Disable Correction): 0 Read Retry Count: 41 Write Retry Count: 24
The values for AWRE and ARRE should both be 1. If they aren't, as in this case, where AWRE is 0, change the data with the editor, write it back, and exit. camcontrol writes the data back to the disk and enables the option.
Note the last two lines in this example. They give the number of actual retries that this drive has performed. You can reset these values too if you want; they will be updated if the drive performs any additional retries.
One of the most important parts of running any computer system is handling data on disk. We have already looked at UNIX
When you installed FreeBSD, you created file systems on at least one hard disk. At a later point, you may want to install additional drives. There are two ways to do this: with sysinstall and with the traditional UNIX command-line utilities.
There was a time when it was dangerous to use sysinstall after the system had been installed: there was a significant chance of shooting yourself in the
We've been through all the details of disk layout and slices and partitions in Chapter 2, so I won't repeat them here. Basically, to add a new disk to the system, you need to:
These are the same operations that we performed in Chapter 5.
Before you can do anything with the disk, you have to install it in the system. To do this, you must normally shut down the system and turn the power off, though high-end SCSI
Adding a SCSI disk is more complicated. You can connect up to 15
What ever kind of disk you're adding, look at the boot messages, which you can retrieve with the dmesg command. For example, if you're planning to add a
sym0: <875> port 0xc400-0xc4ff mem 0xec002000-0xec002fff,0xec003000-0xec0030ff irq 10 at device 9.0 on pci0 sym0: Symbios NVRAM, ID 7, Fast-20, SE, NO parity sym0: open drain IRQ line driver, using on-chip SRAM sym0: using LOAD/STORE-based firmware. sym0: SCAN FOR LUNS disabled for targets 0. sym1: <875> port 0xc800-0xc8ff mem 0xec001000-0xec001fff,0xec000000-0xec0000ff irq 9 at device 13.0 on pci0 sym1: No NVRAM, ID 7, Fast-20, SE, parity checking further down... Waiting 3 seconds for SCSI devices to settle sa0 at sym0 bus 0 target 3 lun 0 sa0: <EXABYTE EXB-8505SMBANSH2 0793> Removable Sequential Access SCSI-2 device sa0: 5.000MB/s transfers (5.000MHz, offset 11) sa1 at sym0 bus 0 target 4 lun 0 sa1: <ARCHIVE Python 28849-XXX 4.CM> Removable Sequential Access SCSI-2 device sa1: 5.000MB/s transfers (5.000MHz, offset 15) sa2 at sym0 bus 0 target 5 lun 0 sa2: <TANDBERG TDC 3800 -03:> Removable Sequential Access SCSI-CCS device sa2: 3.300MB/s transfers pass4 at sym0 bus 0 target 4 lun 1 pass4: <ARCHIVE Python 28849-XXX 4.CM> Removable Changer SCSI-2 device pass4: 5.000MB/s transfers (5.000MHz, offset 15) cd0 at sym0 bus 0 target 6 lun 0 cd0: <NRC MBR-7 110> Removable CD-ROM SCSI-2 device cd0: 3.300MB/s transfers cd0: cd present [322265 x 2048 byte records] da0 at sym1 bus 0 target 3 lun 0 da0: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device da0: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da0: 4095MB (8386733 512 byte sectors: 255H 63s/t 522C)
This output shows two Sym bios
External
Alternatively, you can add the device at the end of the chain. Remove the terminator or turn off the termination, and plug your cable into the
You can add external camcontrol rescan. For example, if you added a second
# camcontrol rescan 1 dal at syml bus 0 target 0 lun 0 dal: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device dal: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da1: 4095MB (8386733 512 byte sectors: 255H 63s/t 522C) Re-scan of bus 1 was successful
There's a problem with this approach: note that /dev/dal has ID 0, and the already present /dev/da0 has ID 3. If you now reboot the system, they will come up with the device names the other way round. We'll look at this issue in more detail in the next section.
Installing an internal
In this chapter, we'll look at two ways of installing a drive in an existing SCSI chain. We could be in for a surprise: the device ID we get for the new drive depends on what is currently on the chain. For example, consider our example above, where we have a chain with a single drive on it:
da0 at sym1 bus 0 target 3 lun 0 da0: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device da0: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da0: 4095MB (8386733 512 byte sectors: 255H 63S/T 522C)
This drive on target (ID) 2. If we put our new drive on target 0 and reboot, we see:
da0 at sym1 bus 0 target 0 lun 0 da0: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device da0: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da0: 4095MB (8386733 512 byte sectors: 255H 63S/T 522C) da1 at sym1 bus 0 target 3 lun 0 da1: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device da1: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da1: 4095MB (8386733 512 byte sectors: 255H 63S/T 522C)
At first glance, this looks reasonable, but that's only because both disks are of the same type. If you look at the target numbers, you'll notice that the new disk is /dev/da0,not /dev/dal. The target ID of the new disk is lower than the target ID of the old disk, so the system recognizes the new disk as /dev/da0, and our previous /dev/da0 has become /dev/dal .
This change of disk ID can be a problem. One of the first things you do with a new disk is to create new
Formatting is the process of rewriting every sector on the disk with a specific data pattern, one that the electronics find most difficult to
If you have anything you want to keep, back it up before formatting. Most modern disks don't need formatting unless they're damaged. In particular, formatting will not help if you're having configuration problems, if you can't get PPP to work or you're running out of
If you do need to format a SCSI disk, use camcontrol. camcontrol is a control program for
# camcontrol format dal
Remember that formatting a disk destroys all data on the disk. Before using the command, make sure that you need to do so: there are relatively few cases that call for formatting a disk. About the only reasons are if you want to change the physical sector size of the disk, or if you are getting "medium format corrupted" errors from the disk in response to read and write requests.
FreeBSD can format only floppies and SCSI disks. In general it is no longer possible to
# dd if=/dev/zero of=/dev/ad1 bs=128k
If this doesn't work, you may find formatting programs on the manufacturer's web site. You'll probably need to run them under a Microsoft platform.
If you can, use sysinstall to partition your disk. Looking at the dmesg output for our new disk, we see:
dal at syml bus 0 target 0 lun 0 dal: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device dal: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da1: 4095MB (8386733 512 byte sectors: 255H 63s/t 522C)
You see the standard installation screen (see Chapter 5, page 60). Select Index, then Partition, and you see the following screen:
(рис 11.1) Disk selection menu
In this case, we want to partition /dev/dai, so we position the cursor on da1 (as shown) and press Enter. We see the disk partition menu, which shows that the disk currently contains three partitions:
We want a FreeBSD partition, not a Microsoft partition. At this point, we have a number of choices:
(рис 11.2) Disk partition menu
f command.To use the whole disk, we first delete the current partition: we press the cursor down key until it highlights the FreeBSD partition. Then we press d, and the three partitions are joined into one, marked unused.
The next step is to create a new partition using the entire disk. If we press f, we get the following message:
We don't get this message if we use the a command: it just automatically assumes Yes. In this case we've decided to use the whole disk, so we move the cursor right to No and press Enter. That gives us a
This isn't a None as indicated. Then we press q to exit the
The important information on this rather empty looking menu is the information at the top about the free space available. We want to create two partitions: first, a swap partition of 512 MB, and then a file system taking up the rest of the disk. We press C, and are shown a
Next, we press c again to create a new partition. This time, we accept the offer of the rest of the space on the disk, 7338157 sectors, we select A file system , and we are presented with yet another menu asking for the name of the file system. We enter the name, in this case /S:
After pressing Enter, we see:
Finally, we press W to tell the
We're doing this online, so that's OK. We select Yes, and sysinstall creates the file system and mounts both it and the swap partition. This can take quite a while. Don't try to do anything with the drive until it's finished.
Unfortunately, sometimes you may not be able to use the sysinstall method. You may not have access to sysinstall, or you may want to use options that sysinstall doesn't offer. That leaves us with the old way to add disks. The only difference is that this time we need to use different tools. In the following sections, we'll look at what we have to do to install this same 4 GB Seagate drive manually. This time we'll change the partitioning to contain the following partitions:
We've called this file system /newhome to use it as an example of moving file systems to new disks.
The first step is to create a PC BIOS style fdisk. In the following discussion, you'll find a
If the disk is not brand new, it will have existing data of some kind on it. Depending on the nature of that data, fdisk could get sufficiently confused to not work correctly. If you don't format the disk, it's a good idea to overwrite the beginning of the disk with dd:
# dd if=/dev/zero of=/dev/da1 count=100 100+0 records in 100+0 records out 51200 bytes transferred in 1 sees (51200 bytes/sec)
We'll as sign 1 GB for Microsoft and use the remaining approximately 3 GB for FreeBSD. Our resulting
(рис 11.3) Partition table on second FreeBSD disk
The fdisk performs as good as no checking. You can easily create a
fdisk calls sysid. This is a number describing what the partition is used for. FreeBSD partitions have partition type 165, and modern (MS-DOS Release 4 and later) Microsoft partitions have type 6.start sector, the first sector in the partition.end sector for the partition.In addition, we need to decide which partition is the active partition, the partition from which we want to boot. In this case, it doesn't make any difference, because we won't be booting from the disk, but it's always a good idea to set it anyway.
We specify the partitions we don't want by giving them a type, start sector and end sector of 0. Our disk has 8386733 sectors, numbered 0 to 8386732. Partitions should start and end on a cylinder boundary, and we want the Microsoft partition to be about 1 GB. 1GB is 1024 MB, and 1 MB is 2048 sectors of 512 bytes each, so
# fdisk dal
******* Working on device /dev/dal *******
parameters extracted from in-core disklabel are:
cylinders=13726 heads=13 sectors/track=47 (611 blks/cyl)
Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=13726 heads=13 sectors/track=47 (611 blks/cyl)
fdisk: invalid fdisk partition table found
Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
<UNUSED>
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 47, size 8386539 (4094 Meg), flag 80 (active)
beg: cyl 0/ head 1/ sector 1;
end: cyl 413/ head 12/ sector 47
You'll notice that /fdisk has decided that there is a FreeBSD partition in partition 4. That happens even if the disk is brand new. In fact, this is a less desirable feature of /fdisk: it "suggests" this partition, it's not really there, which can be really confusing. This
We use the remaining space for the FreeBSD partition. How much? Well, dmesg tells us that there are 8386733 sectors, but if you look at the geometry that /fdisk outputs, there are 13726 cylinders with 13
| Partition number | Partition | Start | Size |
|---|---|---|---|
| 1 | 6 | 1 | 2091453 |
| 2 | 165 | 2091453 | 6295133 |
| 3 | 0 | 0 | |
| 4 | 0 | 0 |
Next we run fdisk in earnest by specifying the -i option. During this time, you may see messages on the console:
da1: invalid primary partition table: no magic
The message no magic doesn't mean that fdisk is out of purple smoke. It refers to the fact that it didn't find the so-called magic number, which identifies the
fdisk prompts interactively when you specify the -i flag:
# fdisk -i dal
******* Working on device /dev/da1 *******
parameters extracted from in-core disklabel are:
cylinders=13726 heads=13 sectors/track=47 (611 blks/cyl)
Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=13726 heads=13 sectors/track=47 (611 blks/cyl)
Do you want to change our idea of what BIOS thinks ? [n] Enter pressed Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblack is:
The data for partition 1 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 0, size 8386733 (4095 Meg), flag 80 (active)
beg: cyl 0/ head 0/ sector 1;
end: cyl 522/ head 12/ sector 47
Do you want to change it? [n] y
Supply a decimal value for "sysid (165=FreeBSD)" [0] 6
Supply a decimal value for "start" [0] Enter pressed Supply a decimal value for "size" [0] 2091453
Explicitly specify beg/end address ? [n] Enter pressed
sysid 6,(Primary 'big' DOS (> 32MB))
start 0, size 2091453 (1021 Meg), flag 0
beg: cyl 0/ head 0/ sector 1;
end: cyl 350/ head 12/ sector 47
Are we happy with this entry? [n] y
The data for partition 2 is:
<UNUSED>
Do you want to change it? [n] y
Supply a decimal value for "sysid (165=FreeBSD)" [0] 165 Supply a decimal value for "start" [0] 2091453
Supply a decimal value for "size" [0] 6295133
Explicitly specify beg/end address ? [n] Enter pressed
sysid 165,(FreeBSD/NetBSD/386BSD)
start 2091453, size 6295133 (3073 Meg), flag 0
beg: cyl 351/ head 0/ sector 1;
end: cyl 413/ head 12/ sector 47
Are we happy with this entry? [n] y
The data for partition 3 is:
<UNUSED>
Do you want to change it? [n] Enter pressed
The data for partition 4 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 47, size 8386539 (4094 Meg), flag 80 (active)
beg: cyl 0/ head 1/ sector 1;
end: cyl 413/ head 12/ sector 47
Do you want to change it? [n] y
The static data for the DOS partition 4 has been reinitialized to:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 47, size 8386539 (4094 Meg), flag 80 (active)
beg: cyl 0/ head 1/ sector 1;
end: cyl 413/ head 12/ sector 47
Supply a decimal value for "sysid (165=FreeBSD)" [165] 0 Supply a decimal value for "start" [47] 0
Supply a decimal value for "size" [8386539] 0
Explicitly specify beg/end address ? [n] Enter pressed
<UNUSED>
Are we happy with this entry? [n] y
Do you want to change the active partition? [n] y
Supply a decimal value for "active partition" [1] 2
Are you happy with this choice [n] y
We haven't changed the partition table yet. This is your last chance, parameters extracted from in-core disklabel are:
cylinders=13726 heads=13 sectors/track=47 (611 blks/cyl)
Figures below won't work with BIOS for partitions not in cyl 1 parameters to be used for BIOS calculations are:
cylinders=13726 heads=13 sectors/track=47 (611 blks/cyl)
Information from DOS bootblack is:
1: sysid 6,(Primary 'big' DOS (> 32MB))
start 0, size 2091453 (1021 Meg), flag 0
beg: cyl 0/ head 0/ sector 1;
end: cyl 350/ head 12/ sector 47
2: sysid 165,(FreeBSD/NetBSD/386BSD)
start 2091453, size 6295133 (3073 Meg), flag 80 (active)
beg: cyl 351/ head 0/ sector 1;
end: cyl 413/ head 12/ sector 47
3: <UNUSED>
4: <UNUSED>
Should we write new partition table? [n] y
You'll notice a couple of things here:
The problem here is overflow: once upon a time, the maximum cylinder value was 1023, and /fdisk still thinks this is the case. The numbers we're seeing here are the
Once we have a valid PC BIOS
The first thing we need is the disk (slice) label, which supplies general information about the slice:
The only information we need to input is the kind, size and locations of the partitions. In this case, we have decided to create a file system on
partition h (/dev/da1s2h) and b (/dev/dalslb). The
h partition and not the a partition, so we'll stick to that tradition, though there's nothing to stop you from using the
a partition if you prefer. In addition, we need to define the c partition, which represents the whole slice. In summary,
the FreeBSD slice we want to create looks like:
| /dev/da1s2b: FreeBSD swap, 512 MB |
|---|
| /dev/da1s2h: /newhome file system, 2.5 GB |
The program that writes the
# bsdlabel -w /dev/da1s2 auto
This creates the label with a single partition c. You can look at the label with bsdlabel without options:
#bsdlabel /dev/da1s2 #/dev/da0s2: 8partitions: # size offset fstype [fsize bsize bps/cpg] c: 6295133 0 unused 0 0 # "raw" part, don't edit
At this point, the only partition you have is the "whole disk" partition c. You still need to create partitions b and h and specify their location and size. Do this with bsdlabel -e, which starts an editor with the output you see above. Simply add additional partitions:
8partitions: # size offset fstype [fsize bsize bps/cpg] c: 6295133 0 unused 0 0 # "raw" part, don't edit b: 1048576 0 swap 0 0 h: 5246557 1048576 unused 0 0
You don't need to maintain any particular order, and you don't need to specify that partition h will be a file system. In the next step , newfs does that for you automatically.
Using the old disklabel program used to be like
–w option), you may find:
# bsdlabel -w da1s2 bsdlabel: /dev/da1s2c: Undefined error: 0
This message may be the result of the kernel having out-of-date information about the slice in memory. If this is the case, a reboot may help.
No disk label on disk is straightforward enough. You tried to use bsdlabel to look at the label before you had a label to look at.Label magic number or checksum is wrong! tells you that bsdlabel thinks it has a label, but it's invalid. This could be the result of an incorrect previous attempt to label the disk. It can be difficult to get rid of an incorrect label. The best thing to do is to repartition the disk with the label in a different position, and then copy /dev/zero to where the label used to be:
# dd if=/dev/zero of=/dev/da1 bs=128k count=
Then you can repartition again the way you want to have it.
Open partition would move or shrink probably means that you have specified incorrect values in your slice definitions. Check particularly that the c partition corresponds with the definition in the write: Read-only file system means that you are trying to do something invalid with a valid fixlabel: raw partition size > slice size or fixlabel: raw partitions offset != slice offset
The meanings of these messages should be obvious.
Once we have a valid label, we need to create the file systems. In this case, there's only one file system, on /dev/da1s2/z. Mercifully, this is easier:
# newfs -U /dev/da1s2h
/dev/vinum/da1s2h: 2561.8MB (5246556 sectors) block size 16384, fragment size 2048
using 14 cylinder groups of 183.77MB, 11761 blks, 23552 inodes.
with soft updates
super-block backups (for fsck -b #)at:
160, 376512, 752864, 1129216, 1505568, 1881920, 2258272, 2634624, 3010976, 3387328,
3763680, 4140032, 4516384, 4892736
The -U flag tells newfs to enable soft updates, which we looked at on page 191.
Finally the job is done. Well, almost. You still need to mount the file system, and to tell the system that it has more swap. But that's not much of a problem:
# mkdir /newhome make sure we have a directory to mount on # mount /dev/da1s2h/newhome and mount it # swapon /dev/da1s2b # df show free capacity and mounted file systems Filesystem 1024-blocks Used Avail Capacity Mounted on /dev/ad0s1a 19966 17426 944 95% / /dev/ad0s1e 1162062 955758 113340 89% /usr procfs 4 4 0 100% /proc presto:/ 15823 6734 8297 45% /presto/root presto:/usr 912271 824927 41730 95% /presto/usr presto:/home 1905583 1193721 521303 70% /presto/home presto:/S 4065286 3339635 563039 86% /S /dev/da1s2h 2540316 2 2337090 0% /newhome # pstat -s show swap usage Device 1K-blocks Used Avail Capacity Type /dev/ad0s4b 524160 0 524160 0% Interleaved /dev/da1s2b 524160 0 524160 0% Interleaved Total 1048320 0 1048320 0%
This looks fine, but when you reboot the system, /newhome and the additional swap will be gone. To ensure that they get mounted after booting, you need to add the following lines to /etc/fstab:
/dev/da1s2b none swap sw 0 0 /dev/da1s2h /newhome ufs rw 0 0
Very frequently, you add a new disk to a system because existing disks have run out of space. Let's consider the disk we have just added and assume that currently the files in /home are
#cd /home #tar cf - . | (cd /newhome; tar xvf – 2>/var/tmp/tarerrors)
This writes any error messages to the file /var/tmp/tarerrors. if you don't do this, any errors will get lost.
# rm -rf /usr/home
#rm /home #mkdir /home
You don't need to do this if /home was already a directory (for example, if you're moving a complete file system).
/dev/da1s2h /home ufs rw 0 0
#umount /newhome #mount /home
Modern hard disks are a miracle in
At the same time, reliability has gone up, but disks are still relatively
Modern disks make
# camcontrol modepage dal -m 1 -e
This command will start up your favorite editor (either the one specified in the EDITOR
AWRE (Auto Write Reallocation Enbld): 0 ARRE (Auto Read Reallocation Enbld): 0 TB (Transfer Block): 1 EER (Enable Early Recovery): 0 PER (Post Error): 1 DTE (Disable Transfer on Error): 0 DCR (Disable Correction): 0 Read Retry Count: 41 Write Retry Count: 24
The values for AWRE and ARRE should both be 1. If they aren't, as in this case, where AWRE is 0, change the data with the editor, write it back, and exit. camcontrol writes the data back to the disk and enables the option.
Note the last two lines in this example. They give the number of actual retries that this drive has performed. You can reset these values too if you want; they will be updated if the drive performs any additional retries.
Для получения официальных документов о завершении программы дополнительного профессионального образования (удостоверения о повышении квалификации, дипломов о профессиональной переподготовке и MBA) необходимо предоставить:
Внимание! Вы можете не заказывать доставку бумажной версии официального документы, а скачать его в электронном виде и распечатать самостоятельно. Информация о выданном документе в течение 1 месяца загружается в Федеральную информационную систему «Федеральный реестр сведений о документах об образовании и (или) о квалификации, документах об обучении» - ФИС ФРДО.
Доступ на новый сайт осуществляется с использованием адреса электронной почты, который был указан вами при регистрации на "старом". Мы постарались перенести все ваши данные с прежнего ресурса, однако не исключена вероятность потери части информации.
При возникновении проблемы со входом, воспользуйтесь функцией сброса пароля
Если вы обнаружите несоответствия, пожалуйста, сообщите нам.