SUMMARY: faster full restore?

From: Rich Schultz (rich@ccrwest.org)
Date: Wed Feb 17 1993 - 04:41:37 CST


Original request:

> I have heard that Backup Copilot includes a version of restore that can do
> a full restore faster than the stock restore, by telling the kernel not to
> do synchronous writes of filesystem metadata. I don't have Backup
> Copilot, but I am running 4.1.3, which includes all the kernel support for
> Backup Copilot, so in theory I should be able to turn on this feature with
> some system call and save myself some time restoring a large disk. Does
> anyone know how?

Answer:

Yes, you can do it. Several people, including the original author, sent me a
program to turn the feature on and off. It was previously posted to
comp.sys.sun.admin, apparently when my back was turned.

Many thanks to:

    Casper Dik <casper@fwi.uva.nl>
    Postmaster <Piete.Brooks@cl.cam.ac.uk>
    Christopher Davis <ckd@eff.org>
    Peter Gray <pdg@cs.uow.edu.au>

Rich Schultz
rich@ccrwest.org

---------------------------------------------------------------------
/*
 * Written by Peter Gray, University of Wollongong
 * pdg@cs.uow.edu.au
 *
 * This programs turns on/off delayed I/O on a filesystem.
 *
 * Usage: fastfs filesystem fast|slow|status
 *
 * Note that it is intended for use with restore(8)
 * to speed up full filesystem restores. Remember
 * that if a filesystem is running with delayed I/O
 * enabled when the system crashes it can result in
 * the fsck being unable to "fix" the filesystem on reboot
 * without manual intervention.
 *
 * Typical use is
 *
 * fastfs /home fast
 * cd /home; restore rf /dev/rst5
 * fastfs /home slow
 *
 * The above gives about a 500% increase in the speed of
 * the restore.
 *
 * Its also good for /tmp giving most of the benefits of tmpfs
 * without the problems.
 *
 * In rc.local
 *
 * fastfs /tmp fast
 *
 * but you may need to add fsck -y /tmp into /etc/rc.boot
 * before the real fsck to ensure the machine always boots
 * (I have not done this yet).
*/

#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <sys/filio.h>
#include <errno.h>
#include <string.h>

extern char *sys_errlist[];

int
main(argc, argv)
int argc;
char **argv;
{
        int fd;
        int flag;
        
        if (geteuid() != 0)
        {
                fprintf(stderr,"%s: Must run as root.\n", argv[0]);
                exit(1);
        }

        if (argc != 3)
        {
                fprintf(stderr,"Usage: %s path {fast|slow|status}\n",argv[0]);
                exit(2);
        }
        
        if ((fd = open(argv[1], O_RDONLY)) < 0)
        {
                fprintf(stderr,"%s: Unable to open \"%s\"\n%s\n", argv[0], argv[1], sys_errlist[errno]);
                exit(3);
        }
        
        if (!strcasecmp(argv[2], "status"))
        {
                if (ioctl(fd, FIODIOS, &flag) != 0)
                {
                        fprintf(stderr,"%s: ioctl failed%s\n", argv[0], sys_errlist[errno]);
                        exit(4);
                }
                if (flag == 0) printf("%s is slow.\n", argv[1]);
                else printf("%s is fast\n", argv[1]);
                exit(0);
        }
        
        flag = (strcasecmp(argv[2], "fast") == 0) ? 1 : 0;
        
        if (ioctl(fd, FIODIO, &flag) != 0)
        {
                fprintf(stderr,"%s: ioctl failed\n%s\n", argv[0], sys_errlist[errno]);
                exit(5);
        }
        
        printf("%s is now %s\n",argv[1], flag ? "fast" : "slow");
        exit(0);

}



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:07:29 CDT