zwei Partitionen

fischerr
Beiträge: 19
Registriert: 29 Jun 2009, 10:52

zwei Partitionen

Beitrag von fischerr »

Hallo
Ich möchte das zwei NTFS Partitionen bei der Windows XP Installation erstellt werden.
Ich habe auch schon unter
viewtopic.php?f=7&t=29&p=1289 -> von mro-ncd » 16 Okt 2008, 15:03<-
ein Skript namens „winxppro.py“ entdeckt.
Nun weis ich aber nicht wo ich das Skript Speichern soll, und wie ich es Starte, b.z.w. wo ich es einbinde.
Gruß Robert
.
Gruß Robert
Benutzeravatar
d.oertel
uib-Team
Beiträge: 3327
Registriert: 04 Jun 2008, 14:27

Re: zwei Partitionen

Beitrag von d.oertel »

Hi,

das Installationsscript für die OS-Installation heisst inzwischen einheitlich setup.py.
z.b
/opt/pcbin/install/winxppro/setup.py

gruss
detlef oertel


Vielen Dank für die Nutzung von opsi. Im Forum ist unser Support begrenzt.

Für den professionellen Einsatz und individuelle Beratung empfehlen wir einen Support-Vertrag und eine Schulung.
Gerne informieren wir Sie zu unserem Angebot.

uib GmbH
Telefon: +49 6131 27561 0
E-Mail: sales@uib.de


fischerr
Beiträge: 19
Registriert: 29 Jun 2009, 10:52

Re: zwei Partitionen

Beitrag von fischerr »

Hallo
erst mal danke für die schnelle Antwort! Nun habe ich das Skript aus den Link denn ich geschickte habe komplett übernommen, und meine setup.py komplett überschrieben (ausgetauscht).
Nun Partitioniert er anscheint 2 Partitionen, aber die Windows Installation bleibt bei
"Windows XP Professional Setup"
stehen und wartet auf manuelle Eingaben. Wenn ich Enter drücke verlangt er nach der Windows XP CD.



Hier meine orginal setup.py (wie von VMWare Image v3.3.1 installiert)
-------------------------------------------------------
#
# This script requires opsi >= 3.3, opsi-linux-bootimage version >= 20090224
#
if not bootimageVersion or (int(bootimageVersion) < 20090224):
raise Exception("This product requires opsi-linux-bootimage version >= 20090224")

target = '/mnt/hd'
source = DEPOT_MOUNT + '/install/' + productId
srcDriversDir = source + '/drivers'
dstDriversDir = target + '/drv'

# Do hardware inventory
logger.notice("Fetching opsi hw audit configuration")
config = backend.getOpsiHWAuditConf()

logger.notice("Running hardware inventory")
hardware = hardwareInventory(config = config)

logger.notice("Sending hardware information to service")
backend.setHardwareInformation(fqdn, hardware)

# Get harddisks
disks = getHarddisks()

# Use first Harddisk
disk = disks[0]
scriptMessageSubject.setMessage("Verwende Festplatte %s (%s MB)." % (disk.device, round(disk.size/1024/1024)) )

# Check disk size
if (disk.size < 6000*1024*1024):
# Disk smaller than 6000 MB => give up
raise Exception("Die Festplatte ist zu klein")

# Get current partitions
partitions = disk.getPartitions()

if not partitions:
# No partition found on harddisk
scriptMessageSubject.setMessage("Keine Partitionen auf %s gefunden" % disk.device)

# Create new partitiontable
disk.deletePartitionTable()

# Partition table deleted => set all netboot products to not_installed
for pid in backend.getInstallableNetBootProductIds_list(fqdn):
if (pid == productId):
continue
backend.setProductInstallationStatus(pid, fqdn, 'not_installed')

# Create fat32 partition
disk.createPartition(start="0", end="100%", fs="fat32", boot=True)

# Create fat32 filesystem on partition
disk.createFilesystem(partition=1, fs="fat32")

# Write Master Boot Record
disk.writeMasterBootRecord(system='winxp')

# Write Partition Boot Record
disk.writePartitionBootRecord(partition=1, fsType='fat32nt')

# Mount partition
disk.mountPartition(partition=1, mountpoint=target)

# Copy Windows installation files
i386Dir = productProperties.get('i386_dir')
if not i386Dir: i386Dir = 'i386'
copy(source + '/' + i386Dir + '/*', target + '/$win_nt$.~ls/i386/')
copy(target + '/$win_nt$.~ls/i386/*', target + '/$win_nt$.~bt/')
copy(target + '/$win_nt$.~ls/i386/ntldr', target)
copy(target + '/$win_nt$.~ls/i386/ntdetect.com', target)
if os.path.exists(target + '/$win_nt$.~ls/i386/bootfont.bin'):
copy(target + '/$win_nt$.~ls/i386/bootfont.bin', target)
copy(target + '/$win_nt$.~ls/i386/txtsetup.sif', target)
copy(target + '/$win_nt$.~ls/i386/setupldr.bin', target + '/$ldr$')


if (productProperties.get('store_i386') == 'true'):
copy(target + '/$win_nt$.~ls/i386', target + '/')

# Copy r2 files
if os.path.exists(source + '/CMPNENTS'):
copy(source + '/CMPNENTS', target + '/')

# Copy x64 files
if os.path.exists(source + '/AMD64'):
copy(source + '/AMD64/*', target + '/$win_nt$.~ls/AMD64/')
copy(target + '/$win_nt$.~ls/AMD64/*', target + '/$win_nt$.~bt/')
copy(target + '/$win_nt$.~ls/AMD64/txtsetup.sif', target)

# Copy oem and opsi files
copy(source + '/opsi', target + '/')
os.renames(target + '/opsi/$oem$', target + '/$')
copy(source + '/custom/$oem$/*', target + '/$/')
copy(source + '/custom/unattend.txt', target + '/$win_nt$.~bt/winnt.sif')
for f in os.listdir(source + '/custom/postinst.d'):
if not os.path.exists(target + '/opsi/postinst.d/' + f):
copy(source + '/custom/postinst.d/' + f, target + '/opsi/postinst.d/')

# for preloginloader 3.3
if os.path.exists(DEPOT_MOUNT + '/install/preloginloader/files/opsi/utils/prelogin.exe'):
# Copy opsi-preloginloader
copy(DEPOT_MOUNT + '/install/preloginloader/files/*', target)
# Copy installation script
copy(target + '/opsi/setdepot.cmd', target + '/opsi/postinst.d/50_preloginloader.cmd')

# for preloginloader 3.4
elif os.path.exists(DEPOT_MOUNT + '/install/preloginloader/files/opsi/dist/opsiclientd.exe'):
# Copy opsi-preloginloader
copy(DEPOT_MOUNT + '/install/preloginloader', target + '/opsi/')
# Copy sysconf.ini to preloginloader config dir
copy(SYSCONF_INI, target + '/opsi/preloginloader/files/opsi/cfg')
# Copy preloginloader postinst scripts
copy(target + '/opsi/preloginloader/files/opsi/postinst.d/*', target + '/opsi/postinst.d/')

else:
raise Exception("Opsi preloginloader not found")

# Copy sysconf.ini to C:\opsi\cfg
copy (SYSCONF_INI, target + '/opsi/cfg')

# Store master boot record
f = open(disk.device, 'rb')
mbr = f.read(512)
f.close()
f = open(target + '/opsi/opsi.mbr', 'wb')
f.write(mbr)
f.close()

# Integrate drivers
if os.path.exists(srcDriversDir):
scriptMessageSubject.setMessage("Treiber-Verzeichnis '%s' gefunden, starte Treiberintegration" % srcDriversDir)

integrateHardwareDrivers(srcDriversDir, dstDriversDir, hardware, messageObserver = scriptMessageObserver)
integrateAdditionalDrivers(srcDriversDir + '/drivers/additional', dstDriversDir, productProperties.get('additional_drivers',''), messageObserver = scriptMessageObserver)
integrateTextmodeDrivers(dstDriversDir, target, hardware, target + '/$win_nt$.~bt/winnt.sif', messageObserver = scriptMessageObserver)
oemPnpDriversPath = getOemPnpDriversPath(dstDriversDir, target, ';')

pi = open(PATCHA_IN, 'a')
print >> pi, "oempnpdriverspath=%s" % oemPnpDriversPath
pi.close()

# Create bootsect.dat
f = open(disk.getPartition(1)['device'], 'rb')
pbr = f.read(512)
f.close()
pbr = pbr.replace('NTLDR', '$LDR$')
f = open(target + '/$win_nt$.~bt/bootsect.dat', 'wb')
f.write(pbr)
f.close()

# Installation config for preloginloader 3.4
patchtarget = target + '/opsi/preloginloader/files/opsi/cfg/config.ini'
# Installation config preloginloader 3.3
if os.path.exists(target + '/opsi/cfg/pxecfg.ini'):
patchtarget = target + '/opsi/cfg/pxecfg.ini'

# Patch unattended.txt
for i in ( target + '/$win_nt$.~bt/winnt.sif', patchtarget ):
execute("/usr/local/bin/patcha '%s'" % i)
execute("/usr/local/bin/patcha -f %s '%s'" % (PATCHA_IN, i))

# Write boot.ini
f = open(target + '/boot.ini', 'w')
print >> f, '[Boot Loader]'
print >> f, 'Timeout=1'
print >> f, 'Default=C:\$WIN_NT$.~BT\BOOTSECT.DAT'
print >> f, '[Operating Systems]'
print >> f, 'C:\$WIN_NT$.~BT\BOOTSECT.DAT = "OPSI Windows Installation"'
f.close()

# Umount partition
disk.umountPartition(partition=1)

# Reboot
reboot()
--------------------------------------------------------------
.
Gruß Robert
Benutzeravatar
d.oertel
uib-Team
Beiträge: 3327
Registriert: 04 Jun 2008, 14:27

Re: zwei Partitionen

Beitrag von d.oertel »

Hi,

natürlich kann man das Script nicht einfach austauschen.
Sondern das eine zur Vorlage nehmen um das andere anzupassen.
Wir machen das gerne für Euch im Rahmen eines Supportvertrages.

gruss
detlef oertel


Vielen Dank für die Nutzung von opsi. Im Forum ist unser Support begrenzt.

Für den professionellen Einsatz und individuelle Beratung empfehlen wir einen Support-Vertrag und eine Schulung.
Gerne informieren wir Sie zu unserem Angebot.

uib GmbH
Telefon: +49 6131 27561 0
E-Mail: sales@uib.de


fischerr
Beiträge: 19
Registriert: 29 Jun 2009, 10:52

Re: zwei Partitionen

Beitrag von fischerr »

Hallo
Ja ich probiere gerade OPSI Privat aus, um evtl. es im Geschäft einzusetzen. Privat werde ich erst mal kein Geld einsetzten. Trozdem erst mal DANKE.
Gruß Robert
.
Gruß Robert
fischerr
Beiträge: 19
Registriert: 29 Jun 2009, 10:52

Re: zwei Partitionen

Beitrag von fischerr »

Habe mir nun die setup.py selbst gebaut. Damit in V3.3.1 winxppro zwei Partitionen erstellt werden.
War ganz einfach. ich stells mal für andere ein:

/opt/pcbin/install/winxppro/setup.py:
---------------------------------------------------------------------
#
# This script requires opsi >= 3.3, opsi-linux-bootimage version >= 20090224
#
if not bootimageVersion or (int(bootimageVersion) < 20090224):
raise Exception("This product requires opsi-linux-bootimage version >= 20090224")

target = '/mnt/hd'
source = DEPOT_MOUNT + '/install/' + productId
srcDriversDir = source + '/drivers'
dstDriversDir = target + '/drv'

# Do hardware inventory
logger.notice("Fetching opsi hw audit configuration")
config = backend.getOpsiHWAuditConf()

logger.notice("Running hardware inventory")
hardware = hardwareInventory(config = config)

logger.notice("Sending hardware information to service")
backend.setHardwareInformation(fqdn, hardware)

###################################################################################
### Modifikation
###################################################################################

# Get first harddisk
KB=1000
MB=1000*1000
GB=1000*1000*1000

disks = getHarddisks()
disk = disks[0]
disksize = disk.size - KB
partitions = disk.getPartitions()

# Disksize <= 2GB
# => Platte zu klein => exit
if (disksize <= 2*GB):
raise Exception("Die Festplatte ist kleiner als 2GB!\n")

# 2GB < Disksize <= 6GB
# => erstelle 1 Partition ueber die gesamte Platte elif (2*GB < disksize) and (disksize <= 6*GB):
if not partitions:
ui.getMessageBox().addText("Es wird eine Partition ueber die gesamte Platte erstellt!\n")
disk.deletePartitionTable()
disk.createPartition(start="0%", end="100%", fs="fat32", boot=True)
disk.createFilesystem(partition=1, fs="fat32")
else:
partition = partitions[0]
partend = str(int((partition['end'] / (1024*1024)) - 1)) + "M"
ui.getMessageBox().addText('Ende Partition 1: %s\n' % (partend))
ui.getMessageBox().addText("Partition 1 wird neu erstellt\n")
disk.deletePartition(partition=1)
disk.createPartition(start="0%", end=partend, fs="fat32", boot=True)
disk.createFilesystem(partition=1, fs="fat32")

# 6GB < Disksize <= 15GB
# => 2 Partitionen: 1. 6GB, 2. Rest
elif (6*GB < disksize) and (disksize <= 15*GB):
if not partitions:
ui.getMessageBox().addText("Es werden zwei Partition erstellt!\n1. Partition: 6GB, 2. Partition: Rest\n")
disk.deletePartitionTable()
disk.createPartition(start="0M", end="6000M", fs="fat32", boot=True)
disk.createFilesystem(partition=1, fs="fat32")
disk.createPartition(start="6001M", end="100%", fs="ntfs", boot=False)
else:
partition = partitions[0]
partend = str(int((partition['end'] / (1024*1024)) - 1)) + "M"
ui.getMessageBox().addText('Ende Partition 1: %s\n' % (partend))
ui.getMessageBox().addText("Partition 1 wird neu erstellt\n")
disk.deletePartition(partition=1)
disk.createPartition(start="0%", end=partend, fs="fat32", boot=True)
disk.createFilesystem(partition=1, fs="fat32")

# Disksize > 15GB
# 2 Partitionen: 1. 40%, 2. 60%
else:
if not partitions:
ui.getMessageBox().addText("Es werden zwei Partition erstellt!\n1. Partition: 40%, 2. Partition: 60%\n")
disk.deletePartitionTable()
disk.createPartition(start="0%", end="40%", fs="fat32", boot=True)
disk.createFilesystem(partition=1, fs="fat32")
disk.createPartition(start="41%", end="100%", fs="ntfs")
disk.createFilesystem(partition=2, fs="ntfs")
else:
partition = partitions[0]
partend = str(int((partition['end'] / (1024*1024)) - 1)) + "M"
disk.deletePartitionTable()
ui.getMessageBox().addText('Ende Partition 1: %s\n' % (partend))
ui.getMessageBox().addText("Partition 1 wird neu erstellt\n")
ui.getMessageBox().addText("\nSchritt 2: Erstelle neue Partition\n")
disk.createPartition(start="0%", end="40%", fs="fat32", boot=True)
ui.getMessageBox().addText("\nSchritt 3: Formatiere Partition\n")
disk.createFilesystem(partition=1, fs="fat32")
ui.getMessageBox().addText("\nSchritt 5: Erstelle neue Partition\n")
disk.createPartition(start="41%", end="100%", fs="ntfs")
ui.getMessageBox().addText("\nSchritt 5: Formatiere Partition\n")
disk.createFilesystem(partition=2, fs="ntfs")


###################################################################################
### Modifikation ende
###################################################################################

# Write Master Boot Record
disk.writeMasterBootRecord(system='winxp')

# Write Partition Boot Record
disk.writePartitionBootRecord(partition=1, fsType='fat32nt')

# Mount partition
disk.mountPartition(partition=1, mountpoint=target)

# Copy Windows installation files
i386Dir = productProperties.get('i386_dir')
if not i386Dir: i386Dir = 'i386'
copy(source + '/' + i386Dir + '/*', target + '/$win_nt$.~ls/i386/')
copy(target + '/$win_nt$.~ls/i386/*', target + '/$win_nt$.~bt/')
copy(target + '/$win_nt$.~ls/i386/ntldr', target)
copy(target + '/$win_nt$.~ls/i386/ntdetect.com', target)
if os.path.exists(target + '/$win_nt$.~ls/i386/bootfont.bin'):
copy(target + '/$win_nt$.~ls/i386/bootfont.bin', target)
copy(target + '/$win_nt$.~ls/i386/txtsetup.sif', target)
copy(target + '/$win_nt$.~ls/i386/setupldr.bin', target + '/$ldr$')


if (productProperties.get('store_i386') == 'true'):
copy(target + '/$win_nt$.~ls/i386', target + '/')

# Copy r2 files
if os.path.exists(source + '/CMPNENTS'):
copy(source + '/CMPNENTS', target + '/')

# Copy x64 files
if os.path.exists(source + '/AMD64'):
copy(source + '/AMD64/*', target + '/$win_nt$.~ls/AMD64/')
copy(target + '/$win_nt$.~ls/AMD64/*', target + '/$win_nt$.~bt/')
copy(target + '/$win_nt$.~ls/AMD64/txtsetup.sif', target)

# Copy oem and opsi files
copy(source + '/opsi', target + '/')
os.renames(target + '/opsi/$oem$', target + '/$')
copy(source + '/custom/$oem$/*', target + '/$/')
copy(source + '/custom/unattend.txt', target + '/$win_nt$.~bt/winnt.sif')
for f in os.listdir(source + '/custom/postinst.d'):
if not os.path.exists(target + '/opsi/postinst.d/' + f):
copy(source + '/custom/postinst.d/' + f, target + '/opsi/postinst.d/')

# for preloginloader 3.3
if os.path.exists(DEPOT_MOUNT + '/install/preloginloader/files/opsi/utils/prelogin.exe'):
# Copy opsi-preloginloader
copy(DEPOT_MOUNT + '/install/preloginloader/files/*', target)
# Copy installation script
copy(target + '/opsi/setdepot.cmd', target + '/opsi/postinst.d/50_preloginloader.cmd')

# for preloginloader 3.4
elif os.path.exists(DEPOT_MOUNT + '/install/preloginloader/files/opsi/dist/opsiclientd.exe'):
# Copy opsi-preloginloader
copy(DEPOT_MOUNT + '/install/preloginloader', target + '/opsi/')
# Copy sysconf.ini to preloginloader config dir
copy(SYSCONF_INI, target + '/opsi/preloginloader/files/opsi/cfg')
# Copy preloginloader postinst scripts
copy(target + '/opsi/preloginloader/files/opsi/postinst.d/*', target + '/opsi/postinst.d/')

else:
raise Exception("Opsi preloginloader not found")

# Copy sysconf.ini to C:\opsi\cfg
copy (SYSCONF_INI, target + '/opsi/cfg')

# Store master boot record
f = open(disk.device, 'rb')
mbr = f.read(512)
f.close()
f = open(target + '/opsi/opsi.mbr', 'wb')
f.write(mbr)
f.close()

# Integrate drivers
if os.path.exists(srcDriversDir):
scriptMessageSubject.setMessage("Treiber-Verzeichnis '%s' gefunden, starte Treiberintegration" % srcDriversDir)

integrateHardwareDrivers(srcDriversDir, dstDriversDir, hardware, messageObserver = scriptMessageObserver)
integrateAdditionalDrivers(srcDriversDir + '/drivers/additional', dstDriversDir, productProperties.get('additional_drivers',''), messageObserver = scriptMessageObserver)
integrateTextmodeDrivers(dstDriversDir, target, hardware, target + '/$win_nt$.~bt/winnt.sif', messageObserver = scriptMessageObserver)
oemPnpDriversPath = getOemPnpDriversPath(dstDriversDir, target, ';')

pi = open(PATCHA_IN, 'a')
print >> pi, "oempnpdriverspath=%s" % oemPnpDriversPath
pi.close()

# Create bootsect.dat
f = open(disk.getPartition(1)['device'], 'rb')
pbr = f.read(512)
f.close()
pbr = pbr.replace('NTLDR', '$LDR$')
f = open(target + '/$win_nt$.~bt/bootsect.dat', 'wb')
f.write(pbr)
f.close()

# Installation config for preloginloader 3.4
patchtarget = target + '/opsi/preloginloader/files/opsi/cfg/config.ini'
# Installation config preloginloader 3.3
if os.path.exists(target + '/opsi/cfg/pxecfg.ini'):
patchtarget = target + '/opsi/cfg/pxecfg.ini'

# Patch unattended.txt
for i in ( target + '/$win_nt$.~bt/winnt.sif', patchtarget ):
execute("/usr/local/bin/patcha '%s'" % i)
execute("/usr/local/bin/patcha -f %s '%s'" % (PATCHA_IN, i))

# Write boot.ini
f = open(target + '/boot.ini', 'w')
print >> f, '[Boot Loader]'
print >> f, 'Timeout=1'
print >> f, 'Default=C:\$WIN_NT$.~BT\BOOTSECT.DAT'
print >> f, '[Operating Systems]'
print >> f, 'C:\$WIN_NT$.~BT\BOOTSECT.DAT = "OPSI Windows Installation"'
f.close()

# Umount partition
disk.umountPartition(partition=1)

# Reboot
reboot()

-----------------------------------------------------------------------------------
.
Gruß Robert
thomask3006
Beiträge: 67
Registriert: 06 Jul 2008, 10:10

Re: zwei Partitionen

Beitrag von thomask3006 »

Super

Danke
fischerr
Beiträge: 19
Registriert: 29 Jun 2009, 10:52

Re: zwei Partitionen

Beitrag von fischerr »

Hallo
Habe setup.py (v3.3.1) nochmals angepasst, und getestet.
min. HDD Größe 4GB

Festplatte1 | Größe C:\ | Größe D:\
----------------------------------------------------
4-8GB HDD | 100% C:\ | keine D:\
8-15GB HDD | 6GB C:\ | Rest D:\
15-80GB HDD | 40% C:\ | 60% D:\
ab 81GB HDD | 32GB C:\ | Rest D:\

Code: Alles auswählen

#
# This script requires opsi >= 3.3, opsi-linux-bootimage version >= 20090224
# mail@robert-fischer.de 15.07.2009
#
if not bootimageVersion or (int(bootimageVersion) < 20090224):
	raise Exception("This product requires opsi-linux-bootimage version >= 20090224")

target = '/mnt/hd'
source = DEPOT_MOUNT + '/install/' + productId
srcDriversDir = source + '/drivers'
dstDriversDir = target + '/drv'

# Do hardware inventory
logger.notice("Fetching opsi hw audit configuration")
config = backend.getOpsiHWAuditConf()

logger.notice("Running hardware inventory")
hardware = hardwareInventory(config = config)

logger.notice("Sending hardware information to service")
backend.setHardwareInformation(fqdn, hardware)

###################################################################################
### Modifikation
###################################################################################

# Get first harddisk
KB=1000
MB=1000*1000
GB=1000*1000*1000

disks = getHarddisks()
disk = disks[0]
disksize = disk.size - KB
partitions = disk.getPartitions()

# Disksize <= 4GB
# => Platte zu klein => exit
if (disksize <= 4*GB):
  raise Exception("Die Festplatte ist kleiner als 4GB!\n")

  # 4GB < Disksize <= 8GB
  # => erstelle 1 Partition ueber die gesamte Platte elif (4*GB < disksize) and (disksize <= 6*GB):
  if not partitions:
    ui.getMessageBox().addText("Es wird eine Partition ueber die gesamte Platte erstellt!\n")
    disk.deletePartitionTable()
    disk.createPartition(start="0%", end="100%", fs="fat32", boot=True)
    disk.createFilesystem(partition=1, fs="fat32")
  else:
    partition = partitions[0]
    partend = str(int((partition['end'] / (1024*1024)) - 1)) + "M"
    ui.getMessageBox().addText('Ende Partition 1: %s\n' % (partend))
    ui.getMessageBox().addText("Partition 1 wird neu erstellt\n") 
    disk.deletePartition(partition=1)
    disk.createPartition(start="0%", end=partend, fs="fat32", boot=True)
    disk.createFilesystem(partition=1, fs="fat32")


# 6GB < Disksize <= 15GB
# => 2 Partitionen: 1. 6GB, 2. Rest
elif (8*GB < disksize) and (disksize <= 15*GB):
  if not partitions:
    ui.getMessageBox().addText("Es werden zwei Partition erstellt!\n1. Partition: 6GB, 2. Partition: Rest\n") 
    disk.deletePartitionTable()
    disk.createPartition(start="0M", end="6000M", fs="fat32", boot=True)
    disk.createFilesystem(partition=1, fs="fat32") 
    disk.createPartition(start="6001M", end="100%", fs="ntfs")
    disk.createFilesystem(partition=2, fs="ntfs")
    
  else:
    partition = partitions[0]
    partend = str(int((partition['end'] / (1024*1024)) - 1)) + "M"
    disk.deletePartitionTable()
    ui.getMessageBox().addText('Ende Partition 1: %s\n' % (partend))
    ui.getMessageBox().addText("Partition 1 wird neu erstellt\n")   
    ui.getMessageBox().addText("\nSchritt 2: Erstelle neue Partition\n") 
    disk.createPartition(start="0M", end="6000M", fs="fat32", boot=True)
    ui.getMessageBox().addText("\nSchritt 3: Formatiere Partition\n") 
    disk.createFilesystem(partition=1, fs="fat32")
    ui.getMessageBox().addText("\nSchritt 5: Erstelle neue Partition\n") 
    disk.createPartition(start="6001M", end="100%", fs="ntfs")
    ui.getMessageBox().addText("\nSchritt 5: Formatiere Partition\n") 
    disk.createFilesystem(partition=2, fs="ntfs")


# 30GB < Disksize <= 80GB
# 2 Partitionen: 1. 40%, 2. 60%
elif (30*GB < disksize) and (disksize <= 80*GB):
  if not partitions:
    ui.getMessageBox().addText("Es werden zwei Partition erstellt!\n1. Partition: 6GB, 2. Partition: Rest\n") 
    disk.deletePartitionTable()
    disk.createPartition(start="0%", end="40%", fs="fat32", boot=True)
    disk.createFilesystem(partition=1, fs="fat32") 
    disk.createPartition(start="40,1%", end="100%", fs="ntfs")
    disk.createFilesystem(partition=2, fs="ntfs")
    
  else:
    partition = partitions[0]
    partend = str(int((partition['end'] / (1024*1024)) - 1)) + "M"
    disk.deletePartitionTable()
    ui.getMessageBox().addText('Ende Partition 1: %s\n' % (partend))
    ui.getMessageBox().addText("Partition 1 wird neu erstellt\n")   
    ui.getMessageBox().addText("\nSchritt 2: Erstelle neue Partition\n") 
    disk.createPartition(start="0%", end="40%", fs="fat32", boot=True)
    ui.getMessageBox().addText("\nSchritt 3: Formatiere Partition\n") 
    disk.createFilesystem(partition=1, fs="fat32")
    ui.getMessageBox().addText("\nSchritt 5: Erstelle neue Partition\n") 
    disk.createPartition(start="40,1%", end="100%", fs="ntfs")
    ui.getMessageBox().addText("\nSchritt 5: Formatiere Partition\n") 
    disk.createFilesystem(partition=2, fs="ntfs")


# Disksize > 81GB
# 2 Partitionen: 1. 40%, 2. 60%
else:
  if not partitions:
    ui.getMessageBox().addText("Es werden zwei Partition erstellt!\n1. Partition: 40%, 2. Partition: 60%\n") 
    disk.deletePartitionTable()
    disk.createPartition(start="0%", end="32000M", fs="fat32", boot=True)
    disk.createFilesystem(partition=1, fs="fat32") 
    disk.createPartition(start="32001M", end="100%", fs="ntfs")
    disk.createFilesystem(partition=2, fs="ntfs")
  else:
    partition = partitions[0]
    partend = str(int((partition['end'] / (1024*1024)) - 1)) + "M"
    disk.deletePartitionTable()
    ui.getMessageBox().addText('Ende Partition 1: %s\n' % (partend))
    ui.getMessageBox().addText("Partition 1 wird neu erstellt\n")   
    ui.getMessageBox().addText("\nSchritt 2: Erstelle neue Partition\n") 
    disk.createPartition(start="0%", end="32000M", fs="fat32", boot=True)
    ui.getMessageBox().addText("\nSchritt 3: Formatiere Partition\n") 
    disk.createFilesystem(partition=1, fs="fat32")
    ui.getMessageBox().addText("\nSchritt 5: Erstelle neue Partition\n") 
    disk.createPartition(start="32001M", end="100%", fs="ntfs")
    ui.getMessageBox().addText("\nSchritt 5: Formatiere Partition\n") 
    disk.createFilesystem(partition=2, fs="ntfs")
   

###################################################################################
### Modifikation ende
###################################################################################

# Write Master Boot Record
disk.writeMasterBootRecord(system='winxp')

# Write Partition Boot Record
disk.writePartitionBootRecord(partition=1, fsType='fat32nt')

# Mount partition
disk.mountPartition(partition=1, mountpoint=target)

# Copy Windows installation files
i386Dir = productProperties.get('i386_dir')
if not i386Dir: i386Dir = 'i386'
copy(source + '/' + i386Dir + '/*', target + '/$win_nt$.~ls/i386/')
copy(target + '/$win_nt$.~ls/i386/*', target + '/$win_nt$.~bt/')
copy(target + '/$win_nt$.~ls/i386/ntldr', target)
copy(target + '/$win_nt$.~ls/i386/ntdetect.com', target)
if os.path.exists(target + '/$win_nt$.~ls/i386/bootfont.bin'):
	copy(target + '/$win_nt$.~ls/i386/bootfont.bin', target)
copy(target + '/$win_nt$.~ls/i386/txtsetup.sif', target)
copy(target + '/$win_nt$.~ls/i386/setupldr.bin', target + '/$ldr$')


if (productProperties.get('store_i386') == 'true'):
	copy(target + '/$win_nt$.~ls/i386', target + '/')

# Copy r2 files
if os.path.exists(source + '/CMPNENTS'):
	copy(source + '/CMPNENTS', target + '/')

# Copy x64 files
if os.path.exists(source + '/AMD64'):
	copy(source + '/AMD64/*', target + '/$win_nt$.~ls/AMD64/')
	copy(target + '/$win_nt$.~ls/AMD64/*', target + '/$win_nt$.~bt/')
	copy(target + '/$win_nt$.~ls/AMD64/txtsetup.sif', target)

# Copy oem and opsi files
copy(source + '/opsi', target + '/')
os.renames(target + '/opsi/$oem$', target + '/$')
copy(source + '/custom/$oem$/*', target + '/$/')
copy(source + '/custom/unattend.txt', target + '/$win_nt$.~bt/winnt.sif')
for f in os.listdir(source + '/custom/postinst.d'):
	if not os.path.exists(target + '/opsi/postinst.d/' + f):
		copy(source + '/custom/postinst.d/' + f, target + '/opsi/postinst.d/')

# for preloginloader 3.3
if os.path.exists(DEPOT_MOUNT + '/install/preloginloader/files/opsi/utils/prelogin.exe'):
	# Copy opsi-preloginloader
	copy(DEPOT_MOUNT + '/install/preloginloader/files/*', target)
	# Copy installation script
	copy(target + '/opsi/setdepot.cmd', target + '/opsi/postinst.d/50_preloginloader.cmd')

# for preloginloader 3.4
elif os.path.exists(DEPOT_MOUNT + '/install/preloginloader/files/opsi/dist/opsiclientd.exe'):
	# Copy opsi-preloginloader
	copy(DEPOT_MOUNT + '/install/preloginloader', target + '/opsi/')
	# Copy sysconf.ini to preloginloader config dir
	copy(SYSCONF_INI, target + '/opsi/preloginloader/files/opsi/cfg')
	# Copy preloginloader postinst scripts
	copy(target + '/opsi/preloginloader/files/opsi/postinst.d/*', target + '/opsi/postinst.d/')

else:
	raise Exception("Opsi preloginloader not found")

# Copy sysconf.ini to C:\opsi\cfg
copy (SYSCONF_INI, target + '/opsi/cfg')

# Store master boot record
f = open(disk.device, 'rb')
mbr = f.read(512)
f.close()
f = open(target + '/opsi/opsi.mbr', 'wb')
f.write(mbr)
f.close()

# Integrate drivers
if os.path.exists(srcDriversDir):
	scriptMessageSubject.setMessage("Treiber-Verzeichnis '%s' gefunden, starte Treiberintegration" % srcDriversDir)
	
	integrateHardwareDrivers(srcDriversDir, dstDriversDir, hardware, messageObserver = scriptMessageObserver)
	integrateAdditionalDrivers(srcDriversDir + '/drivers/additional', dstDriversDir, productProperties.get('additional_drivers',''), messageObserver = scriptMessageObserver)
	integrateTextmodeDrivers(dstDriversDir, target, hardware, target + '/$win_nt$.~bt/winnt.sif', messageObserver = scriptMessageObserver)
	oemPnpDriversPath = getOemPnpDriversPath(dstDriversDir, target, ';')
	
	pi = open(PATCHA_IN, 'a')
	print >> pi, "oempnpdriverspath=%s" % oemPnpDriversPath
	pi.close()

# Create bootsect.dat
f = open(disk.getPartition(1)['device'], 'rb')
pbr = f.read(512)
f.close()
pbr = pbr.replace('NTLDR', '$LDR$')
f = open(target + '/$win_nt$.~bt/bootsect.dat', 'wb')
f.write(pbr)
f.close()

# Installation config for preloginloader 3.4
patchtarget = target + '/opsi/preloginloader/files/opsi/cfg/config.ini'
# Installation config preloginloader 3.3
if os.path.exists(target + '/opsi/cfg/pxecfg.ini'):
	patchtarget = target + '/opsi/cfg/pxecfg.ini'

# Patch unattended.txt
for i in ( target + '/$win_nt$.~bt/winnt.sif', patchtarget ):
	execute("/usr/local/bin/patcha '%s'" % i)
	execute("/usr/local/bin/patcha -f %s '%s'" % (PATCHA_IN, i))

# Write boot.ini
f = open(target + '/boot.ini', 'w')
print >> f, '[Boot Loader]'
print >> f, 'Timeout=1'
print >> f, 'Default=C:\$WIN_NT$.~BT\BOOTSECT.DAT'
print >> f, '[Operating Systems]'
print >> f, 'C:\$WIN_NT$.~BT\BOOTSECT.DAT = "OPSI Windows Installation"'
f.close()

# Umount partition
disk.umountPartition(partition=1)

# Reboot
reboot()
Viel Spaß
.
Gruß Robert
fischerr
Beiträge: 19
Registriert: 29 Jun 2009, 10:52

Re: zwei Partitionen

Beitrag von fischerr »

Hallo
wie es halt so ist, habe noch kleinen Fehler entdeckt (Partitionieren von kleinen Festplatten ging nicht) und beseitigt.
Hier das korrigierte Skript.

/opt/pcbin/install/winxppro/setup.py

Code: Alles auswählen

#
# This script requires opsi >= 3.3, opsi-linux-bootimage version >= 20090224
# mail@robert-fischer.de 15.07.2009
#
if not bootimageVersion or (int(bootimageVersion) < 20090224):
   raise Exception("This product requires opsi-linux-bootimage version >= 20090224")

target = '/mnt/hd'
source = DEPOT_MOUNT + '/install/' + productId
srcDriversDir = source + '/drivers'
dstDriversDir = target + '/drv'

# Do hardware inventory
logger.notice("Fetching opsi hw audit configuration")
config = backend.getOpsiHWAuditConf()

logger.notice("Running hardware inventory")
hardware = hardwareInventory(config = config)

logger.notice("Sending hardware information to service")
backend.setHardwareInformation(fqdn, hardware)

###################################################################################
### Modifikation
###################################################################################

# Get first harddisk
KB=1000
MB=1000*1000
GB=1000*1000*1000

disks = getHarddisks()
disk = disks[0]
disksize = disk.size - KB
partitions = disk.getPartitions()

# Disksize <= 4GB
# => Platte zu klein => exit
if (disksize <= 3999*MB):
  ui.getMessageBox().addText("Festplatte kleiner ab 4GB,zu klein!\n")

# nur eine Partition
elif (4*GB < disksize) and (disksize <= 14999*MB):
  # 4GB < Disksize <= 8GB
  # => erstelle 1 Partition ueber die gesamte Platte elif (4*GB < disksize) and (disksize <= 6*GB):
  if not partitions:
    ui.getMessageBox().addText("Es wird eine Partition ueber die gesamte Platte erstellt!\n")
    disk.deletePartitionTable()
    disk.createPartition(start="0%", end="100%", fs="fat32", boot=True)
    disk.createFilesystem(partition=1, fs="fat32")
  else:
    partition = partitions[0]
    partend = str(int((partition['end'] / (1024*1024)) - 1)) + "M"
    ui.getMessageBox().addText('Ende Partition 1: %s\n' % (partend))
    ui.getMessageBox().addText("Partition 1 wird neu erstellt\n")
    disk.deletePartition(partition=1)
    disk.createPartition(start="0%", end=partend, fs="fat32", boot=True)
    disk.createFilesystem(partition=1, fs="fat32")



# => 2 Partitionen: 1. 6GB, 2. Rest
elif (15001*MB < disksize) and (disksize < 30*GB):
  if not partitions:
    ui.getMessageBox().addText("Es werden zwei Partition erstellt!\n1. Partition: 6GB, 2. Partition: Rest\n")
    disk.deletePartitionTable()
    disk.createPartition(start="0M", end="6000M", fs="fat32", boot=True)
    disk.createFilesystem(partition=1, fs="fat32")
    disk.createPartition(start="6001M", end="100%", fs="ntfs")
    disk.createFilesystem(partition=2, fs="ntfs")
   
  else:
    partition = partitions[0]
    partend = str(int((partition['end'] / (1024*1024)) - 1)) + "M"
    disk.deletePartitionTable()
    ui.getMessageBox().addText('Ende Partition 1: %s\n' % (partend))
    ui.getMessageBox().addText("Partition 1 wird neu erstellt\n")   
    ui.getMessageBox().addText("\nSchritt 2: Erstelle neue Partition\n")
    disk.createPartition(start="0M", end="6000M", fs="fat32", boot=True)
    ui.getMessageBox().addText("\nSchritt 3: Formatiere Partition\n")
    disk.createFilesystem(partition=1, fs="fat32")
    ui.getMessageBox().addText("\nSchritt 5: Erstelle neue Partition\n")
    disk.createPartition(start="6001M", end="100%", fs="ntfs")
    ui.getMessageBox().addText("\nSchritt 5: Formatiere Partition\n")
    disk.createFilesystem(partition=2, fs="ntfs")


# 2 Partitionen: 1. 40%, 2. 60%
elif (30*GB < disksize) and (disksize <= 80*GB):
  if not partitions:
    ui.getMessageBox().addText("Es werden zwei Partition erstellt!\n1. Partition: 6GB, 2. Partition: Rest\n")
    disk.deletePartitionTable()
    disk.createPartition(start="0%", end="40%", fs="fat32", boot=True)
    disk.createFilesystem(partition=1, fs="fat32")
    disk.createPartition(start="40,1%", end="100%", fs="ntfs")
    disk.createFilesystem(partition=2, fs="ntfs")
   
  else:
    partition = partitions[0]
    partend = str(int((partition['end'] / (1024*1024)) - 1)) + "M"
    disk.deletePartitionTable()
    ui.getMessageBox().addText('Ende Partition 1: %s\n' % (partend))
    ui.getMessageBox().addText("Partition 1 wird neu erstellt\n")   
    ui.getMessageBox().addText("\nSchritt 2: Erstelle neue Partition\n")
    disk.createPartition(start="0%", end="40%", fs="fat32", boot=True)
    ui.getMessageBox().addText("\nSchritt 3: Formatiere Partition\n")
    disk.createFilesystem(partition=1, fs="fat32")
    ui.getMessageBox().addText("\nSchritt 5: Erstelle neue Partition\n")
    disk.createPartition(start="40,1%", end="100%", fs="ntfs")
    ui.getMessageBox().addText("\nSchritt 5: Formatiere Partition\n")
    disk.createFilesystem(partition=2, fs="ntfs")



# 2 Partitionen: 1. 32GB, 2. Rest
else:
  if not partitions:
    ui.getMessageBox().addText("Es werden zwei Partition erstellt!\n1. Partition: 40%, 2. Partition: 60%\n")
    disk.deletePartitionTable()
    disk.createPartition(start="0%", end="32000M", fs="fat32", boot=True)
    disk.createFilesystem(partition=1, fs="fat32")
    disk.createPartition(start="32001M", end="100%", fs="ntfs")
    disk.createFilesystem(partition=2, fs="ntfs")
  else:
    partition = partitions[0]
    partend = str(int((partition['end'] / (1024*1024)) - 1)) + "M"
    disk.deletePartitionTable()
    ui.getMessageBox().addText('Ende Partition 1: %s\n' % (partend))
    ui.getMessageBox().addText("Partition 1 wird neu erstellt\n")   
    ui.getMessageBox().addText("\nSchritt 2: Erstelle neue Partition\n")
    disk.createPartition(start="0%", end="32000M", fs="fat32", boot=True)
    ui.getMessageBox().addText("\nSchritt 3: Formatiere Partition\n")
    disk.createFilesystem(partition=1, fs="fat32")
    ui.getMessageBox().addText("\nSchritt 5: Erstelle neue Partition\n")
    disk.createPartition(start="32001M", end="100%", fs="ntfs")
    ui.getMessageBox().addText("\nSchritt 5: Formatiere Partition\n")
    disk.createFilesystem(partition=2, fs="ntfs")
   

###################################################################################
### Modifikation ende
###################################################################################

# Write Master Boot Record
disk.writeMasterBootRecord(system='winxp')

# Write Partition Boot Record
disk.writePartitionBootRecord(partition=1, fsType='fat32nt')

# Mount partition
disk.mountPartition(partition=1, mountpoint=target)

# Copy Windows installation files
i386Dir = productProperties.get('i386_dir')
if not i386Dir: i386Dir = 'i386'
copy(source + '/' + i386Dir + '/*', target + '/$win_nt$.~ls/i386/')
copy(target + '/$win_nt$.~ls/i386/*', target + '/$win_nt$.~bt/')
copy(target + '/$win_nt$.~ls/i386/ntldr', target)
copy(target + '/$win_nt$.~ls/i386/ntdetect.com', target)
if os.path.exists(target + '/$win_nt$.~ls/i386/bootfont.bin'):
   copy(target + '/$win_nt$.~ls/i386/bootfont.bin', target)
copy(target + '/$win_nt$.~ls/i386/txtsetup.sif', target)
copy(target + '/$win_nt$.~ls/i386/setupldr.bin', target + '/$ldr$')


if (productProperties.get('store_i386') == 'true'):
   copy(target + '/$win_nt$.~ls/i386', target + '/')

# Copy r2 files
if os.path.exists(source + '/CMPNENTS'):
   copy(source + '/CMPNENTS', target + '/')

# Copy x64 files
if os.path.exists(source + '/AMD64'):
   copy(source + '/AMD64/*', target + '/$win_nt$.~ls/AMD64/')
   copy(target + '/$win_nt$.~ls/AMD64/*', target + '/$win_nt$.~bt/')
   copy(target + '/$win_nt$.~ls/AMD64/txtsetup.sif', target)

# Copy oem and opsi files
copy(source + '/opsi', target + '/')
os.renames(target + '/opsi/$oem$', target + '/$')
copy(source + '/custom/$oem$/*', target + '/$/')
copy(source + '/custom/unattend.txt', target + '/$win_nt$.~bt/winnt.sif')
for f in os.listdir(source + '/custom/postinst.d'):
   if not os.path.exists(target + '/opsi/postinst.d/' + f):
      copy(source + '/custom/postinst.d/' + f, target + '/opsi/postinst.d/')

# for preloginloader 3.3
if os.path.exists(DEPOT_MOUNT + '/install/preloginloader/files/opsi/utils/prelogin.exe'):
   # Copy opsi-preloginloader
   copy(DEPOT_MOUNT + '/install/preloginloader/files/*', target)
   # Copy installation script
   copy(target + '/opsi/setdepot.cmd', target + '/opsi/postinst.d/50_preloginloader.cmd')

# for preloginloader 3.4
elif os.path.exists(DEPOT_MOUNT + '/install/preloginloader/files/opsi/dist/opsiclientd.exe'):
   # Copy opsi-preloginloader
   copy(DEPOT_MOUNT + '/install/preloginloader', target + '/opsi/')
   # Copy sysconf.ini to preloginloader config dir
   copy(SYSCONF_INI, target + '/opsi/preloginloader/files/opsi/cfg')
   # Copy preloginloader postinst scripts
   copy(target + '/opsi/preloginloader/files/opsi/postinst.d/*', target + '/opsi/postinst.d/')

else:
   raise Exception("Opsi preloginloader not found")

# Copy sysconf.ini to C:\opsi\cfg
copy (SYSCONF_INI, target + '/opsi/cfg')

# Store master boot record
f = open(disk.device, 'rb')
mbr = f.read(512)
f.close()
f = open(target + '/opsi/opsi.mbr', 'wb')
f.write(mbr)
f.close()

# Integrate drivers
if os.path.exists(srcDriversDir):
   scriptMessageSubject.setMessage("Treiber-Verzeichnis '%s' gefunden, starte Treiberintegration" % srcDriversDir)
   
   integrateHardwareDrivers(srcDriversDir, dstDriversDir, hardware, messageObserver = scriptMessageObserver)
   integrateAdditionalDrivers(srcDriversDir + '/drivers/additional', dstDriversDir, productProperties.get('additional_drivers',''), messageObserver = scriptMessageObserver)
   integrateTextmodeDrivers(dstDriversDir, target, hardware, target + '/$win_nt$.~bt/winnt.sif', messageObserver = scriptMessageObserver)
   oemPnpDriversPath = getOemPnpDriversPath(dstDriversDir, target, ';')
   
   pi = open(PATCHA_IN, 'a')
   print >> pi, "oempnpdriverspath=%s" % oemPnpDriversPath
   pi.close()

# Create bootsect.dat
f = open(disk.getPartition(1)['device'], 'rb')
pbr = f.read(512)
f.close()
pbr = pbr.replace('NTLDR', '$LDR$')
f = open(target + '/$win_nt$.~bt/bootsect.dat', 'wb')
f.write(pbr)
f.close()

# Installation config for preloginloader 3.4
patchtarget = target + '/opsi/preloginloader/files/opsi/cfg/config.ini'
# Installation config preloginloader 3.3
if os.path.exists(target + '/opsi/cfg/pxecfg.ini'):
   patchtarget = target + '/opsi/cfg/pxecfg.ini'

# Patch unattended.txt
for i in ( target + '/$win_nt$.~bt/winnt.sif', patchtarget ):
   execute("/usr/local/bin/patcha '%s'" % i)
   execute("/usr/local/bin/patcha -f %s '%s'" % (PATCHA_IN, i))

# Write boot.ini
f = open(target + '/boot.ini', 'w')
print >> f, '[Boot Loader]'
print >> f, 'Timeout=1'
print >> f, 'Default=C:\$WIN_NT$.~BT\BOOTSECT.DAT'
print >> f, '[Operating Systems]'
print >> f, 'C:\$WIN_NT$.~BT\BOOTSECT.DAT = "OPSI Windows Installation"'
f.close()

# Umount partition
disk.umountPartition(partition=1)

# Reboot
reboot()
.
Gruß Robert
DocDOS
Beiträge: 98
Registriert: 18 Mai 2009, 08:29
Kontaktdaten:

Re: zwei Partitionen

Beitrag von DocDOS »

Hallo,

ich bekomme hier ne Fehlermeldung, wenn ich das gemoddete Script ausühre:

Code: Alles auswählen

'ascii' can't encode character u'\ufffd' in position 22: ordinal not in range(128)
mfg
DocDOS
Antworten