LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   /dev/st0 : Input/Output error (https://www.linuxquestions.org/questions/linux-hardware-18/dev-st0-input-output-error-408535/)

sharonenoch 01-27-2006 05:57 AM

/dev/st0 : Input/Output error
 
Hi all

I have a tape drive HP Colorado 5GB

I connected it to my linux system having Fedora core 3. boot loader lilo

each time i do a reboot i have to run the command

Code:

modprobe ide-scsi
only then the entry in /dev/sto appears and i am able to access the tape drive

I tried adding the command to rc.local but still no effect

Question 1
********
How do i load this module ide-scsi during boot up? (i dont have a modules.conf in my machine)



Anyway after running that command i am able to use "mt" commands to access the device..

I am able to copy data into the device using the "cpio" command..

but I am not able to copy data into the device using the "tar" command
It gives me input / output error.

I know that cpio and tar uses different formatting. tar used 10240 bytes as block size (default) is what i read from man page.

The block size of the tape drive
when no tape is present is 0 bytes
when tape is present is 512 bytes

So i thought of changing the block size of the tape drive to 0 ( variable block size) using the
Code:

mt setblk 0
or
mt -f /dev/st0 setblk 0

but this command was giving me the same error
/dev/st0 : Input/Output error

I tried writing a program thereby calling ioctl 's to set the block size but i am getting the same error..

Code:


  struct mtop magtape_ops;
  struct mtget magtape_get;
  int fd;
 
 
  /* Open the tape drive, read-only mode */

  fd = open (tape_drive, O_RDONLY);
  if (fd < 0) {
    perror ("open");
    fprintf (stderr, "unable to open tape drive [%s] for reading\n",
            tape_drive);
    fprintf (stderr, "did you mistype the tape drive name?\n");
    return(-1);
  }

  /* Get information about the tape drive */

  memset ((struct mtop *) &magtape_ops, 0, sizeof(struct mtop));
  magtape_ops.mt_op = MTNOP;
  magtape_ops.mt_count = 1;
 
  if (ioctl (fd, MTIOCTOP, &magtape_ops) < 0) {
    perror ("ioctl MTIOCTOP:MTNOP");
    fprintf (stderr, "unable to issue a NOOP command to the tape drive");
    fprintf (stderr, " to clear its command buffer.\n");
    return(-1);
  }

  memset ((struct mtget *) &magtape_get, 0, sizeof(struct mtget));
  if (ioctl (fd, MTIOCGET, &magtape_get) < 0) {
    perror ("ioctl MTIOCGET");
    fprintf (stderr, "unable to get tape drive status.\n");
    return(-1);
  }

  /* is there a tape in the drive? */

  if (GMT_DR_OPEN(magtape_get.mt_gstat)) {
    fprintf (stderr, "error: the tape drive appears to be open\n");
    fprintf (stderr, " and/or a tape is not inserted.  Please insert\n");
    fprintf (stderr, " a tape and close the tape drive door.\n");
    return(-1);
  }

  /* is the tape write protected? */

  if (!GMT_WR_PROT(magtape_get.mt_gstat)) {
    fprintf (stderr, "error: tape loaded in drive appears to be NOT\n");
    fprintf (stderr, " write-protected.  Please unload the tape, enable\n");
    fprintf (stderr, " write protection, and reload the tape.\n");
    return(-1);
  }

  /* is the tape drive online? */

  if (!GMT_ONLINE(magtape_get.mt_gstat)) {
    fprintf (stderr, "error: tape drive is not on-line.  Please place\n");
    fprintf (stderr, " the tape drive on-line and rerun this program.\n");
    return(-1);
  }

  /* rewind the tape drive */

  memset ((struct mtop *) &magtape_ops, 0, sizeof(struct mtop));
  magtape_ops.mt_op = MTREW;
  magtape_ops.mt_count = 1;
 
  if (ioctl (fd, MTIOCTOP, &magtape_ops) < 0) {
    perror ("ioctl MTIOCTOP:MTREW");
    fprintf (stderr, "unable to issue a MTREW command to the tape drive");
    fprintf (stderr, " to rewind the tape.\n");
    return(-1);
  }


  memset ((struct mtop *) &magtape_ops, 0, sizeof(struct mtop));
  magtape_ops.mt_op = MTSETBLK;
  magtape_ops.mt_count = 0;

  if (ioctl (fd, MTIOCTOP, &magtape_ops) < 0)
 {
    perror ("ioctl MTIOCTOP:MTSETBLK");
    fprintf (stderr, "unable to issue a MTSETBLK command to the tape drive");
    fprintf (stderr, " to set the blocksize to variable.\n");
    return(-1);
  }

I am sure that the tape is loaded as i am able to retrieveother data like whether the tape is write protected or not , cpio command works for data backup

Question 2
********
How do i get to set the tape to variable block size?


Since if i am able to set the tape to variable block size i guess everything should work just fine..

Anyone any ideas????? I am not sure this is the correct forum but since it invovled tape drives i put it here

thronh 02-10-2006 12:44 PM

I was runnning into the same problems with my Quantum LTO-2 drive. I could write to the device and see it but couldnt get any data off the device. I ran dmesg and found out the tape device was erroring out. I had to finally replace the drive and the cable.


All times are GMT -5. The time now is 10:24 AM.