Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Getting Started with Ghost scripting (deploying .GHO files)

Created: 19 Nov 2012 • Updated: 19 Nov 2012 | 3 comments

Hello all,

Please forgive the newcomer question, but I am just getting started with writing batch script files that utilize Symantec Ghost and am looking for some simple examples.  I'm running Win7 and Symantec Ghost 11.5.  Basically I am just trying to deploy a give .GHO file to a hard drive.  I am setting up the HD such that it will have multilpe partitions.  But I am doing the creation of it manually.  The deployment is what I am looking to script.  These are my two scripts that I would like to accomplish.  I have written in steps what I would do manually using the Ghost wizard.

#1 - Deploy Disk Image (contains partition table)
1a. Load Symantec Ghost
1b. Local>Disk>From Image
1c. Y:\\Images\PartitionTable.GHO
1d. Select destination drive

Note: Currently I am using a USB-HD device where I can simply plug it into my PC and run Ghost wizard and select the drive to deploy.  Eventually I want to be able to plug a USB stick into a computer, boot from the USB stick (it will run WinPE), and have the batch file deploy the .GHO (which will be stored on a network drive).

#2 - Deploy a Partition Image (obviously done after the Partiition table is deployed)
2a. Load Symantec Ghost
2b. Local>Partition>From Image
2c. Y:\Images\PartitionImage.GHO
2d. Select source partition from image file (Image file will only have one source partition)
2e. Selection destination drive
2f. Select destination partition from Basic drive

Any help would be greatly appreciated.  Thanks.

Discussion Filed Under:

Comments 3 CommentsJump to latest comment

EdT's picture

The Ghost documentation has a full explanation of the switches available and there are also technotes on Symwise that give details of command line switches.

I am not convinced that your deployment of a partition table by use of a drive image is practical or reliable. So much depends on drive geometry and with advanced sector drives requiring partition boundaries to be in specific places, I suspect you are storing up a pile of grief for yourself.

It is so simple to wipe a disk and create a clean partition structure using either GDISK (Symantec) or DISKPART (Microsoft) that you can achieve the required structure in a fraction of the time necessary to deploy a full disk image.

Finally, with USB sticks being so cheap these days, even for the big ones, why not use these to store the image rather than dragging it down over a network. The USB-3 keys are really fast and ideal for imaging as we use them here.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

r2t2's picture

Hello EdT,

Thank you for your reply.  I am looking through the documentation now, seems to be more of a reference guide with the switches available and descriptions.  This is fine, but I was  hoping that I could save myself having to experiment since what I am trying to do seems to be fairly simple.  To be honest I have very limited programming experience (at least writing batch scripts) so this will be a learning opportunity for me.  Do you have any good "getting started" articles in Symwise that would be good for me?  I found this one in particular to be useful and I'll be experimenting with that today.

I understand what you're saying about the deployment of a partition table by use of a drive image.  But in fact I have been doing this for a while now with success, just using the Ghost wizard.  I would like to automate everything using scripts, I believe this is possible using DISKPART.  I will look into this, thank you for the tip.

On the final note, I do need to store the images on a network share because they will be used at a couple different sites.  Furthermore I may have to update the image in the future, and I want to make sure that others are using the current revision.  

Thanks again, I look forward to your reply. 

EdT's picture

Here is a batch file I created a few years ago that would wipe the existing partition structure and create a new one, then deploy and image file from a mapped network drive. As it was found that a USB bootable key would sometimes mount as A: and sometimes as C:, there was logic to check which boot drive was applicable. This may need to change according to your own setup, but the code should at least point you in the right direction:

@ECHO OFF
CLS
 
REM Figure out drive letter of boot process by checking for a specific folder called netboot on the boot media.
if exist a:\netboot\nul goto BOOTA
if exist c:\netboot\nul goto BOOTC
 
ECHO.
ECHO. Unable to determine boot drive letter
ECHO.
ECHO  Program Terminated
goto END
 
:BOOTA
REM This section is run if booting from floppy or a bootable CDROM that mounts as A:
REM Nuke any existing partitions using Symantec GDISK utility
gdisk.exe 1 /del /all /y
 
REM Create C: drive partition using 80% of drive space
gdisk.exe 1 /cre /pri /sz:80p /for /q
 
REM Create D: drive partition using remainder of drive space
gdisk.exe 1 /cre /ext 
 
REM Format D: drive (FAT32 - NTFS conversion will happen at first boot)
gdisk.exe 1 /cre /log /for /q
 
REM Use the first disk partition for the image
ghost.exe -clone,MODE=Prestore,SRC=8215PST3.GHO:1,DST=1:1 -sure
 
REM Set the partition active
gdisk.exe 1 /act /p:1
 
goto FINISH
 
:BOOTC
REM This section is run if booting from a single partition USB device
REM Nuke any existing partitions
gdisk.exe 2 /del /all /y
 
REM Create C: drive partition using 80% of drive space
gdisk.exe 2 /cre /pri /sz:80p /for /q
 
REM Create D: drive partition using remainder of drive space
gdisk.exe 2 /cre /ext 
 
REM Format D: drive (FAT32 - NTFS conversion will happen at first boot)
gdisk.exe 2 /cre /log /for /q
 
REM Use the first disk partition for the image
ghost.exe -clone,MODE=Prestore,SRC=8215PST3.GHO:1,DST=2:1 -sure
 
REM Set the partition active
gdisk.exe 2 /act /p:1
 
goto FINISH
 
 
:FINISH
CLS

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.