wbfs2fat.py

Discussion in 'Wii - Backup Loaders' started by PsyBlade, May 3, 2011.

May 3, 2011

wbfs2fat.py by PsyBlade at 10:40 PM (92,551 Views / 14 Likes) 245 Comments

    • Newcomer

    ederenzi78 New Member

    Member Since:
    Dec 14, 2012
    Message Count:
    23
    Country:
    Italy
    Help please!

    I've done a mess :-(. Here is what I did:
    1) Converted WBFS to FAT32 (no errors). The HD is 1TB with more or less 250 MB of free space
    2) Added three more games to the WBFS folder and added one more folder to the root (names games, with 4 Gamecube games). No errors
    3) Used EaseUs Partition Master to use unallocated space .... but it failed and now I can't see my partition! Now I have a partition with 200MB ... the actual data is unallocated ....

    How can I recover my original WBFS data? I still have the .backup file that WBFS2FAT created but I can't use the "restore Backup" option as it failed saing "I/O exeception" ... The recovery tool programs do not see my files ....

    Could I restore the file system using the .backup WBFS2FAT created? This way I could have all my original files (the data has never been actually overwritten or cancelled) and than use a WBFS File manager to move them safely.

    Can you help me? I don't know how to restore the backup and I'm scared I could ruin everything .....

    Thank you in advance!


    • Member

    pin New Member

    Member Since:
    Apr 21, 2009
    Message Count:
    106
    Country:
    United Kingdom
    Does it actually have a drive letter if it failed>? Check and assign if not
    • Newcomer

    ederenzi78 New Member

    Member Since:
    Dec 14, 2012
    Message Count:
    23
    Country:
    Italy
    Yes, it has a drive letter, but only for the 200MB partition (which is empty). The actual WBFS data is in the unallocated space ...
    • Member

    PsyBlade Snake Charmer

    Member Since:
    Jul 30, 2009
    Message Count:
    2,204
    Location:
    Sol III
    Country:
    Germany
    You tried to enlarge the fat32 partition, right?
    In general is such things fail during operation the data is lost.

    I have never used EaseUs Partition Master and no idea what it does.
    Your best chance would probably be it's recovery options.

    The backup wbfs2fat creates contains only the data it itself changes.
    Even if you could restore it I have no idea what would happen.
    No clue why you now get an IO error either.
    You could try with admin rights if you haven't, but I guess EUPM messed up good.
    I would abandon that direction and rather try drive recovery software.

    BTW: even if everything fails the drive itself is not lost
    no matter how messed up you can always zero the drive for a clean slate
    (I have seen that misconception here on gbatemp)


    EDIT:
    what was the partition layout before and after, with as much detail as possible?
    really helpful would be the exact (!) starting sector of the wbfs partition.
    do you know how to handle a hex editor?
    Last edited by PsyBlade, Dec 14, 2012
    • Newcomer

    ederenzi78 New Member

    Member Since:
    Dec 14, 2012
    Message Count:
    23
    Country:
    Italy
    I tried to overwrite the initial sectors with hdd raw copy tool (it's similar to dd) but after that windows does not assign any letter to drive and so - can't check wbfs files ... So i reverted (i made a raw copy of the sectors) to the previous state. Yes, i can use hex editors. What should i look at? I thought that overwriting the initial sectors with wbfs2fat backup would have restored everything to previou state (i did not cancel enything) but had no luck. Probably i should restore from an offset? Thanks
    • Newcomer

    ederenzi78 New Member

    Member Since:
    Dec 14, 2012
    Message Count:
    23
    Country:
    Italy
    UPDATE: i tried restoring sectors with dd tool. Then i could read the drive with a wbfs file manager: it saw al the games but could not retrive the correct data as all the games were listed with no ios and doing an export would reveal a fail. Can i do something else to recover the data? Thanks
    • Member

    PsyBlade Snake Charmer

    Member Since:
    Jul 30, 2009
    Message Count:
    2,204
    Location:
    Sol III
    Country:
    Germany
    yes restoring the initial sectors should have fixed it usually
    but in your caser there is no guarantee the the partition start is in the same place as before
    1. you need to find the right starting position,
    2. get the right size from the backup file
    3. create a partition with that parameters
    4. and then dd the backup back

    about 1
    open the drive (not the partition) in a hex editor
    search the suspected start area for a sector starting with the bytes EB 58 90 77 62 66 73 32 66 61 74 00 (in ascii: ".X.wbfs2fat.")
    thats the starting sector of the partition
    • Member

    PsyBlade Snake Charmer

    Member Since:
    Jul 30, 2009
    Message Count:
    2,204
    Location:
    Sol III
    Country:
    Germany
    If the wbfs manager can not read the games they were overwritten (unlikey if all are affected)
    or the partition is indeed in the wrong place
    undo the try and try to find it

    2.
    to get the size open the wbfs2fat backup in the hex editor
    offsets 0x04-0x07 are the wbfs's size as an big endian integer sector count
    eg "22 2E 00 00" means 0x222E0000 (or 573,440,000) sectors

    3.
    then you need an partitioning tool that allows you to create an partition with that exact parameters without trying to create a filesystem there
    I don't use windows so I can only suggest linux fdisk
    (If you can not use that and do not know anything yourself I can edit the MBR for you as a last resort kind of thing)

    4.
    then dd the backup to it
    • Newcomer

    ederenzi78 New Member

    Member Since:
    Dec 14, 2012
    Message Count:
    23
    Country:
    Italy
    Thank you.
    Here are the values:
    1) First byte of the string(EB) is at address: C900000--> Should I use this value?
    Last byte of the string (00) is at address: C90000B
    2) Partition Size: 74 6A 20 00
    3 e 4) I don't understand one thing ... The MBR is formed by the first sectors of HD, right? If I change the MBR on the HD and then restore the dd backup to it I lose the changes ... Am I missing something?
    At the moment I'm looking for a fdisk like tool for windows
    Thanks for patience

    UPDATE: I found the program MBRWizard. I think that I should do the following steps:
    1) Delete current partition
    2) Insert the partiotion. The program uses this info. Which values should I put for align and type? And size and start?
    (i uploaded also the MBR, just to make sure what I'm doing)
    Thanks
    /Create start, size, align, type Creates a new partition on the specified disk (not currently supported on GPT). If no further options are specified a type 0x7 partition will be created in the first identified freespace. Please see the additional options for ore granular control of creating the partition.
    /start= starting sector for the new partition, or 'freespace' selects the first available space on the disk
    /size= size in MB of the new partition, or MAX for maximum available size
    /align= alignment boundary for the new partition (1k, 2k, 4k... 128k, etc)
    /type= partition type identifier

    Attached Files:

    • MBR.zip
      File size:
      609 bytes
      Views:
      28
    Last edited by ederenzi78, Dec 14, 2012
    • Member

    PsyBlade Snake Charmer

    Member Since:
    Jul 30, 2009
    Message Count:
    2,204
    Location:
    Sol III
    Country:
    Germany
    yes the mbr is in the first sector (0) of the hdd
    and if you would dd the backup to there you would overwrite it
    the point you are missing is the the backup does not belong there
    instead it belongs to the start of the newly created partition (or sector 210763776+ of the hdd)


    to get the starting sector divide the starting address 0xC900000 or 210763776 by the sector size of your harddrive (512 Byte most likely, possibly 4096, others extremely rare)
    the partition size is 0x746A2000 or 1953112064 sectors (about 931 GiB assuming 512B sectors)
    disable alignment or at least choose the smallest possible value
    type should be 0x0b but the default 0x07 should work too

    confirm that the start and size were not changed by the alinment
    you have to hit the start exactly, the size can be larger but not smaller

    you now could try if windows can read the partition
    depending on what EUPM did it could still be a valid fat32 or have all kind of damage

    if you do not want to or can not read it restore the backup to the partition (not the drive)

    good luck
    • Member

    nukeboy95 Leave luck to heaven.

    Member Since:
    Aug 24, 2010
    Message Count:
    2,272
    Location:
    Hoenn
    Country:
    did you relly fill 1tb of wii games
    i can only can fill 500gb
    • Member

    PsyBlade Snake Charmer

    Member Since:
    Jul 30, 2009
    Message Count:
    2,204
    Location:
    Sol III
    Country:
    Germany
    there are some limits but 500GB is not one of them

    the ones I know are:
    max 32bit sector count (-> max 2TiB with the common 512B sector hdds)
    max sectorsize-12 (-> 500) games
    some arcane maximum on the number of games based on partition size

    maybe check the hdd with wwt for details
    • Newcomer

    ederenzi78 New Member

    Member Since:
    Dec 14, 2012
    Message Count:
    23
    Country:
    Italy
    Thank you! It worked setting the correct partition! Now I'll be doing some checks just to make sure everything is correct.

    Thank you very much!
    • Newcomer

    gip_mad New Member

    Member Since:
    Dec 30, 2012
    Message Count:
    1
    Country:
    Italy
    Hi, first of all thank you for the great tool. I ran into some problems with Italian titles with stupid characters:
    Code:
      File "/home/gip/wbfs2fat/python/wbfs2fat.py", line 397, in mkfiles
        dname = str(tmpC.decode("ascii")).strip(' \t\r\n\0')+" ["+id6+"]"
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)
    
    The titles are:
    "SVMP01Super Mario All-Stars: Edizione per il 25° anniversario" due to the "°"
    "R8AP01Poképark Wii: La Grande Avventura di Pikachu" due to the "é"
    "R3LPWRLanterna Verde: L’ascesa dei Manhunters" due to the stupid ’ that is not an UTF8 '
    I wrote a quick fix to replace the line 392 in the wbfs2fat.py from
    Code:
    dname = str(self.wbfs.games[id6][1][0x20:].decode("ascii")).strip(' \t\r\n\0')+" ["+id6+"]"
    to:
    Code:
    #UTF8 stupid characters fix
                tmpC=self.wbfs.games[id6][1][0x20:]
                tmpC= tmpC.replace("°",".")
                tmpC= tmpC.replace("é","e")
                tmpC= tmpC.replace("’","'")
                #print tmpC
     
                dname = str(tmpC.decode("ascii")).strip(' \t\r\n\0')+" ["+id6+"]"
                #dname = str(self.wbfs.games[id6][1][0x20:].decode("ascii")).strip(' \t\r\n\0')+" ["+id6+"]"
    To people getting the error Unhandled Error: <type 'exceptions.UnicodeDecodeError'> in the GUI, just replace the lines in the file; if the error persists, uncomment the #print tmpC line and see at what title the program crashes, then add more filters as necessary.

    I know it's a dirty hack, but I'm not expert in python and character encodings. This should be implemented in a more elegant way.
    Regards
    Mastro Gippo
    • Member

    PsyBlade Snake Charmer

    Member Since:
    Jul 30, 2009
    Message Count:
    2,204
    Location:
    Sol III
    Country:
    Germany
    thanks for the info I will look into it for the next version

    If anyone else has that problem please post the offending chars and I will provide a quick fix if you need it

    @gip_mad: could you please upload the backup file somwhere
    its the easiest way for me to try a real fix
    Last edited by PsyBlade, Dec 30, 2012
    • Global Moderator

    Cyan GBATemp's lurking knight

    Member Since:
    Oct 27, 2002
    Message Count:
    10,609
    Location:
    Engine room, learning
    Country:
    France
    I never tried it yet, but French also has some special characters. I can check if my games have special chars.

    Is there a mode where I can just check the data without really convert my partition?
    Stopping just before the actual conversion?

    Edit:
    Or is the problem while renaming the files after the conversion?
    • Member

    PsyBlade Snake Charmer

    Member Since:
    Jul 30, 2009
    Message Count:
    2,204
    Location:
    Sol III
    Country:
    Germany
    I think I fixed the problem.
    (I should probably try harder to really finish 0.9)

    Some backup where it failed might still be usefull.

    @Cyan
    The only thing close to an simulation mode is the CLI which by default asks after the computations but before writing anything (other than the backup)
    unfortunately it does not seem to work on windows curently

    I removed the final renaming step in 0.9
    the files are now created with the right names
    which means that the error would occour before the first write
    • Member

    LoloLakitu Shwowow Schogog

    Member Since:
    Jul 26, 2012
    Message Count:
    174
    Location:
    That new rad hangout.
    Country:
    Canada
    I keep getting error 7, so I did "wwt check" says I have 31 errors:
    CHECK /dev/sde1

    * Summary of WBFS Check: 31 errors found:
    5 used WBFS sectors marked as free!
    9 free WBFS sectors marked as used!
    15 WBFS sectors are used by 2 or more discs!
    2 invalid WBFS block references found!
    Total: 10 discs are invalid!

    Then I did "wwt repair" (assuming thats what I have to do)
    And I get:
    !! wwt: ERROR #17 [NO WBFS FOUND] in AnalyzePartitions() @ src/wbfs-interface.c#
    447
    !! no WBFS partitions found -> abort

    Using 320GB WD My Passport
    • Member

    PsyBlade Snake Charmer

    Member Since:
    Jul 30, 2009
    Message Count:
    2,204
    Location:
    Sol III
    Country:
    Germany
    try specifieing the drive to repair
    "wwt repair /dev/sde1"

    I'm not that experienced wit wwt
    but it also has a help function ("wwt help repair"), gbatemp thread and web page

    edit:
    wbfs2fat error 7 is "permission denied"
    that means that it could not open the drive
    try running it with admin rights and close all other wbfs related programs

    while you should try to fix the errors with wwt before
    it could benefit from the same hints
    Last edited by PsyBlade, Jan 3, 2013
    • Member

    LoloLakitu Shwowow Schogog

    Member Since:
    Jul 26, 2012
    Message Count:
    174
    Location:
    That new rad hangout.
    Country:
    Canada
    Oh sorry, I meant I got error 6 every time.
    And it says in wbfs2fat "wbfs is corrupted: Blocks used multiple times"
    Last edited by LoloLakitu, Jan 3, 2013

SPONSORED LINKS
 

Share This Page