Jump to content

Formatting an external drive using different interfaces


Dave-H

Recommended Posts

Yep :), good (which again means bad :()

 

That is where the difference between what is expected:

 

dsfi \\.\PHYSICALDRIVE6 33554432 4096 as4kbNTFS.bss

OK, written 4096 bytes at offset 33554432

and what you actually get:

dsfi \\.\PHYSICALDRIVE5 33554432 4096 as4kbNTFS.bss

\\.\PHYSICALDRIVE5 - Access is denied.

 

Becomes relevant.

 

There are no issues of course to avoid the repetitive loop (that is actually my bad :blushing:, forgot to put a check about it).

 

The issue is probably about the mechanism that the stupid Vista or later implements to protect parts of the hard disks (but not all of them) unless  they are part of something it "recognizes".

 

It is a CATCH22, since it doesn't recognize offset 33554432 as being part of the volume, it doesn't allow to write the (correct) bootsector to it, BUT when it finds already the "correct" bootsector, since it recognizes that offset as being part of a volume, THEN allows potentially to write to it a "wrong" one, it sounds crazy but that is seemingly what happens:

http://www.msfn.org/board/topic/173265-formatting-an-external-drive-using-different-interfaces/?p=1093173

 

To be fair, the stupid Windows 8.1 is actually "right" (hard as it is to say this :w00t::ph34r:) as in the specific prilog scheme the beginning of the NTFS volume is in the address actually assigned to the FAT12 partition (not by the actual volume, only by the MBR partition table entry), i.e. the two partitions (but not the volumes) are actually overlapping.

 

There are four ways out as I see it, all to be tested, but basically:

1) change the setup from "prilog" to "twolog"

2) keep the FAT12 volume and partition entries "as they are now" BUT move the NTFS partition and volume further so that they don't overlap 

3) keep the FAT 12 Volume and NTFS partition and volume "as they are" but find a way to also switch the MBR making the FAT12 partition entry "tight" on the space occupied by the volume.

4) find a way, like a MBR write or putting the disk offline to be able to get access to the bootsector of the NTFS volume bootsector.

 

I don't like very much #1 as it would make (even on the 512 bytes interface) the disk impossible to be made bootable (unless a MBR+hidden sectors bootmanager like grub4dos is used, though this might be needed anyway, to pre-switch to right geometry to access the NTFS volume) and as well I am not really sure that #3 switching the MBR also, is a good idea (doing it from a batch running from a volume residing on that same disk) or #4 (that implies to either do another kingd of MBR trick or on 7 and later put the disk offline).

 

#2 still seems to me the best one (actually more lke the "simpler" one), though it has an attached string, you will lose overall capacity of the disk (roughly 7 times the size of the FAT12 partition).

In practice, this has no real effect/weight until the size of the FAT12 volume is kept small enough, like:

FAT12:1 Mb in size=7 Mb unusable area of disk 

FAT12:2 Mb in size=14 Mb unusable area of disk 

...

FAT12:32 Mb in size=224 Mb unusable area of disk :w00t:

and it is still to be seen if the non-standard 1 sector Extended partition is an issue, but since it works on the 512 interface, I don't think that it is part of the issue.

 

If you are OK with this latter approach, and willing to try it with either a smaller partition (the 1 Mb one is more than enough to hold just the "switcher related files") or you are fine with having the 1 Tb reduces by at most some 224 Mb, I would recheck/correct  the previously posted batches so that you can recreate the "prilog" disk from scratch.

 

To be exact there is even a further approach, making use of a "temp" directory on another disk, let's say your "normal" %TEMP%, by copying to it the Switcher.cmd and thus being surely able (on 7 and later) to quickly put the disk offline in order to write the bootsector.

 

Though 3/4 to 4/5 of all programs you run normally do this (beside senselessly writing to your Registry and what not) I somehow feel like this approach to be "inappropriate". :unsure:

 

A further approach would be to add (yet another) little excutable to the FAT12 partition.

The _K over at reboot.pro put together a little tool that should be doing exactly what needed, Lock the disk and Unlock it after having performed another task (dsfi in our case), it has to be anyway tested on 8.x, as it was tested on Vista and 7 at the time, though nothing should have changed.

Get the tool here:

http://reboot.pro/topic/12413-lockdismount-v0300-update/

http://www.mediafire.com/download/5q6795h7pp32623/LockDismount0300.zip

and add it in the root of the FAT12 volume.

Edit the switcherDA.cmd changing this:

 

:do_switchDA

ECHO dsfi %Disk% %NTFSbsOffset% 4096 as%MountedAs%NTFS.bss

dsfi %Disk% %NTFSbsOffset% 4096 as%MountedAs%NTFS.bss

::if we are here it means that the volume was not found

::hence there is no drive letter either

ECHO attempting to run a rescan

ECHO rescan|diskpart.exe|FIND /v "DISKPART"|FIND /i /v "Microsoft"

::update the offset for next diskpart script

to:

 

:do_switchDA

ECHO dsfi %Disk% %NTFSbsOffset% 4096 as%MountedAs%NTFS.bss

lockdismount -lock %Disk#% dsfi %Disk% %NTFSbsOffset% 4096 as%MountedAs%NTFS.bss

IF %ERRORLEVEL% EQU 0 ECHO Operation succeeded!

::if we are here it means that the volume was not found

::hence there is no drive letter either

ECHO attempting to run a rescan

ECHO rescan|diskpart.exe|FIND /v "DISKPART"|FIND /i /v "Microsoft"

::update the offset for next diskpart script

 

 

 

jaclaz

Edited by jaclaz
Link to comment
Share on other sites


Sorry for the delay again, tried the last option with lockdismount and the modified script, but no joy I'm afraid.

:no:

Microsoft Windows [Version 6.3.9600](c) 2013 Microsoft Corporation. All rights reserved.C:\WINDOWS\system32>I:I:\>switcherdaVista , or later, ...OK, I am a local admin ..."DUAL" disk found as \\.\PHYSICALDRIVE5Disk is connected as 4096 bytes/sectorThe NTFS volume has not been found.This may seemingly happen on 8.x, and we can then try with direct access.No dice, something is really wrong.Press any key to continue . . .I:\>

:) 

Link to comment
Share on other sites

@Dencorso

NO.

The issue was expected and it should be connected to the writability of disk sectors without LOCKing the disk (or the drive/volume/partition)

Trustedinstaller should have no connection with this, and however the idea is again to make things as simple as possible, and using TrustedInstaller would be an overcomplex addition, we'd better shift back to "wasting" a few Mb and make a (slightly) more standard partitioning scheme

 

@Dave-H

Your last report makes no sense to me :w00t:

*Something* must have changed between your post #180 and #182.

in post #180 you posted:

 

I:\>switcherda

Vista :ph34r:, or later, ...

OK, I am a local admin ...

"DUAL" disk found as \\.\PHYSICALDRIVE5

Disk is connected as 4096 bytes/sector

The NTFS volume has not been found.

This may seemingly happen on 8.x, and we can then try with direct access.

The current NTFS bootsector is NOT the 4kb bytes one

switching it ...

dsfi \\.\PHYSICALDRIVE5 33554432 4096 as4kbNTFS.bss

\\.\PHYSICALDRIVE5 - Access is denied.

attempting to run a rescan

The bolded part comes from the SUB :doswitchDA, which means that the CALL to it, which is near the end of this snippet:

:Not_found_vol

ECHO The NTFS volume has not been found.

ECHO This may seemingly happen on 8.x, and we can then try with direct access.

::we now run a diskpart script to find the size of the first partition

::though the numbers expressed in Mb are rarely accurate, since the disk

::was partitioned programmatically, the output of diskpart is accurate enough

SET FAT12Size=

::set the start of Diskpart scripts

FOR /F "tokens=1 delims=[]" %%A in ('FIND /N "::THIS IS START OF DISKPART BATCH COMMANDS::" %~dpnx0') DO SET More_offset=%%A

::update to offset of script

SET /A More_offset+=18

FOR /F "tokens=* delims= " %%A IN ('MORE +!More_offset! %~dpnx0^|diskpart.exe^|FIND /i "Parti"') DO CALL :ParsePartline %%A

::reset to offset of start

SET /A More_offset-=18

IF NOT DEFINED FAT12Size ECHO No dice, something is really wrong.&PAUSE&GOTO :EOF

SET /A NTFSbsOffset=%FAT12Size%*1024*1024

::now let's check which bootsector is on the disk at the given offset (NOT the drive letter, NOT the volume)

FOR /F "tokens=5,6,7 delims=, " %%A IN ('dsfo %Disk% %NTFSbsOffset% 4096 NUL') DO SET NTFSVolume%%A%%B%%C

::and let's compare it with the MD5 of the two available bootsectors

FOR /F "tokens=5,6,7 delims=, " %%A IN ('dsfo as4kbNTFS.bss 0 4096 NUL') DO SET as4kbNTFS%%A%%B%%C

FOR /F "tokens=5,6,7 delims=, " %%A IN ('dsfo as512NTFS.bss 0 4096 NUL') DO SET as512NTFS%%A%%B%%C

SET /A Checkbs=0

IF "%NTFSVolumeMD5%"=="%as4kbNTFSMD5%" SET InUseAs=4kb&SET /A Checkbs+=1

IF "%NTFSVolumeMD5%"=="%as512NTFSMD5%" SET InUseAs=512&SET /A Checkbs+=1

IF %Checkbs% LSS 1 ECHO Oh, oh, something went wrong, exiting ... &PAUSE&GOTO :EOF

IF "%MountedAs%"=="%InUseAs%" (

ECHO The current NTFS bootsector is already the %MountedAs% bytes one

ECHO Nothing to switch ...

PAUSE

GOTO :EOF

)

ECHO The current NTFS bootsector is NOT the %MountedAs% bytes one

ECHO switching it ...

CALL :do_switchDA

ECHO This is the most we can do, if after next iteration

ECHO the NTFS volume is still not found but the bootsector

ECHO is detected as the "right" one, you will need to

ECHO disconnect the disk through "Safely Remove Hardware" and

ECHO reconnect it ...

PAUSE

GOTO :just_do_it

GOTO :EOF

The post #182 is instead the message that comes from the check in red above.

This can only mean that somehow the previous diskpart command failed, which makes no sense as it worked before.

However, try running manually.

Make sure you are in the right condition, i.e. PC1814096.

Make sure the disk is \\.\Physicaldrive5.

Run in diskpart:

select disk 5

list partition

you should get the same output as in post #176

The Partition 2 has offset 32 Mb, (as expected because we know that you selected 32 Mb size in the batches when you created the disk) so it's bootsector is at absolute offset 32*1024*1024=33554432 and you want to run:

lockdismount -lock 5 dsfi \\.\PhysicalDrive5 33554432 4096 as4kbNTFS.bss

and then a diskpart RESCAN.

jaclaz

Link to comment
Share on other sites

Well I don't understand what's changed.

All I did was change the ":do_switchDA" section in the switcherda file to your new version, and add the lockdismount file to drive I:.

I ran the commands you stated, and got this -

Microsoft Windows [Version 6.3.9600](c) 2013 Microsoft Corporation. All rights reserved.C:\WINDOWS\system32>diskpartMicrosoft DiskPart version 6.3.9600Copyright (C) 1999-2013 Microsoft Corporation.On computer: ASHFIELDCOURTDISKPART> select disk 5Disk 5 is now the selected disk.DISKPART> list partition  Partition ###  Type              Size     Offset  -------------  ----------------  -------  -------  Partition 0    Extended           4096 B   252 KB  Partition 1    Primary            254 MB   256 KB  Partition 2    Primary            931 GB    32 MBDISKPART> exitLeaving DiskPart...C:\WINDOWS\system32>I:I:\>lockdismount -lock 5 dsfi \\.\PhysicalDrive5 33554432 4096 as4kbNTFS.bssLocking volume I: ...FAILED (Access is denied.)Operation failed!Please close all files/applications accessing the affected volumes and try again.I:\>diskpartMicrosoft DiskPart version 6.3.9600Copyright (C) 1999-2013 Microsoft Corporation.On computer: ASHFIELDCOURTDISKPART> rescanPlease wait while DiskPart scans your configuration...DiskPart has finished scanning your configuration.DISKPART> select disk 5Disk 5 is now the selected disk.DISKPART> list partition  Partition ###  Type              Size     Offset  -------------  ----------------  -------  -------  Partition 0    Extended           4096 B   252 KB  Partition 1    Primary            254 MB   256 KB  Partition 2    Primary            931 GB    32 MBDISKPART> exitLeaving DiskPart...I:\>

:(

Link to comment
Share on other sites

Yep. 
This:
 

C:\WINDOWS\system32>I:

I:\>lockdismount -lock 5 dsfi \\.\PhysicalDrive5 33554432 4096 as4kbNTFS.bss
Locking volume I: ...FAILED (Access is denied.)
Operation failed!

Please close all files/applications accessing the affected volumes and try again

 
obviously puts an end on this approach, because one would need to NOT run the batch from the FAT12 partition, even if  instead of a tool that locks all volumes on the physicaldrive one would lock the single volume matter would not change because - right or wrong as it may be - the Windows 8, since it fails to see the second NTFS as volume, it considers that address as part of the FAT12 partition, so we really need to lock that FAT12 volume.

 

We have to abandon the idea of the overlapping partitions. :(

 

Find attached a new version of the files mkprilog and mkdualdisk, you need to use this version and recreate the partitioning again from scratch, these will make not the two partitions overlapping, and the NTFS volume should be found also on the 4kb interface on Windows 8.1.

Once you have the new partitions formatted, the SwitcherNG should work normally, also on Windows 8.1, on both 512 and 4 kb.

In a couple of days I should be able to provide a simplified (hopefully better) version of the Switcher.cmd, but as said in the meantime you could experiment with the SwitcherNG on this non-overlapping partition scheme.

 

jaclaz

 

mkprilog007.zip

Link to comment
Share on other sites

Sorry for the delay, the site's been down again!

:(

I've tried the new version just in Windows 8.1 with elevated command prompts, and I'm delighted to say that it all seems to work perfectly, switching happily in either direction!

:thumbup

This is the setup output -

Microsoft Windows [Version 6.3.9600](c) 2013 Microsoft Corporation. All rights reserved.C:\WINDOWS\system32>cd\mkprilogC:\mkprilog>mkprilogPlease input an approximated size in Megabytes for the FAT12 partition,minimum 1, maximum 32...The image will be created in the same folder as this batchand will be named PriLog.imgPlease consider how in the a size roughly 7 times the size of this partitionwill NOT be accessible/usable normally, in other words the PriLog.img oncedeployed will reduce disk capacity by 7 times the size you input, exampleIf you choose 1 Mbyte, you will lose roughly 7 Mbytes...If you choose 32 Mbyte, you will lose roughly 224 Mbytes32Writing MBR at offset 0 ...... done.Writing the 512 bytes/sector bootsector BPB at offset 32768 ...... done.Writing the 4096 bytes/sector bootsector BPB at offset 262144...... done.Writing FAT tables incipit ...... done.Press any key to continue . . ..The image should have been created as PriLog.img, now you need tomanually dd it to the destination disk, a suitable command would be:dsfi.exe \\.\PhysicalDrive[n] 0 0 PriLog.imgMake sure that you use the RIGHT Disk Number [n], do check in Disk Manager.The disk can be mounted indifferently through the 4kb or the 512 bytes/sectorinterface to deploy the image.Once the image has been deployed you may need to disconnect and reconnect thedisk to have the FAT12 volume be recognized and mounted to a drive letter.Then you can go to Disk Manager and create a Primary partition, NTFS formattedextending on all the available space on disk (or on just a portion of it).The size of the NTFS partition you create must be at least 7 times the size ofthe FAT12 one.It is "better" to use a Vista (or later) OS to create the NTFS partition asthe partition would be better if Megabyte aligned.(or do it manually or use a suitable third-party tool) as the XP will align iton head/cylinder boundaries, whilst a MB-aligned partition will be faster onslow buses such as USB 2.0The partition and the NTFS filesystem MUST be created when the disk is connectedas a 4kb sectored device, this is NOT negotiable.Once the second partition has been created, and I repeat, this MUST be donewith the device connected as 4kb sectored, you can run the mkdualdisk.cmdWhich will modify the disk and create the needed EPBR's.Press any key to continue . . .C:\mkprilog>dsfi \\.\PhysicalDrive5 0 0 PriLog.imgOK, written 33554432 bytes at offset 0C:\mkprilog>mkdualdisk"DUAL" disk found as \\.\PHYSICALDRIVE5Creating a temporary copy of the MBRdsfo \\.\PHYSICALDRIVE5 0 4096 temp.mbrOK, 4096 bytes, 0.016s, MD5 = c5e2a6e6a72dd713bde01cef7939e4ddNow the extent of the FAT12 partition is 65472000001B8h: 44 55 41 4C DUAL000001BEh: 00 00 00 00 0F 00 00 00 3F 00 00 00 01 00 00 00000001CEh: 00 00 00 00 01 00 00 00 40 00 00 00 C0 FF 00 00000001DEh: 00 14 11 04 07 FE FF FF 00 00 01 00 00 0B 8D 0E000001EEh: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00The disk was recognized as created with the Prilog schemeCreating a temporary copy of the NTFS partition bootsectordsfo \\.\PHYSICALDRIVE5 268435456 4096 tempNTFS.bssOK, 4096 bytes, 0.000s, MD5 = 13193b512259ee7256e9a592720f4821Press any key to continue . . .and copying it to the filedsfo tempNTFS.bss 0 0 as4kbNTFS.bssOK, 4096 bytes, 0.000s, MD5 = 13193b512259ee7256e9a592720f4821Creating a copy of the 4kb bytes/sector NTFS bootsectorAnd modifying it to become the 512 bytes/sector NTFS bootsectordsfo tempNTFS.bss 0 0 as512NTFS.bssOK, 4096 bytes, 0.000s, MD5 = 4476465c2498dd63a3c97e8a17cb6d21Press any key to continue . . .Creating a copy of the 4kb bytes/sector EPBRand writing to it the values for the NTFS volumeOK, 4096 bytes, 0.000s, MD5 = fc86b746e3b8c6f0108aaf1a1ac6271aCreating a copy of the 512 bytes/sector EPBRand writing to it the values for the NTFS volumeOK, 4096 bytes, 0.000s, MD5 = 620f0b67a91f7f74151bc5be745b7110Press any key to continue . . .Now we write the sectors to the diskdsfi \\.\PHYSICALDRIVE5 0 4096 Prilog.mbrOK, written 4096 bytes at offset 0dsfi \\.\PHYSICALDRIVE5 29672 4096 EPBR1_512.epbOK, written 4096 bytes at offset 29672dsfi \\.\PHYSICALDRIVE5 258048 4096 EPBR1_4Kb.epbOK, written 4096 bytes at offset 258048Deleting temporary files ...temp.mbr deletedtempNTFS.bss deletedPrilog.mbr deletedEPBR1_4kb.epb deletedEPBR1_512.epb deletedPress any key to continue . . .C:\mkprilog>

This is switching from 4096 mode to 512 mode -

Microsoft Windows [Version 6.3.9600](c) 2013 Microsoft Corporation. All rights reserved.C:\WINDOWS\system32>I:I:\>switcherdaVista , or later, ...OK, I am a local admin ..."DUAL" disk found as \\.\PHYSICALDRIVE5Disk is connected as 512 bytes/sectorNTFS volume found as \\.\Volume{e308684d-bc26-11e4-bfa7-00304879f908}, drive J:* Volume 9     J                RAW    Partition    931 GB  HealthyRemoving drive letter J: ...The current NTFS bootsector is NOT the 512 bytes oneswitching it ...dsfi \\.\Volume{e308684d-bc26-11e4-bfa7-00304879f908} 0 4096 as512NTFS.bssOK, written 4096 bytes at offset 0Please wait while DiskPart scans your configuration...Leaving DiskPart...* Volume 9         New Volume   NTFS   Partition    931 GB  HealthyMounting the volume to a drive letter...Checking drive letters ...In use: C: D: E: F: G: H: I:                            S:          W:Free  :                      J: K: L: M: N: O: P: Q: R:    T: U: V:    X: Y: Z:Mounting volume to first free drive letter J: ...OK, done:* Volume 9     J   New Volume   NTFS   Partition    931 GB  HealthyPress any key to continue . . .I:\>

This is switching back to 4096 mode, with is what failed before -

Microsoft Windows [Version 6.3.9600](c) 2013 Microsoft Corporation. All rights reserved.C:\WINDOWS\system32>I:I:\>switcherdaVista , or later, ...OK, I am a local admin ..."DUAL" disk found as \\.\PHYSICALDRIVE5Disk is connected as 4096 bytes/sectorNTFS volume found as \\.\Volume{e308684d-bc26-11e4-bfa7-00304879f908}, drive J:* Volume 9     J                RAW    Partition    931 GB  HealthyRemoving drive letter J: ...The current NTFS bootsector is NOT the 4kb bytes oneswitching it ...dsfi \\.\Volume{e308684d-bc26-11e4-bfa7-00304879f908} 0 4096 as4kbNTFS.bssOK, written 4096 bytes at offset 0Please wait while DiskPart scans your configuration...Leaving DiskPart...* Volume 9         New Volume   NTFS   Partition    931 GB  HealthyMounting the volume to a drive letter...Checking drive letters ...In use: C: D: E: F: G: H: I:                            S:          W:Free  :                      J: K: L: M: N: O: P: Q: R:    T: U: V:    X: Y: Z:Mounting volume to first free drive letter J: ...OK, done:* Volume 9     J   New Volume   NTFS   Partition    931 GB  HealthyPress any key to continue . . .I:\>

Unfortunately we're not quite there yet as I then tried with a non-elevated command prompt and got this in the second window -

Vista , or later, ...OK, I am a local admin ..."DUAL" disk found as \\.\PHYSICALDRIVE5Disk is connected as 512 bytes/sectorNTFS volume found as \\.\Volume{e308684d-bc26-11e4-bfa7-00304879f908}, drive J:File not found - I:\ELEVATEDCannot access file I:\+ECHO is off.Houston, we've had a problem.The current NTFS bootsector is already the 512 bytes oneCannot access file I:\elevatedECHO is off.Mounting the volume to a drive letter...Checking drive letters ...In use: C: D: E: F: G: H: I: J:                         S:          W:Free  :                         K: L: M: N: O: P: Q: R:    T: U: V:    X: Y: Z:The parameter is incorrect.Oh, oh, something prevented the correct mounting to K: ...Cannot access file I:\elevatedECHO is off.Press any key to continue . . .

Looking at it, I immediately thought that there must be a typo somewhere in the switcher file resulting in an invalid path, but I can't see any obvious one.

:)

Edited by Dave-H
Link to comment
Share on other sites

Good :) that the switching now works, at the cost of a few Mbytes :(.

 

Further good news are that I LIED :w00t::ph34r: technically that area is not really-really inaccessible, it is possible to use it as a logical volume inside extended that will be accessible ONLY when the disk is connected through the 512 bytes/sector interface, what do you think of this possible added feature?

Would it make sense to have that area usable (but only on 512 byte/sector interface)? :unsure:

 

 

 

That "elevated" not found must be a leftover...  :blushing: 
The issue is here:

:do_elevate
elevate.exe -c %~dpnx0 /elevated %1
GOTO :EOF

Try changing it to a simpler:
 

:do_elevate
elevate.exe -c %~dpnx0
GOTO :EOF

I added the /elevated and the %1 for some debugging version, but now there is no need for them now that things seem to work the way they should..
 
I must remember to change this (if it works) also in the "simplified" version I am putting together...
 
Right now the Switcher - no matter what - removes the drive letter that Windows assigned (if any) automatically, whilst in practice there are cases where this removing the drive letter and re-assigning it is not needed, I hope to make it so it doesn't unless it is actually *needed*.

 

jaclaz

Link to comment
Share on other sites

Wow, success after all that.  I'm impressed.

 

Jaclaz, I'm guessing you're the kind of guy who likes solving such things as....

 

http://en.wikipedia.org/wiki/Impossible_Puzzle

 

-Noel

Naah, the real fun is not in just solving the puzzle, it is into creating it beforehand ;).

 

@Dave-H

Find attached Switcher 010, it should be a tadbit less verbose, skipping not really needed operations.

 

jaclaz

Switcher010.zip

Edited by jaclaz
Link to comment
Share on other sites

That's all fine jaclaz, works a treat, both in elevated and non-elevated prompts!

:thumbup

The only thing I would suggest is that when you are using a non-elevated prompt, a second command window opens when you dismiss the UAC prompt. That window closes itself when it's finished what it's doing and you "press any key to continue..."

It might be nicer if it went back to the command prompt rather than just closing, so people could check its contents if they want to before closing it manually, especially considering that the first command window does stay open.

 

I haven't tried just double clicking on the switcher file, or right clicking and running as an administrator.

Would that now work?

 

With regards to getting a bit of drive space back when using the 512 interface, I personally don't think that's important enough to complicate things over.

I think we're only talking about a quarter of a gigabyte, and the disks being used nowadays are almost certainly going to be tens of gigabytes in size at least, so the extra would be a very small proportional increase in size.

Especially as it will only work with one interface, I really wouldn't bother with it.

As a matter of interest, if you did implement this, and the disk was being used on the 512 interface and data was written to the "extra" area, what would happen to that data when you switched to the 4096 interface? I assume it wouldn't be accessible, but would it be damaged?

 

This has been a really fascinating exercise, and I've really enjoyed doing it!

:yes:

Edited by Dave-H
Link to comment
Share on other sites


That's all fine jaclaz, works a treat, both in elevated and non-elevated prompts!
:thumbup

 

Good. :)

 


The only thing I would suggest is that when you are using a non-elevated prompt, a second command window opens when you dismiss the UAC prompt. That window closes itself when it's finished what it's doing and you "press any key to continue..."
It might be nicer if it went back to the command prompt rather than just closing, so people could check its contents if they want to before closing it manually, especially considering that the first command window does stay open.

 

Right now the :do_elevate is:

 

:do_elevate
elevate.exe -c %~dpnx0
GOTO :EOF

 

you can try with:

 

:do_elevate
elevate.exe -k %~dpnx0
GOTO :EOF

 

Is that the effect you want? :unsure:

 

 


I haven't tried just double clicking on the switcher file, or right clicking and running as an administrator.
Would that now work?

 

Both double clicking and RunAsAdmin  should work :unsure: though possibly the first should make use of the ":do_elevate" and the second go "direct", but you need anyway to try...

 

 


With regards to getting a bit of drive space back when using the 512 interface, I personally don't think that's important enough to complicate things over.
I think we're only talking about a quarter of a gigabyte, and the disks being used nowadays are almost certainly going to be tens of gigabytes in size at least, so the extra would be a very small proportional increase in size.
Especially as it will only work with one interface, I really wouldn't bother with it.
As a matter of interest, if you did implement this, and the disk was being used on the 512 interface and data was written to the "extra" area, what would happen to that data when you switched to the 4096 interface? I assume it wouldn't be accessible, but would it be damaged?

 

The issue (in theory as I haven't tested yet) with the "second" (actually "third") partition/volume would be different depending on the OS running and the actual bootsector in use.

 

The additional volume would behave just like the NTFS volume did in previous tests at least in theory:

under XP:

  1. If interface is 512 and bootsector is 512 then volume would be normally visible/accessible/etc.
  2. If interface is 512 and bootsector is 4096 then volume can be normally "switched"  (&GOTO #1)
  3. If interface is 4096 and bootsector is 4096 then volume would be normally visible/accessible/etc.
  4. If interface is 4096 and bootsector is 4096 then volume can be normally "switched"  (&GOTO #3)

under 8.1 (which probably means Vista :ph34r: and later):

 

 

  1. If interface is 512 and bootsector is 512 then volume would be normally visible/accessible/etc.
  2. If interface is 512 and bootsector is 4096 then volume can be normally "switched"  (&GOTO #1)
  3. If interface is 4096 and bootsector is 4096 then volume would be normally visible/accessible/etc.
  4. If interface is 4096 and bootsector is 512 then volume canNOT be  "switched"  (stuck :()

The switching (where possible) would most probably create some issues (though nothing that cannot be solved) with drive letter assignments, so it would be easier to have a "fixed" situation #1, also because there would the need for 1 EPBR (for the 512 interface) instead of 2 EPBR's (one for the 512 interface and one for the 4096).

 

The above would apply only if that volume was normally formatted with any of the available filesystems, or anyway if NTFS, if we pre-format via batch we would have to make  (just like we do for the first FAT12 Partition) a "dual-mode" formatting, which opens a (small) can of worms, as once excluded NTFS we have available:

  1. FAT 12 (but only up to 32 Mb) i.e. "good" only if the first FAT12 partition is up to 32/7=4 Mb
  2. FAT16 (but possibly only over 16 Mb), i.e. "good" only if the first FAT12 partition is over 16/7=2 Mb
  3. FAT 32 (but only over roughly 268 Mb), i.e. "good" only if the first FAT12 is over 268/7=38 Mb (but then the first FAT12 partition would be a first FAT16 partition)

(I have no idea/have not checked what could be done with exFAT)

 

It would be I believe acceptable however to limit the range of sizes for the first partition to 3-32 or 4-32 (instead of the current 1-32) and "force" a FAT16 filesystem on this second partition, this way (which would not require switching) would "restore" the lost area, possibly minus 1 Mbyte wasted by the EPBR to keep the volume "Mb aligned" provided that it makes sense (probably unneeded as a 4kb alignment would do nicely as well).

 

Still some tests should be made to verify that *something else* (the way mount manager *sees* this setup under different OS/interface) gets in the way of this otherwise nicely laid out plan... 

... the good news are that at least  in theory this added volume could be post-fitted to an existing "dual disk" without modifying the existing data...

 

There would be in any case no "risks" of damages for the contents of the volume, of course, they would be either fully accessible or not accessible.

 

jaclaz

Link to comment
Share on other sites

Yes, changing the elevate.exe switch from -c to -k does exactly what I wanted!

The window now stays open when the batch ends.

:yes:

I've tried just double clicking on the switcher file and that all works fine, which is good as it means it can be run from a shortcut, but there is a problem with right clicking and selecting "run as administrator".

The command prompt window comes up OK after the UAC prompt is dismissed, it says what interface the disk is connected with, but then just outputs some lines that are too fast to read, and closes!

Needless to say it hasn't done the switch.

:no:

Edited by Dave-H
Link to comment
Share on other sites

Good that it works fine double clicking, as at the end of the day it will be it's actual usage.

 

Try (to understand what the issue is when Run as Admin is used) to add  a few lines like:

ECHO  Checkpoint#1&PAUSE

before a few groups of commands and see on which Checkpoint it Pauses last (or what is displayed until the last prompt for the press any key closes the window).

 

 

 

jaclaz

Link to comment
Share on other sites

OK, tried that, and what's happening with "run as an administrator" is this -

Vista , or later, ...OK, I am a local admin ..."DUAL" disk found as \\.\PHYSICALDRIVE5Disk is connected as 4096 bytes/sector* Volume 9     J                RAW    Partition    931 GB  Healthy'dsfo' is not recognized as an internal or external command,operable program or batch file.'dsfo' is not recognized as an internal or external command,operable program or batch file. Checkpoint#1Press any key to continue . . .

:)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...