2x deletePartition: BLKRRPART: Device or resource busy
2x deletePartition: BLKRRPART: Device or resource busy
wenn in einer modifizierten Windows 7-Setup.py (OPSI 4.0rc) zweimal hintereinander deletePartition (statt deletePartitiontable) aufgerufen wird, kommt folgende Fehlermeldung:
"BLKRRPART: Device or resource busy
This disk is currently in use - repartitioning is probably a bad idea.
Umount all file systems, and swapoff all swap partitions on this disk.
Use the --no-reread flag to suppress this check.
Use the --force flag to overrule all checks. (master.py|1432)"
Wie kommts, bzw. wie kann man das verhindern?
Hintergrund ist, dass bei der Neuinstallation nicht alle Partitionen der Platte gelöscht werden sollen.
Gruß,
Chr. Adam
- j.schneider
- uib-Team
- Beiträge: 2044
- Registriert: 29 Mai 2008, 15:14
Re: 2x deletePartition: BLKRRPART: Device or resource busy
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
Re: 2x deletePartition: BLKRRPART: Device or resource busy
Code: Alles auswählen
#
# This script requires opsi >= 4.0, opsi-linux-bootimage version >= 20100628
#
if not bootimageVersion or (int(bootimageVersion) < 20100628):
raise Exception(u"This product requires opsi-linux-bootimage version >= 20100628")
try:
if not backend.isOpsi4():
raise Exception
except:
raise Exception(u"This is a opsi 4.0 product")
target = '/mnt/hd'
source = SCRIPT_PATH
srcDriversDir = source + '/drivers'
dstDriversDir = target + '/drv'
winpeNetworkMode = True
if (productProperties.get('winpenetworkmode', 'true') == 'false'):
winpeNetworkMode = False
# Do hardware inventory
logger.notice(u"Fetching opsi hw audit configuration")
hwconfig = backend.auditHardware_getConfig()
logger.notice(u"Running hardware inventory")
auditHardwareOnHosts = auditHardware(config = hwconfig, hostId = clientId)
logger.notice(u"Sending hardware information to service")
backend.auditHardwareOnHost_updateObjects(auditHardwareOnHosts)
# Get harddisks
logger.notice(u"Preparing Harddisks")
KB=1024
MB=1024*1024
GB=1024*1024*1024
disks = getHarddisks()
# Use first Harddisk
disk = disks[0]
scriptMessageSubject.setMessage(u"Verwende Festplatte %s (%0.0f MB)." % (disk.device, (float(disk.size)/(1024*1024))))
# Check disk size
if (disk.size < 51000*1024*1024):
# Disk smaller than 51000 MB => give up
raise Exception("Die Festplatte ist zu klein")
# Get current partitions
partitions = disk.getPartitions()
# -----------------------------------------Modifizierter Part Beginn
if (not partitions or len(partitions)!=3):
# No partition found on harddisk
scriptMessageSubject.setMessage("Keine oder zuwenige Partitionen auf %s gefunden" % disk.device)
# Create new partitiontable
disk.deletePartitionTable()
# Create partitions
# Partition C:
disk.createPartition(start="0M", end="14000M", fs="ntfs")
# OPSI-Partition
disk.createPartition(start="14000M", end="18000M", fs="fat32", boot=True)
# Partition D:
disk.createPartition(start="50000M", end="100%", fs="ntfs")
else:
# Installation vorhanden, nur C und opsi-Part. loeschen, D in Ruhe lassen
scriptMessageSubject.setMessage("Partitionen auf %s gefunden: " % disk.device)
for x in partitions:
scriptMessageSubject.setMessage(": %s " % x)
disk.deletePartition(partition=1)
disk.deletePartition(partition=2)
# Create partitions
logger.notice(u"Erstelle ntfs-partition")
disk.createPartition(start="0M", end="14000M", fs="ntfs")
logger.notice(u"Erstelle fat32-partition")
disk.createPartition(start="14000M", end="18000M", fs="fat32", boot=True)
logger.notice(u"Fertig mit Partitionierung")
partitions = disk.getPartitions()
scriptMessageSubject.setMessage("Neue Partitionierung: ")
for x in partitions:
scriptMessageSubject.setMessage(": %s " % x)
#------------------------------------- Modifizierter Part Ende
# Partition table deleted => delete all netboot product states
backend.backend_setOptions( { 'addProductPropertyStateDefaults': False } )
deletePocs = []
for poc in backend.productOnClient_getObjects(clientId = clientId):
if ((poc.productType == 'NetbootProduct') and (poc.productId != productId)) or \
((poc.productType == 'LocalbootProduct') and (poc.installationStatus == 'not_installed') and (poc.actionRequest == 'none')):
deletePocs.append(poc)
backend.productOnClient_deleteObjects(deletePocs)
# Create fat32 filesystem on partition
disk.createFilesystem(partition=2, fs="fat32")
# Write Master Boot Record
disk.writeMasterBootRecord(system='vista')
# Write Partition Boot Record
disk.writePartitionBootRecord(partition=2, fsType='fat32nt60')
# Mount partition
disk.mountPartition(partition=2, mountpoint=target)
# Copy PE files
depot.copy(source + '/winpe/*', target)
# Copy Windows installation files
if not winpeNetworkMode:
depot.copy(source + '/installfiles', target)
# Copy opsi files
depot.copy(source + '/opsi', target + '/')
# Copy opsi-client-agent
depot.copy('/opsi-client-agent', target + '/opsi/')
copy(target + '/opsi/opsi-client-agent/files/opsi/postinst.d/*', target + '/opsi/postinst.d/')
# Copy custom files
depot.copy(source + '/custom/unattend.xml', target + '/opsi/')
depot.copy(source + '/custom/postinst.d/*', target + '/opsi/postinst.d/')
# Copy sysconf.ini to opsi-client-agent config dir
copy(SYSCONF_INI , target + '/opsi/opsi-client-agent/files/opsi/cfg')
# Integrate drivers
oemPnpDriversPath =''
if depot.exists(srcDriversDir):
scriptMessageSubject.setMessage("Treiber-Verzeichnis '%s' gefunden, starte Treiberintegration" % srcDriversDir)
integrateWindowsHardwareDrivers(srcDriversDir, dstDriversDir, auditHardwareOnHosts, messageSubject = scriptMessageSubject, srcRepository = depot)
additionalDrivers = [ ad.strip() for ad in (u','.join(productPropertyValues.get('additional_drivers', [u'']))).split(u',') ]
if additionalDrivers:
integrateAdditionalWindowsDrivers(srcDriversDir + u'/drivers/additional', dstDriversDir, additionalDrivers, messageSubject = scriptMessageSubject, srcRepository = depot)
oemPnpDriversPath = getOemPnpDriversPath(dstDriversDir, target, separator=' ', prePath='d:\\')
pi = open(PATCHA_IN, 'a')
print >> pi, "oempnpdriverspath=%s" % oemPnpDriversPath
pi.close()
# Create startnet.cmd and 05_copydriver.cmd
f = open(target + '/opsi/startnet.cmd', 'w')
f1 = open(target + '/opsi/postinst.d/05_copydriver.cmd', 'w')
print >> f, "@echo off\r"
print >> f1, "@echo off\r"
print >> f, "c:\opsi\SetWallpaper.exe c:\opsi\opsibg.bmp\r"
print >> f, "echo Initializing ..... please wait ......\r"
print >> f, "wpeinit\r"
if os.path.exists(dstDriversDir):
devices = [ { 'vendorId': usedNetworkDevice['vendorId'], 'deviceId': usedNetworkDevice['deviceId'] } ]
logger.info(u"Integrating winpe driver for network controller: %s" % usedNetworkDevice)
storageControllerInfo = disk.getControllerInfo()
if storageControllerInfo:
logger.info(u"Integrating winpe driver for storage controller: %s" % storageControllerInfo)
devices.append( { 'vendorId': storageControllerInfo['vendorId'], 'deviceId': storageControllerInfo['deviceId'] } )
for filePath in findFiles(prefix = dstDriversDir, directory = dstDriversDir, includeFile = re.compile('\.inf$', re.IGNORECASE), returnDirs = False):
infFile = InfFile(filePath)
for dev in devices:
if infFile.isDeviceKnown(dev['vendorId'], dev['deviceId']):
filePath = filePath[len(target):]
if filePath.startswith('/'):
filePath = filePath[1:]
filePath = 'c:\\' + filePath.replace('/', '\\')
logger.notice("Adding to startnet.cmd: drvload %s\r" % filePath )
print >> f, "drvload %s\r" % filePath
if winpeNetworkMode:
match = re.search('^smb://([^/]+)\/([^/]+)$', depotUrl, re.IGNORECASE)
if not match:
raise Exception("Bad depot-URL '%s'" % depotUrl)
hn = match.group(1)
sn = match.group(2)
print >> f, "goto trynet\r"
print >> f, ":waitnet\r"
print >> f, "echo Waiting for the network ......\r"
print >> f, ":trynet\r"
print >> f, "ping -n 5 127.0.0.1>nul\r"
print >> f, "net use /user:pcpatch o: \\\\%s\\%s %s\r" % (hn, sn, pcpatchPassword)
print >> f, "if not %ERRORLEVEL%==0 goto waitnet\r"
print >> f, "o:\\install\\%s\\installfiles\\setup.exe /unattend:c:\\opsi\\unattend.xml\r" % productId
else:
print >> f, "c:\\installfiles\\setup.exe /unattend:c:\\opsi\\unattend.xml\r"
f.close()
print >> f1, "echo [%date% %time%] Executing: xcopy /s /i /e d:\drv c:\drv \r"
print >> f1, "xcopy /s /i /e d:\drv c:\drv \r"
f1.close()
# Patch files
for i in ( target + '/opsi/unattend.xml', target + '/opsi/opsi-client-agent/files/opsi/cfg/config.ini' ):
execute('/usr/local/bin/patcha %s' % i)
execute('/usr/local/bin/patcha -f %s %s' % (PATCHA_IN, i))
# Umount partition
disk.umountPartition(partition=2)
# Reboot
reboot()
Christian Adam
- j.schneider
- uib-Team
- Beiträge: 2044
- Registriert: 29 Mai 2008, 15:14
Re: 2x deletePartition: BLKRRPART: Device or resource busy
Bitte einnmal einen sleep einbauen.
Code: Alles auswählen
disk.deletePartition(partition=1)
time.sleep(3)
disk.deletePartition(partition=2)
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
Re: 2x deletePartition: BLKRRPART: Device or resource busy
- j.schneider
- uib-Team
- Beiträge: 2044
- Registriert: 29 Mai 2008, 15:14
Re: 2x deletePartition: BLKRRPART: Device or resource busy
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