bob@wyse.wyse.com (08/15/89)
Several postings recently have asked questions about the primary hard disk under SCO XENIX, particularly about upgrading to a new hard disk and needing to backup the root division. The following somewhat lengthy discussion details the events that are gone through when a new bootable disk is created. This information has been gleaned from the various scripts that control the process of installing the XENIX OS. This is my interpretation and I may be inaccurate or speculative in certain areas. All of this is controlled by a script called hd which can be found in the directory /usr/lib/mkdev. It is the same one used when you add a second hard disk using the command line: mkdev hd 1 The script is run from the N1 floppy disk /.profile as: /usr/mkdev/hd 0 First, some terminology. I will use the term partition to name an item created by an fdisk program, while the term division is used for what most UNIX people think of as partitions. I will be as careful as I can to be sure I don't let slip an "incorrect" usage, but if this happens I hope the context will point you to what I meant. Now, some device names. (Please note, I am limiting discussion to the first or primary hard disk.) A single hard disk on a PC may have up to 4 partitions. XENIX calls these hd01, hd02, hd03 and hd04. The ENTIRE disk is hd00. Also available are the names hd0a for the active partition and hd0d for a DOS partition. Finally, there are the names root and swap plus optional additional logical devices such as u, if the disk is large enough. The hd?? names come with the system (pre-defined) while the others are created by the divvy command, the XENIX equivalent of mkpart. It can be invoked on the first hard disk as follows: divvy -b 1 -c 1 This program can only be run interactively. The form above assumes that a divvy table exists for the partition, which is read and displayed. Besides the names root, swap, hd0a, and possibly u..., you will see a device named recover. This is a 10K space on the disk that is used by fsck during an autoboot. Note that because of the required divisions there is space for only 4 optional devices. Also, the device named recover is NOT for use as a scratch file. It is used to hold fsck output during an autoboot so it can then be mailed to root. Using this method keeps the filesystems being checked static during the check. Now, back to installation. The first access of the disk is by the command: dparam -w This installs on track 0 of the disk the contents of the file /etc/masterboot. This "program" is loaded by the BIOS and its only purpose in life is to find the active partition and load its boot sectors. If there are none it generates a "No OS" error message. Because of the way it is installed, there is no apparent straight forward way of doing it to a secondary hard disk (no device name allowed with the -w option). It might be possible to use dd on it but I have not explored this avenue. Next, dparam is run again, using the script dkinit as a front end. It is at this point that a non-standard hard disk may be specified. (I have never done this, so don't know anything more about this.) After exiting dkinit, the installation procedure runs fdisk followed by badtrk. If the first track of the XENIX partition is bad in any part, badtrk will exit with a non-zero status and you will be prompted to re-partition the disk. Since the boot track is outside of the filesystem structures, it is not possible to logically map spare sectors in this track. Reading data from this space successfuly requires that the track be flawless. The next item of interest is divvy. On installation of the OS, it is run with a -i option which tells it to create a root filesystem and swap device on this disk. If the disk is large enough it will prompt you about creating a separate u filesystem. After creating the necessary filesystem structures, the install script will mount the division that will be the hard disk's root on the floppy disk's /mnt directory and use cpio with the pass option to copy most of the floppy disk contents to the hard disk. A mknod must be done in the hard disk dev directory to make proper entries for root and rroot (major/minor numbers pointing to the hard disk, not the floppy). Just before exiting, the script brands the kernel so it will run properly and uses dd twice, to install the files /etc/hdboot0 and /etc/hdboot1 on the XENIX partition boot track. The primary difficulty then in moving up to a new larger primary hard disk is getting the file /etc/masterboot properly installed. This is most easily done by just using the N1 install disk and doing the first part of the install process, so the disk is prepared for installing the files from the old disk. You would then re-boot from a previously prepared floppy and copy files from a tape backup to the new disk. Alternatively, if you can set up the old disk as the secondary disk (temporarily or permanently?) you could expedite the transfer of files from it by mounting it under the primary disk. This would imply completing the the OS installation and using find and cpio to do a pass type operation from the second to the first hard disk. Do not try to use dd on /dev/hd00 to "duplicate" the first disk onto a second. Bad tracks will be different, so even if the procedure worked the result would not be usable. However, unless you have a flawless hard disk the read by dd of hd00 will fail at the first bad sector. Remember, bad sectors are only mapped out with respect to a filesystem and hd00 is certainly not that. Finally for all you folks who have stayed with it this far, a little extra item: why have multiple XENIX partitions on a disk (remember the meaning of partition, here!)? On very large disks you may find that the 4 optional plus root divisions still leave you with much larger chunks of disk than you want per fs, or in the original setup the system was left with a large DOS partition which is now just wasted space. What you can do is: 1) run fdisk, delete the DOS partition and use the same parameters to make a XENIX partition, or if this is the initial install create two or more partitions right away. If this is the case be sure to leave the primary one large enough for the full system. **Remember the partition number[s]!!** 2) Run badtrk on each partition using the following form: badtrk -e -f /dev/rhd0n where n is the partition number from fdisk. NOTE: NEVER run badtrk with the -e unless it is on a disk that has not been previously set up. This option causes the program to recreate the badtrack/spares table/allocation, which could cause loss of data. 3) Run divvy to create the logical device names and filesystem structure: divvy -m -b 1 -c 1 -v n Again, n is the partition number from fdisk. You SHOULD do block by block control since the default names divvy uses are not very nice. In fact, if any one knows where/how the names are created, I would be interested. The format is: d1057all The -m tells divvy that a new table is being made with 1 or more divisions. Without this option it will try to read a divvy table from the disk and fail if one is not found. Comments and contructive criticism are welcome. Flames to /dev/null. :-) I hope this is helpful and useful. Cheers! :-) Bob McGowan (standard disclaimer, these are my own ...) Customer Education, Wyse Technology, San Jose, CA ..!uunet!wyse!bob bob@wyse.com
noel@ubbs-nh.MV.COM (N. Del More) (08/17/89)
In article <2363@wyse.wyse.com> bob@wyse.wyse.com () writes: > >Just before exiting, the script brands the kernel so it will run >properly and uses dd twice, to install the files /etc/hdboot0 and >/etc/hdboot1 on the XENIX partition boot track. Interesting article. I have a question concerning SCO's serialization and branding of the OS or any other application for that matter. Just how does it work. I know from past experiance that while the files may be present they will not function without the "branding". Noel