PS2 APA JAIL

__empty can be reassembled if user creating new. Better idea would be i.e "__exfat" with custom ID or (raw id). But what about partition size exceeding 128GiB? :P In example user would want store 1TiB of games on exFAT and this cannot be covering up by single APA partition and subpartitions.
Yes, I mean to fill with __empty partitions until __exfat fake partition is reached.
upload_2021-8-11_23-29-45.png

WinHIIP is still the best when showing HDD structure, just NEVER press on repair button.
upload_2021-8-11_23-47-58.png

As for partition size, you probably can hack its size by changing it manually (in picture is __mbr partition, of course you should do it for __exfat). For example, you can set the highlighted value on my screen to FF FF FF FF (this means 2Tb for partition size), next 2 bytes should be 01 00 (this means that this is RAW partition). If this is the last partition on ps2 side, you will not face any problems. Probably only some partition managers like wlaunchelf can become acting weirdly - this should be checked cause better to not set up partition size larger than space left until the end of disk. But maybe everything will be fine, needs testing.
 
Ok, I got the idea. Comparison of two ideas few posts below in cases 'B' and 'C' ("__jail" name would be better because it is neutral):

Never tried hack the size. But if this is possible, then it is great solution and both words can be at least minimally protected.

WinHIIP is still the best when showing HDD structure, just NEVER press on repair button.
I prefer IsoBuster. ;)
 
Last edited:
This last design is perfect! It allows also from PS2 side to access to exFAT data if partition size can be fooled in header (i.e uLE would use fs table from exFAT, ignoring APA size). This should works if "APA header" is right before exFAT fs table, and exFAT fully fit in fs space of APA partition. For it, we could set custom ID like I did for FAT32 in experiment a year ago (all software is fine with custom IDs which HDL proofs anyway).

It is possible to use somehow code from USBD.IRX from PS2Netbox (Chinese OPL clone)? It support exFAT as I heard, but only from MBR, so we must somehow add to it APA support.
 
Last edited:
@Berion Ah, I now understand - you want to start exfat exactly where starts __jail partition filesystem (after 4Mb attributes area). So in the future, this partition can be somehow accessed from the ps2 side, just by mounting _jail as exFat. In such case I advise you to mark it not as RAW but already as exFat - after partition size (which in my screen is highlighted) you should change 2 bytes to 00 07 (07 - is exFat partition descriptor). Also probably you cannot hack size to FF FF FF FF cause it is not the division of 0x400 (128Mb). Probably maximum valid size can be 00 00 C0 FF (first 2 bytes should be zero, 3rd byte should be the multiplication of 0x40, 4th byte any) - this means that partition consists of FFC00000 sectors. Anyway, I am not sure if such hacked partition can be mounted later on (at least modification in ps2sdk should be made). Probably this size should not overlap the HDD end if you really need to get as a more valid partition as possible. We are breaking APA design not only by creating partition larger than 128Gb but also by the fact that this partition does not contain subpartitions (according to APA design each partition larger than 1Gb should be divided into subpartitions).

Also, my design is a bit more flexible. Currently, in your design - from ps2 side, your HDD has no free space for new partitions. My design allows users to keep some free space by making the exFat partition smaller.
It will be almost the same picture just instead of
Code:
__mbr
__system
__sysconf
__common
__jail
my layout will look such:
Code:
__mbr
__net
__system
__sysconf
__common
__empty
__empty
...
__empty
__jail
This will allow by manipulating __empty partitions to keep some free space for ps2 users.
 
Yes, exactly.

Also yes, we should use official descriptors, or at least similar to them.

Thanks for advices. I'll test those scenarios.


So far we have four main conceptions, so I numbered them:

apa_jail_multiconcept.png


"A" doesn't work on Windows (or I made mistake in GPT) so probably we can eliminating it. It's a shame because this is cleanest and safest design.

"B" was tested and works. Link to image was attached in post no.8.

"C" and "D" quite the same but depend of how current libs interpret broken APA chain and fake size. This is what I have in plans to test in next week.

If tests C/D will fail, then I have idea to "E" with i.e multiple exFAT partitions and numbered jails like __jail0, __jail1, jail2 etc. (all 128GiB in size) but this ruin a little the idea to bee free from APA limitations and I would prefer back to B solution.

Of course I'm in idea of __empty partitions to safe some space for the user (i.e SCUMMVM creating it's own, or all old OPLs). It is compatible with all above scenarios, I just wanted to make scheme more simplified. Even in my image, there is a gap between __common and exFAT (few KiB because I'm to lazy to doing it by hand so I automate process using GParted which for some reason, created partition a little later than 512MiB.
 
Just dont remove __net - believe me it is used not only by BBNav :D
BTW when you hack the last partition size you will not break APA chain, cause apa chain doesn't check size of the last partition in chain
 
What else using __net? DVD-Player? HDD OSD doesn't. So there is nothing else which comes to my mind. :/ DESR probably, by this is beyond out reach yet. Maybe online games? But all are dead now.
 
Last edited:
Many online games use __net. Even those who use unofficial servers still use __net (or at least can use). All DNAS based stuff requires that partition. Here are more details.
 
Sorry, somehow I forgot about it. :/

If games using them, and those games can be played with unofficial servers via hack or any other way, then yeah, we should leave it. For me it was always empty, so I always considering it as garbage. ;p
 
In attachment. :)

To monster image, I transplanting only IDs from LBA 0 (0x1C0 to 0x1FF), full LBA 1 and 2, and full exFAT where it starts (somewhere far away). Nothing else was needed.
 

Attachments

Last edited:
Thanks.

First of all, you have wiped the APA journal. I highly recommend running HDD Checker to restore the journal (it is basically a backup of all partition headers in Sector 8 and so on). This will also help me to create proper HDD dumps.
Ok, lets start:
Modified them a bit. MBR/GPT schemes actually allow moving the GPT header into sector 2. I hope that I modified all values correctly. Now APA checksum also will be protected, you can create, remove, expand, do whatever you want with partitions outside the jail, everything should be fine, PA will not be broken. I changed inside Protected MBR HDD size to FF FF FF FFF - it seems valid value, Windows before seven are using it. Nowadays it is good practice to fill that value with disk amount, so maybe Gpart will do it silently and will break APAchecksum (this should be checked).
All other information in the first 2 sectors should be intact.
I also modified the GPT header, so it will know that he is starting from sector 2 and that the partition table is in sector 3. I also protected the first 16 Mb of HDD so there cannot be created partitions. I also limited the partition count to 20 (so it will not overlap APA journal on sector 8). Don't know if it actually limits possible partition count or just cosmetic value, just don't create more than 5 partitions!
Regarding partitions. It seems that your protective partition starts only from 16Mb from disk beginning. You choose a really good value cause it is the maximum possible size for APA Journal (if you fill 2TB drive with 128Mb partitions, I am completely sure no one will do it :D).

DEADFEED image - it is the image for generic disks, so it can be used on any HDD. I advise you to test it first, cause it can be used on any HDD, not only on your HDD @Berion . All values that point to the end of the disk are replaced with hex value - 0xDEADFEED.
 

Attachments

Protected MBR HDD size to FF FF FF FFF - it seems valid value,
https://linux.die.net/man/8/sgdisk
-C, --recompute-chs
Recompute CHS values in protective or hybrid MBR. This option can sometimes help if a disk utility, OS, or BIOS doesn't like the CHS values used by the partitions in the protective or hybrid MBR. In particular, the GPT specification requires a CHS value of 0xFFFFFF for over-8GiB partitions, but this value is technically illegal by the usual standards. Some BIOSes hang if they encounter this value. This option will recompute a more normal CHS value -- 0xFEFFFF for over-8GiB partitions, enabling these BIOSes to boot.

First of all, you have wiped the APA journal.
True, I didn't noticed. It must be gparted after setting partitions flags. It wipes those sectors and I forgot to put them back. ;p
 
@Berion my changes also allows to change partition sizes and count without breakin apa. Btw it will be cool to test ps2 side with hdd checker to check if hdd checker will not break gpt side. It also will generate proper apa journal.
 
HDD Checker (latest version) doesn't breaking GPT etc. but also doesn't recreating journal. I tried both options: check and optimize. On both "mini images".

dskmgmt.msc (Windows Disk Managment Tool build-in Windows 7) doesn't allow me to resize exFAT partition (this option is greyed) on all three images (monster, and both of Yours mini images). I didn't create new because I have only two IDE HDD, one 40GiB on which I testing, and one 80GiB full of games which I do not want mess. I have also SATA replacement for NA but I didn't yet mess with it.

GParted and Linux doesn't recognize the disk logic anymore on Your images. It looks like, he needs GPT in LBA1 or backup GPT at the end.


So it is rather all good news because user will not destroy GPT logic by HDDChecker, and also will be unable to change once formatted GPT logic. So it is nothing bad if we put GPT on LBA1 as intended to allow see it by Linux (tested on Mint 20.1 64bit with Cinnamon).
 
Last edited:
Ah I see, linux doesnt recognize gpt header in sector 2, this is bad news, cause in sector 1 we will need te recalculate hash for apa header if some changes are done. Its strange that windows can use such image, I always thought that unix systems are more flexible.
 
I have made further tests and we have first serious problem which makes setup inflexible. After setting up APA Jail, which means once after it setup whole HDD logic, user cannot touch it or loose all data. :| Main problem is with APA Journal. Without it, if user goes to HDD Manager in uLE and choose to create partition, uLE will wipe out whole APA scheme and create this partition as first. Also uLE ignoring forged 2TiB "hdd0:/__jail", so "hdd0:/__empty" doesn't protect us. And APA Journal writing to LBA 8+ breaking GPT. It is still usable but making visible none existent raw partition with... billions of EiB.

So if we follow this road, it is one way ticket. Hybrid HDD is great and works fine... until user decide to modify it by changing partitioning. Then, and only then all turns into shit because PS2 (at least uLE) overwriting old APA logic and PC probably breaks "hdd0:/__mbr" checksum). I'm unable to change exFAT size, so maybe diskmgmt.msc on Windows 7 doesn't support it, I dunno.

In attachment is perfectly aligned PC exFAT with APA fs exFAT space. Plus two experimental partitions (made for fun :P), one with FAT32 and one with 64MiB MCFS (relative sector addressing). Plus one __empty.

apajail_poc_20210815.png

Following by scheme:

apajail_scheme_e.png
 

Attachments

Last edited:
@Berion you expected these issues, not because you miss the APA journal, but because your __empty partitions don't follow the APA scheme. Basically __empty partition - it is just a normal APA partition and must follow all the APA limitations and standards. In our mixed scheme, only __jail partition can be hacked a bit (and only whole size and partition type).
There is no easy way for creating proper __empty partitions. I advise doing the following when you want to move __jail somewhere:
(You can use pfsshell, but for safety, I advise to use wlaunchelf):
1) Remove __jail partition
2) Create 1 partition (like +TEMP) with the size of the required __empty partition.
2a) I am not sure that you will trap exactly where you want - it will be safer to create tons of 128Mb partitions until you fill your size. Why? Cause big APA partition can become fragmented (yes APA also has fragmentation), and will fill more space on the disk.
3) Create __jail partition of size 128Mb (it is safer to make it as small as possible, so fewer changes will be made). The __jail partition must be the last partition on the HDD.
4) Remove partition from step 2 (or partition set from step 2a). It is basically what we need: it will create a proper __empty partition set.
4a) For safety it will be useful to run HDD checker at this step, just to ensure that everything is ok.
5) Now it is the time for HEX editing, you can modify __jail partition attributes (enormous size and partition type).

Now returning to the GPT side. As you proved - we cannot move the GPT header from sector 1 to sector 2 (it's a shame, btw). This will produce a whole bunch of problems: first, we should check the __mbr APA header checksum each time we connect HDD to pc. Even simple partition renaming or size change will lead to a corrupted checksum.
Next: you faced a problem that GParted is wiping APA journal. This can be fixed if you limit the partition count by 12:
just change
Code:
80 00 00 00  80 00 00 00
to
Code:
0C 00 00 00  80 00 00 00

I realized that sector 6 and sector 7 are also in use by APA (they are for storing APA smart attributes). So in fact we have only 3-4 sectors for the GPT partition table.

Not sure if GParted will not wipe the rest sectors "just in case". Seems like these utilities use a lot of hardcoded values, but I hope that I am wrong.

Don't forget that the GPT header has checksums inside, when you hex edit it, it is better to fix checksums (i am not familiar with GParted - hope that this utility has such an option). You can fix the APA checksum only after the GPT checksum is fixed.

After everything is set up, you can test if it is possible to create new partitions. It is still possible that wlaunchelf will destroy __jail, cause it is hacked, but I really hope that nothing bad will happen.

Edit:
I also added some notes about why originally system partitions have so big sizes:
Code:
__mbr     128Mb
__net     128Mb
__system  256Mb
__sysconf 512Mb
__common  1024Mb
this was made to avoid APA fragmentation and avoid subpartition creation. It is better for the partition to start from the multiplication of their size. For example __system has a size 256Mb, so it should start from the offset that is the multiplication of 256Mb.
So how sony thought. For 40Gb disk maximum partition size when it is possible to get rid of subpartitions: 1Gb. As they in the very beginning choose __common partition for storing game data, game saves, and probably something else, they choose for __common maximum possible size which will not lead to fragmentation and sub partitioning (1Gb). And again, to get rid of fragmentation and subpartitions, __common should start from the offset that is the multiplication of 1Gb (the minimum possible will be 1Gb). So they firstly create __common and then filled free 1Gb space with the rest of the partitions.
Basically, any change in partition sizes will lead to __common fragmentation.
Code:
__mbr     128Mb
__net     128Mb
__system  128Mb
__sysconf 128Mb
lead to the fact that __common cannot be larger than 512Mb, cause it will become fragmented. And also it cannot be less than 512Mb, cause the next partition in the chain can become fragmented (for example BB Navigator needs __content partition to be next in the chain).
Here I mix subpartitions and fragmentation, this is not the same: Partition can consist of subpartitions but it will not be really fragmented.
 
Last edited:

Similar threads

Back
Top