Subject: RE: installing problems
To: 'paul yaskowski' <paul@upvchamber.org>
From: Gunnar Helliesen <gunnar@bitcon.no>
List: port-vax
Date: 07/30/1999 09:01:50
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------ =_NextPart_000_01BEDA59.65C9CF20
Content-Type: text/plain

paul yaskowski wrote:
> 
> I'm having the worst luck installing..
> 
> Anyway, my scsi disks in my vaxstation 3100 have bad sectors.  i've
> formatted them with the "test 75" console command, but netbsd 
> still has
> problems with some areas.  when it attempts to write to an affected
> area, the kernel panics and i find myself back at the chevron prompt. 
> from what i've read, you use the "bad144" program to check for bad
> sectors.  is that true?  can anyone else offer help on how to get
> around my bad sectors?  and, i grabbed all the precompiled sets from
> ftp.netbsd.org, and none of them included a bad144 program.  i'm used
> to linux's mkfs, which spawns badblocks to check for them.  is there
> anyway to do this in netbsd/vax?

I've used this program (sdremap.c) on NetBSD/i386 with good results. The
docs are in the source. Please note, this program only works on SCSI
disks and for all I know it might not work at all on NetBSD/vax. The
program was written by Jason R. Thorpe <thorpej@NetBSD.ORG>, so if it
works for you send your thanks his way.

Gunnar

--
Gunnar Helliesen   | Bergen IT Consult AS  | NetBSD/VAX on a uVAX II
Systems Consultant | Bergen, Norway        | '86 Jaguar Sovereign 4.2
gunnar@bitcon.no   | http://www.bitcon.no/ | '73 Mercedes 280 (240D)


------ =_NextPart_000_01BEDA59.65C9CF20
Content-Type: application/octet-stream;
	name="sdremap.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="sdremap.c"

/*
 * sdremap <dev> <blkno> - tell a SCSI disk to remap the bad block
 *                         specified on the command line.
 *
 * Compile this on your favorite NetBSD 1.1 system with:
 *
 *      cc -I/sys -DOLD_SCSI_BYTES -o sdremap sdremap.c
 *
 * or on newer NetBSD systems with:
 *
 *      cc -I/sys -o sdremap sdremap.c
 *
 * It will be pretty obvious if you need to add or remove the =
OLD_SCSI_BYTES
 * define; this program won't compile if the setting is incorrect.
 *
 * When you use this program, make sure the disk you're mucking with
 * has no mounted filesystems (unless that's just not possible, in =
which
 * case, make sure they're mounted read-only, and you're in single-user
 * mode).  You must use the "raw partition" of the disk.  On an i386, =
this
 * is `d', and everywhere else `c'.
 *
 * I.e.:
 *      ./sdremap /dev/rsd1d 356642
 *
 * Written by Jason R. Thorpe <thorpej@NetBSD.ORG>.
 * This program is in the public domain.
 *
 * Use this software at your own risk.  At no time shall Jason R. =
Thorpe
 * be liable for any damages it may cause.
 *
 * TODO:
 *      Handle multiple blocks with a single command.  I'm just lazy.
 */

#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/scsiio.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

#include <dev/scsipi/scsi_all.h>
#include <dev/scsipi/scsi_disk.h>

extern  char *__progname;               /* from crt0.o */

static  void usage __P((void));
static  void cleanup __P((void));

static  int disk_fd;

int
main(argc, argv)
        int argc;
        char **argv;
{
        struct scsi_reassign_blocks cmd;
        struct scsi_reassign_blocks_data desc;
        scsireq_t req;
        char *disk, *cp;
        u_int32_t blkno;
        u_int16_t desc_data_len;

        if (argc !=3D 3)
                usage();

        disk =3D argv[1];
        blkno =3D (u_int32_t)strtol(argv[2], &cp, 10);
        if (*cp !=3D '\0')
                errx(1, "invalid block number `%s'", argv[2]);

        /* Register cleanup function. */
        if (atexit(cleanup))
                err(1, "can't register cleanup function");

        /* Open the device... */
        if ((disk_fd =3D open(disk, O_RDWR, 0600)) =3D=3D -1)
                err(1, "%s: open", disk);

        /* Build SCSI command. */
        bzero(&cmd, sizeof(cmd));
        cmd.opcode =3D SCSI_REASSIGN_BLOCKS;

        /*
         * Build the block descriptor.
         */
        desc_data_len =3D sizeof(desc.defect_descriptor[0]);
        bzero(&desc, sizeof(desc));
        /* Descriptor length. */
#ifdef OLD_SCSI_BYTES
        desc.length_msb =3D (desc_data_len >> 8) & 0xff;
        desc.length_lsb =3D desc_data_len & 0xff;
#else
        desc.length[0] =3D (desc_data_len >> 8) & 0xff;
        desc.length[1] =3D desc_data_len & 0xff;
#endif
        /* Block number. */
#ifdef OLD_SCSI_BYTES
        desc.defect_descriptor[0].dlbaddr_3 =3D (blkno >> 24) & 0xff;
        desc.defect_descriptor[0].dlbaddr_2 =3D (blkno >> 16) & 0xff;
        desc.defect_descriptor[0].dlbaddr_1 =3D (blkno >> 8) & 0xff;
        desc.defect_descriptor[0].dlbaddr_0 =3D blkno & 0xff;
#else
        desc.defect_descriptor[0].dlbaddr[0] =3D (blkno >> 24) & 0xff;
        desc.defect_descriptor[0].dlbaddr[1] =3D (blkno >> 16) & 0xff;
        desc.defect_descriptor[0].dlbaddr[2] =3D (blkno >> 8) & 0xff;
        desc.defect_descriptor[0].dlbaddr[3] =3D blkno & 0xff;
#endif

        /* Fill out user-level SCSI request. */
        bzero(&req, sizeof(req));
        bcopy((struct scsi_generic *)&cmd, &req.cmd, sizeof(cmd));
        req.cmdlen =3D (u_char)sizeof(cmd);
        req.databuf =3D (void *)&desc;
        req.datalen =3D (u_long)sizeof(desc);
        req.flags |=3D SCCMD_WRITE;
        req.timeout =3D 20000;                    /* XXX */

        /* Send the request to the SCSI subsystem. */
        if (ioctl(disk_fd, SCIOCCOMMAND, (char *)&req) =3D=3D -1)
                err(1, "SCIOCCOMMAND");

        /*
         * XXX should check for error condition and print
         * sense data.
         */

        exit(0);
}

static void
cleanup()
{

        /* ...simple enough... */
        (void)close(disk_fd);
}

static void
usage()
{

        fprintf(stderr, "usage: %s disk blkno\n", __progname);
        exit(1);
}



------ =_NextPart_000_01BEDA59.65C9CF20--