Anybody know of an on-console tool to remove emunand/rednand?

Discussion in '3DS - Homebrew Development and Emulators' started by ksanislo, Aug 26, 2016.

  1. ksanislo
    OP

    ksanislo GBAtemp Fan

    Member
    378
    218
    Feb 23, 2016
    United States
    Seattle, WA
    Is there any existing tool which can remove an emunand/rednand partition from the SD card and non-destructively resize the FAT partition back up to the full size of the card?
     
  2. xyxa

    xyxa Dokoro

    Member
    198
    100
    Aug 24, 2016
    Somalia
    EmuNAND9.
     
  3. ksanislo
    OP

    ksanislo GBAtemp Fan

    Member
    378
    218
    Feb 23, 2016
    United States
    Seattle, WA
    EmuNAND9 only has formatting options as far as I can tell. While this would remove the emunand partition, I suspect that it will destructively erase the SD contents to do so.
     
  4. gooeywreck

    gooeywreck Newbie

    Newcomer
    8
    0
    Aug 23, 2016
    United States
    you have to copy everything from the sd to your computer , format then transfer everything back and problem solved. im glad u knew not to format you would have lost everything.
     
  5. SirBeethoven

    SirBeethoven 3.145.... something. E=mc2

    Member
    1,794
    547
    Nov 26, 2015
    United States
    Decrypt9 can format (without RedNAND) meaning that it'll format it just like the computer would :D
     
  6. ksanislo
    OP

    ksanislo GBAtemp Fan

    Member
    378
    218
    Feb 23, 2016
    United States
    Seattle, WA
    Yeah, I get that, I'm wondering if anyone has bothered making a version of the tool that can rewrite the partition/FAT nondestructively instead. I've got friends who only have access to cellphones instead of PCs, and one of the few things that I can't walk them through is removing their old EmuNAND partitions without losing data.
     
  7. nobody231

    nobody231 GBATemp's Resident Nobody

    Member
    338
    62
    Dec 8, 2014
    United States
    Nowhere, USA
    I don't think that's even feasibly possible. Even if the 3DS was capable of removing partitions by itself (I don't know if it's possible), the 3DS may no longer recognize the SD card afterwards.
     
  8. ksanislo
    OP

    ksanislo GBAtemp Fan

    Member
    378
    218
    Feb 23, 2016
    United States
    Seattle, WA
    Low level IO is already utilized by Decrypt9/EmuNAND9 while formatting/partitioning, though their choice of the FatFs lib might not be capable of non-destructive operations itself. There's definitely no hardware limitation on being able to do this sort of thing, there's just no existing tools that I'm aware of so far.
     
  9. nobody231

    nobody231 GBATemp's Resident Nobody

    Member
    338
    62
    Dec 8, 2014
    United States
    Nowhere, USA
    Maybe people just can't be bothered to do it?
     
  10. dark_samus3

    dark_samus3 GBAtemp Addict

    Member
    2,314
    1,712
    May 30, 2015
    United States
    the main reason the feature isn't anywhere is the 3ds is ungodly slow in terms of IO speed, it'd take forever to expand a fat32 partition in the configuration that we have redNAND set up in (you'd have to move the fat32 "to the left" (which means closer to sector 0)) therefore, there aren't any tools to do it with... it might be practical for low GB cards, but for anything over... I'd say 8 GB, you're looking at quite some time
     
    Wolfvak likes this.
  11. nobody231

    nobody231 GBATemp's Resident Nobody

    Member
    338
    62
    Dec 8, 2014
    United States
    Nowhere, USA
    Oh, right. I forgot how bad the 3DS is in terms of that kind of stuff.
     
  12. ksanislo
    OP

    ksanislo GBAtemp Fan

    Member
    378
    218
    Feb 23, 2016
    United States
    Seattle, WA
    You should't need to move the files on the filesystem beyond the initial NAND size while creating the partition, anything beyond that could be left in place and you can just update the FAT to point to the new location, for deleting it would be even easier, with no files moving at all.
     
  13. Wolfvak

    Wolfvak *yawn*

    Member
    799
    1,060
    Oct 25, 2015
    Uruguay
    According to some tests I did, read speeds max out at about 12MiB/s, while write speeds average around 500KiB/s and 1.5MiB/s - from these numbers, you can expect yourself to be sitting in front of your 3DS for a long long time.

    EDIT: It depends on what you want - you could simply rewrite the MBR and partition layout in order to "remove" the emunand, but that doesn't really remove it, it simply "dummies" it out (and makes it relatively hard to really remove it afterwards, since you'd have to restore the old MBR or format from zero, yadda yadda).
    On the other hand, if what you want is to obliterate the rednand you'll have to move the FAT file system backwards as well as performing the MBR modification I mentioned earlier.
     
    Last edited by Wolfvak, Aug 26, 2016
    dark_samus3 likes this.
  14. dark_samus3

    dark_samus3 GBAtemp Addict

    Member
    2,314
    1,712
    May 30, 2015
    United States
    Wrong. You'd need to move at least the header and MBR, again, to the left to take advantage of the new space (you can't tell fat to look at addresses before the header, and to move the header, you're going to want to move the rest of the partition as well) unless I'm missing something here
     
    Wolfvak likes this.
  15. ksanislo
    OP

    ksanislo GBAtemp Fan

    Member
    378
    218
    Feb 23, 2016
    United States
    Seattle, WA
    Yeah, you'd have to rewrite the MBR, and the FAT, and write the new offsets for all of the files in the FAT, but that's realistically only a few hundred KB of data. The actual file storage can remain in the same location on the SD card. If you're making a new emunand partition, you'd have to copy all of the allocated blocks in that first GB or so to somewhere later in the disk. But anything already allocated in space that isn't changing just needs the FAT entry updated to point to its new position, the stored data itself doesn't have to be touched.
     
  16. moghedien

    moghedien GBAtemp Fan

    Member
    411
    247
    Mar 9, 2015
    United States
    I think he's implying that you could update the inodes (not sure if that's the right term?) instead of moving the files. I would think that would be possible when removing EmuNAND at least... but I know almost nothing about the low level details of file systems so I may be completely off.
     
  17. ksanislo
    OP

    ksanislo GBAtemp Fan

    Member
    378
    218
    Feb 23, 2016
    United States
    Seattle, WA
    Yeah, they're not inodes in FAT, but that's exactly how it works... There was an old GPL program called FIPS in the 90s that would handle this sort of thing, but I can't find the source for it anywhere... Parted and the like still do it, but I suspect they're far more complicated due to additional features than is really needed to pull this off on the 3DS.
     
  18. dark_samus3

    dark_samus3 GBAtemp Addict

    Member
    2,314
    1,712
    May 30, 2015
    United States
    FatFS (what /every/ arm9 application uses for SD access) might be able to help you out there
     
  19. ksanislo
    OP

    ksanislo GBAtemp Fan

    Member
    378
    218
    Feb 23, 2016
    United States
    Seattle, WA
    I've seen that, but FatFs doesn't seem to have any non-destructive volume management operations to handle this sort of thing, so it would probably be easier to mangle the FAT directly anyway. I really don't have the free time to start hacking on another project like this, I'm really just hoping someone else has already given it a go.