Disk partitions: autorecovery, aux-root, swap, etc.

Operator root at infohh.rmi.de
Sat Jul 16 03:01:14 AEST 1988


Setup:
======
   80 MB external A/UX (as shipped by Apple)
  300 MB internal installed with 1 MacOS partition workable + 1 other partition
Purpose:
========
  300 MB internal with MacOS running in 1 partition and A/UX
  in 1 root and one user partition

As far as I know: with A/UX tools (dp(1M), little vi+c+...) there 
is no way short of writing your own MacOS driver to set up a functional 
MacOS partition; Apple's 'Apple_Driver' intentionally ignores non-Apple
drives. So the MacOS setup had to be done with an installer tool 
supplied  by the local distributor of the 300 MB drive, that (installer) 
runs under MacOS - and being a 1st test version written without access to
A/UX still had some minor shortcomings.

So, when I looked at the drives under A/UX (running from HD 80), dp showed 
(semantically, I 'netted up' the format 
(status: v_alid, a_llocated, u_sed, b_oot, r_ead, w_rite;
last 3 columns in A/UX partitions: {Eschatology,Root,User,Swap}FS
                                   cluster
                                   critical)
) this:

/dev/rdsk/c5d0s31:      # SCSI 5, external HD 80                
ID  Name         Type                phys. blks        log. blks    status
-----------------------------------------------------------------------------------
0 MacOS          Apple_HFS           (  4096 @ 146128) [  4096 @ 0] vau-rw
1 Apple          Apple_partition_map (    63 @      1) [    63 @ 0] vau-rw
2 Macintosh      Apple_Driver        (    32 @     64) [    32 @ 0] vaubrw
3 Extra          Apple_Free          (    32 @     96) [    32 @ 0] vau-rw
4 Eschatology_1  Apple_UNIX_SVR2     (  6144 @    128) [  6144 @ 0] vau-rw  EFS 0 C
5 A/UX_Root      Apple_UNIX_SVR2     (111184 @   6272) [111184 @ 0] vau-rw RUFS 0 -
6 Swap           Apple_UNIX_SVR2     ( 28672 @ 117456) [ 28672 @ 0] vau-rw  SFS 0 C
7 Eschatology_2  Apple_UNIX_SVR2     (  6144 @ 150224) [  6144 @ 0] vau-rw  EFS 0 C
8 Extra          Apple_Free          (     2 @ 156368) [     2 @ 0] vau-rw         

/dev/rdsk/c0d0s31:      # SCSI 0, internal HD 300
ID  Name         Type                phys. blks        log. blks    status
-----------------------------------------------------------------------------------
0 80 Macintosh   Apple_HFS           (163840 @    128) [0 @ 163840] vau-rw
1 Macintosh      Apple_Driver        (    16 @     64) [0 @     16] vaubrw
2 Macintosh      Apple_UNIX_SVR2     (422795 @ 163986) [0 @ 422795] vau-rw RUFS 0 -
3 Partition      Apple_partition_map (     6 @      1) [0 @      6] vau-rw
4 Macintosh      Apple_Free          (    48 @     80) [0 @     48] vau-rw
5 Macintosh      Apple_Free          (  4660 @    128) [0 @   4660] vau-rw

so I had to 1) change the number of entries in the partition map
            2) swap logical start with logical length
            3) change the size of the UNIX partition
            4) add some more partitions for Eschatology, user FS
                        5) change partition 5 (starts at same block as 0)
                        6) copy date form HD 80 to HD 300, make filesystem,
                           eschatology, have user FS automatically mounted
to get here:

/dev/rdsk/c0d0s31:      # SCSI 0, internal HD 300
ID  Name         Type                phys. blks        log. blks    status
-----------------------------------------------------------------------------------
0 80 Macintosh   Apple_HFS           (163840 @    128) [163840 @ 0] vau-rw
1 Macintosh      Apple_Driver        (    16 @     64) [    16 @ 0] vaubrw
2 Eschatology_1  Apple_UNIX_SVR2     (  6144 @ 163986) [  6144 @ 0] vau-rw  EFS 0 C
3 Partition      Apple_partition_map (    63 @      1) [    63 @ 0] vau-rw
4 Macintosh      Apple_Free          (    48 @     80) [0 @     48] vau-rw
5 A/UX_Root      Apple_UNIX_SVR2     (111184 @ 170130) [111184 @ 0] vau-rw RUFS 0 -
6 Swap           Apple_UNIX_SVR2     ( 28672 @ 281314) [ 28672 @ 0] vau-rw  SFS 0 C
7 Eschatology_2  Apple_UNIX_SVR2     (  6144 @ 309986) [  6144 @ 0] vau-rw  EFS 0 C 
8 A/UX_user      Apple_UNIX_SVR2     (200000 @ 316130) [200000 @ 0] vau-rw  UFS 0 -
9 Extra          Apple_UNIX_SVR2     ( 70000 @ 516130) [ 70000 @ 0] vau-rw  UFS 0 -
(where partition 9 isn't used by A/UX, yet)


Step 1: As dp doesn't have a documented way of changing the
======= number of entries in the partition map, I wrote a small 
 C tool  to do it:

 !!!! if used the wrong way, the following code could assist you
      in destroying the most sensitive data, so don't use it before
      you're sure what it does !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
          
#include <stdio.h>       /* this works only if you have super user access */
#include <fcntl.h>
#include <apple/dpme.h>

extern long lseek();

main() {
  int fd;
  DPME OneEntry;
#define DPMElen sizeof(DPME)
#define BLOCK   512
  int count = 0;

  /* /dev/rdsk/c0d0s31 is c<SCSI 0>d<driver>s<slice 31=whole disk> */
  
  printf ("\npme: opening /dev/rdsk/c0d0s31 for inspection etc. of partition map\n");
  printf ("-------------------------------------------------------------------\n");

  if ((fd = open ("/dev/rdsk/c0d0s31", O_RDWR)) >= 0 ) {
    for (count=1 /* phys. blk, see table above */; count < 17; count++) {
      lseek (fd, (long)(count*BLOCK), 0);
      if (read (fd, &OneEntry, DPMElen) == DPMElen) {
       if (OneEntry.dpme_signature != DPME_SIGNATURE) {
           printf ("indecent DPME %d\n", count-1);  exit (-1);
       }
       else {
        if (OneEntry.dpme_allocated)
            printf ("%d %20s %20s [%8d %8d] (%8d %8d) %c%c%c%c %c%v\n", 
                    count-1, OneEntry.dpme_dpident.dpiname,
                             OneEntry.dpme_dpident.dpitype,
                             OneEntry.dpme_pblock_start, OneEntry.dpme_pblocks,
                             OneEntry.dpme_lblock_start, OneEntry.dpme_lblocks,
                             OneEntry.dpme_writable  ?'w':'-',
                             OneEntry.dpme_readable  ?'r':'-',
                             OneEntry.dpme_bootable  ?'b':'-',
                             OneEntry.dpme_in_use    ?'u':'-',
                             OneEntry.dpme_allocated ?'a':'-',
                             OneEntry.dpme_valid     ?'v':'-'
                        );
        else
            printf ("%d ------- not allocated -----------\n", count-1);
        }
      }
      else { printf ("couldn't read DPME %d\n", count-1); exit(-1); }
    }
    
    /* change number of map entries in partition map */
    /* --------------------------------------------- */
    lseek (fd, (long)(1*BLOCK), 0);
    if (read (fd, &OneEntry, DPMElen) == DPMElen) {
           OneEntry.dpme_map_entries = 16;        /* <<--- MAP ENTRIES */
           lseek (fd, (long)(1*BLOCK), 0);
           /* if (write (fd, &OneEntry, DPMElen) != DPMElen) { protection */
              printf ("couldn't change # of MAP ENTRIES in DPME %d\n", 1-1);
           }
    }
        
    /* initializing new map entries for 'dp' et. al. */
    /* --------------------------------------------- */
    for (count=6+1; count < 16; count++) {
      lseek (fd, (long)(count*BLOCK), 0);
      if (read (fd, &OneEntry, DPMElen) == DPMElen) {
           OneEntry.dpme_bootable = 0;            /* <<--- NOT BOOTABLE */
                   OneEntry.dpme_pblocks =        /* <<--- otherwise dp */
                   OneEntry.dpme_lblocks = 0;     /* <<--- dumps core   */
                   OneEntry.dpme_pblock_start = 
                   OneEntry.dpme_lblock_start = 500000; /* device dependent! */
           lseek (fd, (long)(count*BLOCK), 0);
           /* if (write (fd, &OneEntry, DPMElen) != DPMElen) { protection */
              printf ("couldn't change BOOTABLE bits in DPME %d\n", count-1);
              break;
           }
           */
      }
      else { printf ("couldn't read DPME %d\n", count-1); break; }
    }
  }
  close (fd);
}

Step 2: can be done with dp interactively (see below) or
======= by modifying the above source

Steps 3-5 I found easiest to do in dp interactive mode: (do see dp(1M))
}i========= thus: 'dp /dev/rdsk/c0d0s31'  # you need to be super user
'P'    - to be sure about the disk we're manipulating

'd 5'  - to delete partition 5

'c 2'  - to supply the new name, block numbers of partition 2 as asked for
'b'    - to supply FS type, cluster #, and critical bit as asked for
'q'    - to get to DPME-field mode
'q'    - to get to command mode

'a 5'  - to create A/UX_Root partition
'b'    - to supply FS type, cluster #, and critical bit as asked for
'q'    - to get to DPME-field mode
'q'    - to get to command mode

'a 6'  - to create Swap partition
...
'a 7'  - to create Eschatology_2 partition
...
'a 8'  - to create A/UX_user partition
...
'a 9'  - to create Extra partition
...

'P'    - to check the changes
'w'    - to write back iff o.k.
'q'    - to get to step 6

Step 6: make file systems to access partitions logically:
======= 'mkfs /dev/rdsk/c0d0s0 111184'  # number from ID 5, above
        'mkfs /dev/rdsk/c0d0s2 200000'  # number from ID 8, above
                
copy root partition from external HD 80 to internal HD 300:
dd if=/dev/rdsk/c5d0s0 of=/dev/rdsk/c0d0s0

>>> now reboot and from 'sash' boot (0,0,0), i.e. from HD300
and in SYSTEM MAINTENANCE MODE (single user) run 'eupdate'
to install/preset the eschatology filesystems

then 'mkdir /user' and 
'/etc/mount /dev/dsk/c0d0s2 /user' and with
'devnm > /etc/fstab' install /user FS for automatic
mount at boot-up.

I'd be glad to hear any comments, corrections, improvements.

---------
That's it, 
  rlj
  
  
-------------------------------------------------------------------------------
RL Jakschewitz  systemsoftware  Geuderstr. 7  D-8500 NUERNBERG 20  West Germany
Tel: +949 911 53 84 24                                     BITNET: P17386 at QZCOM
UUCP: rlj-nbg at infohh.rmi.de         or        mcvax!unido!infohh.rmi.de!rlj-nbg
-------------------------------------------------------------------------------



More information about the Comp.unix.aux mailing list