Chapter 2: Scripting Workstation Setups


In Brief

In this chapter you'll learn the quickest methods to automate hard disk setups and images. You'll begin learning the secrets of Microsoft FDISK and how to create partitions from the command line. You'll also learn about the scripting limitations of Microsoft FDISK and how to use Free FDISK to script creating and deleting partitions. You'll then learn about different imaging solutions and how to script those packages to create and restore image files.

In order to implement all the examples in this chapter, you'll need to obtain the following files:

  • Free FDISK (http://www.23cc.com/free-fdisk/)

  • PowerQuest Drive Image Pro (http://www.powerquest.com)

  • Norton Ghost (http://www. symantec .com)

Note  

All the DOS- related information in this chapter refers to MS-DOS 7.0.

Warning  

This chapter contains examples on how to partition, format, and image drives . These processes will destroy any data on a disk.

Setting Up a New Hard Drive

For the typical PC, the core component to store user data and system files is the hard drive. A hard drive is like a wallet or purse ”a place you can store your most valuable assets you need to access quickly. When you receive a new hard drive from the manufacturer, it is most likely low-level formatted with no data on it. After you install and configure the hard drive properly, you must partition and format it before you can put any real data on it.

Partitioning

The first step to setting up a new drive is to partition it. Partitioning is the act of dividing up a hard disk into logical sections, which allows one physical drive to appear as multiple drives. When you partition a new drive, a master boot record (MBR) is created on the first physical sector on the hard drive. As a computer initially powers up, it calls the routines stored in the BIOS (Basic Input/Output System). These routines access the system's basic hardware devices (e.g., floppy disk, hard disk, keyboard, video). After these routines are executed, the BIOS reads and executes instructions from the MBR. The MBR contains the partition table, which contains four entries, allowing for various partition types.

Partition Types

When scripting the creation of a partition, you must know the type of partition and its dependencies beforehand. There are three different types of partitions: primary, extended, and logical. Each physical disk can have a maximum of four primary partitions, and only one can be marked active in order to boot. When a primary partition is marked active, it is automatically assigned the drive letter C.

Each primary partition can have only one extended partition. Within an extended partition, you can create up to 24 logical partitions (or 23 logical partitions if you have an active partition on the same drive). Each logical partition is assigned a drive letter (with A and B reserved for floppy drives).

Note  

Only one primary and one extended partition are allowed per physical disk.

Partition Hierarchy

Partition types follow a hierarchy: primary, extended, and logical. They can only be created in this order, and can only be deleted in the opposite order. To begin scripting partitions, you must first familiarize yourself with Microsoft FDISK.

Microsoft FDISK

Microsoft FDISK (Fixed DISK) is a program that an experienced administrator can be all too familiar with. If only I had a nickel for each time I've used Microsoft FDISK, I'd be as rich as these IT salary surveys say I should be. Microsoft FDISK is the most commonly used partitioning utility for hard disks, but despite its popularity, most of its functionality remains highly undocumented. Microsoft FDISK is included in all versions of DOS and Windows. It allows you to create, delete, or view entries in the partition table. If you've ever used Microsoft FDISK to set up a new hard drive manually, you know how time-consuming it can be navigating through menus and waiting for drive integrity checks. Microsoft FDISK provides limited support for scripting from the command line.

Note  

If you want to change entries in the partition table, you must first delete and then recreate them.

Scripting Limitations

Scripting Microsoft FDISK is like going to the casino ”sometimes you win, sometimes you lose, but most of the time you lose. Microsoft FDISK does support many command-line options, but doesn't work well with command redirection input (for example, FDISK < COMMANDS.TXT ). And although the menu-based portion allows for deleting partitions, there's no way to delete partitions from the command line. Just as you do when you're at the casino, you have to know when it's time to collect your chips and move on to the next table. For us, that move is to Free FDISK.

Free FDISK

If Microsoft FDISK were a used car, you could slap a new engine in it and make it run just the way you like. Well, Free FDISK does just that. Free FDISK offers enhanced functionality over Microsoft's FDISK and is the official FDISK of FreeDOS (http://www.freedos.org). Free FDISK provides the same standard Microsoft FDISK interface and commandline options, while adding even more options for batch scripting. After you partition the hard drive, formatting is the last step needed before the drive is ready for data.

Formatting

Formatting is the process of preparing a disk for reading and writing. FORMAT.COM is the executable used to format both floppy and hard disks. When you format a disk, a file allocation table (FAT) and a new root directory are created, allowing you to store and retrieve files. This, in essence, places a file system on a disk for you to use.

The FAT organizes a hard disk into clusters, grouped into 512K sectors. Clusters are the smallest units for storing data and vary in size depending on the file system. Starting with the Windows 95 OSR2 release, Microsoft Windows supports the following two file system types: FAT16 and FAT32. FAT16 is a 16-bit file system that typically stores files in 32K clusters, depending on the partition size . FAT32 is a 32-bit file system that stores files more efficiently in 4K clusters. You should choose a file system that will be compatible with the various operating systems running, provide the greatest security, and be the most efficient.

After the drive is formatted with a file system, the operating system can be loaded and made ready for deployment.

Imaging

Imaging is the process of taking an exact copy of a reference computer's hard drive or partition and storing it to an image file (usually compressed). That image can be stored on any storage medium (hard disk, CDR, DVDR) and restored to multiple computers, creating a standardized software and operating system environment. The basic principle of imaging is very similar to a simple disk copy.

Tools

For an administrator, deploying new PCs can become a large part of your job. With old PCs being retired and new PCs rolling in, finding a way to streamline the imaging process can help cut hours from your work day. And when you're dealing with more than a few PCs, automating the imaging process is not only helpful, but essential. Imaging tools such as PowerQuest's Drive Image Pro or Norton Ghost make it easy for an administrator to re-image multiple hard drives in a matter of minutes.

PowerQuest's Drive Image Pro

Drive Image Pro (see Figure 2.1) is an imaging and software distribution solution package from PowerQuest Corporation (http://www.powerquest.com). In addition to running in standard interactive mode, this product can also be run in batch mode, allowing a script file to send commands to the main program executable (PQDI.EXE).

click to expand
Figure 2.1: PowerQuest's Drive Image Pro.

Drive Image Pro uses a proprietary scripting language and includes many commands and switches to image your hard disk. The most commonly used commands are:

  • SELECT DRIVE number ”Selects a drive according to the number specified

  • SELECT PARTITION x ”Selects a partition where x is:

    • A partition number

    • A drive letter

    • A disk label

  • ALL ”Selects all partitions

  • DELETE ”Deletes the partitions specified in the last SELECT command

  • DELETE x ”Deletes partitions within the currently selected drive where x is:

    • ALL ”To delete all partitions

    • EXTENDED ”To delete the extended partition (if there are no logical drives)

  • STORE ”Stores selected partitions to an image file with no compression

  • STORE WITH COMPRESSION x ”Stores selected partitions to an image file with compression where x is:

    • OFF ”Stores images with no compression

    • LOW ”Stores images with low compression (about 40%)

    • HIGH ”Stores images with high compression (about 50%)

  • RESIZE IMAGE x ”Resizes the partitions being restored where x is:

    • NO ”Turns resizing off

    • A size in megabytes (for example, 1000)

    • PROPORTIONAL ”Resizes partitions proportionally

    • MAX ”Resizes partitions to the maximum size possible

    • MOST SPACE ”Resizes partitions leaving most free space

  • RESTORE ”Restores selected partitions

  • REBOOT ”Immediately reboots the computer

Tip  

To see a brief description of all the available switches, type "PQDI /?" at the command prompt.

Symantec's Norton Ghost

Norton Ghost from Symantec (http://www.symantec.com) is the imaging package most commonly used by IT (Information Technology) professionals. In addition to imaging, Norton Ghost includes cloning functionality, which allows disk-to-disk/partition-to-partition copying. Unlike Drive Image Pro, which mainly uses script files for automation, Norton Ghost uses only command-line switches.

The -CLONE switch is the main switch used to create and restore Norton Ghost image files. The basic syntax of the -CLONE switch is:

 GHOST -CLONE,MODE=  m  ,SRC=  s  ,DST=  d  

Here, m is any mode parameter, s is any source parameter, and d is any destination parameter. The MODE parameters are:

  • COPY ”Copies one disk to another

  • LOAD ”Restores an image to disk

  • DUMP ”Creates an image from disk

  • PCOPY ”Copies one partition to another

  • PLOAD ”Restores an image to partition

  • PDUMP ”Creates an image from partition

The rest of the parameters are dependent on the selected MODE parameter.

The SRC parameters are:

  • Drive ”Specifies a drive number ( COPY/DUMP )

  • File ”Specifies a source image file ( LOAD )

  • Drive:partition ”Specifies a drive and partition number ( PCOPY/PDUMP )

  • @ MT x ”Specifies a tape drive where x is the device number ( LOAD )

The DST parameters are:

  • Drive ”Specifies a drive number ( COPY/LOAD )

  • File ”Specifies a source image file ( DUMP/PDUMP )

  • Drive:partition ”Specifies a drive and partition number ( PCOPY/PLOAD )

  • @ MT x ”Specifies a tape drive where x is the device number ( DUMP )

Note  

Inserting spaces between the CLONE parameters will cause script errors.




Windows Admin Scripting Little Black Book
Windows Admin Scripting Little Black Book (Little Black Books (Paraglyph Press))
ISBN: 1933097108
EAN: 2147483647
Year: 2004
Pages: 89

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net