Tutorial  Updated

Partition based emuMMC and L4T Ubuntu on the same SD card

I take no responsibility for any damage that following this guide might cause to you, your Switch, other devices or your neighbourhood! You have been warned!

With this guide you will create an emuMMC that can be used by KOSMOS/Atmosphère and SX OS. If you don't need/want the latter, you can follow other guides for that but I'm not sure how partitioning is changed then and even if you intend not to use SX OS at all there should be no downside in following this guide as you will end up with an emuMMC that you can use in Atmosphère as well.

Since both processes
  • creating a partition based emuMMC
    and
  • flashing the L4T Ubuntu image to the SD card
are each wiping the whole card, you can't simply do one after the other to achieve this. That's why some more work has to be done.

My way might seem to be a bit laborious but it just worked for me so here's what I did:
  1. Make a full NAND dump with hekate including BOOT0/1 just in case
  2. Since all data will be deleted from your SD card following these steps, create a temp folder on your computer and copy everything into it
  3. Download SX OS boot.dat and put it on the SD card's root directory
  4. Download their payload.bin as well and fire that up on your Switch while it is in RCM and while you hold VOL+
  5. In the SX OS bootmenu click the right button and then emunand
  6. Create a partition based emuNAND from there - this will take some time
  7. After it's finished, put your SD card in your computer. You will have a
    You will end up with the following:
    [30 GB hidden partition][rest of the card formatted to FAT32 with boot.dat on it]
  8. Take a USB flash drive (!) and flash the L4T Ubuntu image with Etcher to it
    (all data on the flash drive will be deleted!)
  9. Download either a GParted live image or any live Linux distribution (I took Ubuntu amd64) and flash/write that to another flash drive or a DVD so you can boot from it
  10. Boot your computer from it while your Switch SD card is connected to the computer so it is automatically mounted there
  11. Run GParted, unmount the FAT32 partition from there so you can resize it
  12. Resize it to free up some space for L4T Ubuntu. I resized it so there were around 16 GB after it at the end of the SD card
  13. Create an EXT4 partition in that unallocated free space with GParted and hit the apply button so both operations (resizing FAT32 and creating EXT4 partition) will be done - this will take some time
  14. Download a CloneZilla Live and flash/write that to a flash drive or DVD
    I burned it to a DVD with imgburn
  15. Boot your computer into CloneZilla while these both things are connected to your computer:
    • Switch SD card
    • flash drive from step 8 where you flashed the L4T image to
  16. In CloneZilla choose the options to clone not a whole drive but only a partition to another
  17. Choose expert mode so you can untick the option (with SPACE) to resize the destination partition size to the source partition size
  18. As the source partition choose the EXT4 partition (not the FAT32 one) from the flash drive from step 8
  19. As the destination partition choose the EXT4 partition from your Switch SD card that you just created with GParted
  20. Very important: remember how the devices are labeled (for example sdb, sdc, sdd and so on)
    In my case my source device (the flash drive from step 8) was sdb and the EXT4 partition on it was sdb1
    and my destition device (Switch SD card) was sdc and the destition EXT4 partition was sdc3
    What you need to remember now is the label of your source device (the USB flash drive)
  21. Now proceed and hit Y on both warnings that all data in the destination partition will be deleted (that's fine, it's really just the partition, not the whole SD card including your created emuMMC)
  22. Most likely CloneZilla will now complain that source and destition partition tables (MBR and GPT) are not the same and you have to resolve that first
    That's why I told you to remember the label from your flash drive!
    Hit ENTER and then get into the shell/commandline and type the following:
    sudo sgdisk -z /dev/sdx
    (where you replace x by the letter that you remembered)
    In my case it was /dev/sdb (without any numbers behind it)
    Confirm all warnings
  23. Now head back to step 16 and repeat the steps to clone the drive
    It should work now without complaints from CloneZilla
  24. After that is finished, boot back into your usual operation system on your computer and copy everything from your temp folder back to the FAT32 partition that you should be able to access from there
  25. Windows might complain about two "drives" that are not readable and need to be formatted - obviously that's your emuMMC and your L4T Ubuntu partition and you don't want to format them ... just ignore the messages
  26. Download the most recent L4T update (at this time it's 1.3.1), delete the boot.scr file and the boot folder (not to be confused with the bootloader folder!), then copy the content of the L4T update zip to the FAT32 partition of your SD card
  27. On your SD card rename the Nintendo folder to Emutendo
    If you boot into the emuMMC now all games that you had installed previously are present there
    If you want them to be present in your sysNAND instead for whatever reason leave the folder by its name Nintendo
  28. Edit you're SD:\bootloader\hekate_ipl.ini to cover all your needs (CFW emuMMC, Stock sysNAND, CFW sysNAND, L4T Ubuntu, whatever else you want)
    You can find an example of mine at the end of this guide
    The emuMMC section is important as it has to be exactly like that for Atmosphère to detect it
  29. On your SD root directory create a folder called emuMMC
  30. Inside that folder create an empty text file called emummc.ini and open it with a text editor
  31. Paste into it what I put at the end of this thread and save the file
  1. Put the SD card into your Switch and fire up the hekate payload
  2. Head to emuMMC and MIGRATE - it should detect and migrate it
Congratulations, that should be it. Now you can boot everything from within hekate.
Keep in mind that the initial boot of L4T Ubuntu takes some time while the screen is black. Be patient!
Also let me give you the advice to choose different themes for your sysNAND and emuMMC. I have the white theme enabled in my sysNAND while I have the dark theme in my emuMMC environment so I always definitely know where I am.

Here's my promised hekate_ipl.ini:
Code:
[config]
autoboot=0
autoboot_list=0
bootwait=1
verification=1
backlight=100
autohosoff=0
autonogc=1
{AtlasNX/Kosmos v13.0.2}
{}
{Discord: discord.teamatlasnx.com}
{Github: git.teamatlasnx.com}
{Patreon: patreon.teamatlasnx.com}
{Pegascape DNS: pegascape.sdsetup.com}
{}
{--- Custom Firmware ---}
[CFW (SYSNAND)]
emummc_force_disable=1
fss0=atmosphere/fusee-secondary.bin
kip1patch=nosigchk
atmosphere=1
logopath=bootloader/bootlogo.bmp
icon=bootloader/res/icon_payload.bmp
{}
[CFW (EMUMMC)]
fss0=atmosphere/fusee-secondary.bin
kip1patch=nosigchk
atmosphere=1
logopath=bootloader/bootlogo.bmp
icon=bootloader/res/icon_payload.bmp
{}
[SX OS]
payload=bootloader/payloads/SX_OS.bin
[Argon NX]
payload=bootloader/payloads/Argon_NX.bin
{--- Stock ---}
[Stock (SYSNAND)]
emummc_force_disable=1
fss0=atmosphere/fusee-secondary.bin
stock=1
icon=bootloader/res/icon_switch.bmp
{}
[L4T Ubuntu]
payload=l4t-ubuntu/coreboot.rom

And here's the emummc.ini:
Code:
[emummc]
enabled = 1
sector = 0x2
nintendo_path = Emutendo

I did not test that yet so I can only assume it works, but it should!
In short, from current SD (SD1) to a bigger one (SD2):
  1. CloneZilla: Clone the whole SD1 to SD2
  2. GParted: Delete the EXT4 partition on SD2
  3. GParted: Resize the FAT32 partition on SD2 as you like but leave some space at the end for L4T Ubuntu
  4. GParted: Create an EXT4 partition out of that left unallocated space at the end of SD2
  5. CloneZilla: Clone only the EXT4 partition from SD1 to the newly created EXT4 partition on SD2 (similar to how I did it in the guide above with the temporary flash drive to get Linux onto my SD card)
 
Last edited by lordelan,

lordelan

Well-Known Member
OP
Member
Joined
Jan 4, 2015
Messages
5,769
Trophies
1
Age
44
XP
6,475
Country
Germany
When I went to verify booting from the SD. Hekate complained that I didn’t have a FAT partition. So something is definitely changing in the MBR boot table.
Wow this is really strange.
Before I did all this I've had a big 400 GB single FAT32 partitioned SD card with 32 k cluster size which was working just fine in Horizon (stock, Atmo, SX OS).
Then I just went through the steps from my guide and it really kinda worked "first try" (which still surprises me).
As a side note: It seems that the SD card was MBR and that using Etcher with the L4T image turns the destination device into GPT. That's why I had to "destroy" the partition table with CloneZilla first so there's no mismatch that CloneZilla would complain about.
Of course I destroyed it on the temporary flash drive I flashed the img to and not on my SD card I wanted to use in my Switch again as I didn't care about the flash drive anyway. Gladly that was enough for CloneZilla do to the partition cloning.
 
  • Like
Reactions: Deleted-172301
D

Deleted-172301

Guest
I’m going to try and confirm that resizing the partition isn’t the problem shortly. If thats the case then what I’m going to do is setup everything I need then image my SD without Ext4. This way I can simply restore the good image without having to set it all up again multiple times.
 
  • Like
Reactions: lordelan

lordelan

Well-Known Member
OP
Member
Joined
Jan 4, 2015
Messages
5,769
Trophies
1
Age
44
XP
6,475
Country
Germany
I’m going to try and confirm that resizing the partition isn’t the problem shortly. If thats the case then what I’m going to do is setup everything I need then image my SD without Ext4. This way I can simply restore the good image without having to set it all up again multiple times.
Sounds like a plan. I really hope it turns out working for you at some point. Would be a shame if not.
Good thing you're so obstinately. :P
 
  • Like
Reactions: Deleted-172301
D

Deleted-172301

Guest
Its the resize... I can't believe it. When I resize Fat in Gparted it breaks readability on the switch... Going to try and fix this in windows.
 
  • Like
Reactions: lordelan

lordelan

Well-Known Member
OP
Member
Joined
Jan 4, 2015
Messages
5,769
Trophies
1
Age
44
XP
6,475
Country
Germany
Its the resize... I can't believe it. When I resize Fat in Gparted it breaks readability on the switch... Going to try and fix this in windows.
Really?! What?! That's exactly what I did. Wow ...
But at least you found the problem. Now you "only" need to try out countless resize methods until one works lol.
 
  • Like
Reactions: Deleted-172301
D

Deleted-172301

Guest
According to windows. GParted formats the FAT32 partition into a "RAW" format. I've already created an Ex4 partition. Going to verify that the switch reads the corrected Fat32 then try and restore 1.img. Based off of this mess. It seems like we can only use windows tools to format, resize, or edit the MBR boot table. After fixing the partition in windows. The SD is detectable again...

New steps to take:
  • SXOS to create EmuNand
  • Resize FAT32 Partition using windows. Leave at least 10gb free AFTER the Fat32 partition.
  • Use Windows or Ubuntu to create ext4 on newly created space
  • Restore 1.img to ext4 using disks in ubuntu
  • Boot into every OS to confirm.

So Linux has booted successfully as well...


What a headache... Now that I know this works... I’m going to clean this up and experiment. I still want my Linux partition to reside before Fat32. Going to try that later on this week.

For now I can confirm that this is working!!
 
Last edited by ,
  • Like
Reactions: lordelan and Cyan

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
45
Location
Engine room, learning
XP
15,646
Country
France
Thank you for your finding :)
that's strange that resizing FAT32 changes the MBR to raw. maybe the Linux's FAT32 code used by GParted is uncommon and used only by linux?


let us know if it works fine with Linux partition before FAT partition.
In case it doesn't, don't worry too much because there's a way to fix that. hacky way, but it works ! Edit the MBR in hexeditor to swap partition position. make the "first" seen in the table the FAT one, even if physically located after Linux partition. the table only has a "start + length" info, it doesn't number them. just swap the partition 1 and 2 in the table ;)
managers and OS should be able to access the partition without problem, it'll just be reset back to real physical order if you ever edit the partitions in a partition manager.
 

lordelan

Well-Known Member
OP
Member
Joined
Jan 4, 2015
Messages
5,769
Trophies
1
Age
44
XP
6,475
Country
Germany
maybe the Linux's FAT32 code used by GParted is uncommon and used only by linux?
As I wrote I definitely used GParted for resizing and it worked on my end (god knows why). This is so strange.
But really cool that you got it working, @~~Tito~~ :)
let us know if it works fine with Linux partition before FAT partition.
In case it doesn't, don't worry too much because there's a way to fix that. hacky way, but it works ! Edit the MBR in hexeditor to swap partition position. make the "first" seen in the table the FAT one, even if physically located after Linux partition. the table only has a "start + length" info, it doesn't number them. just swap the partition 1 and 2 in the table
Now that's some smart workaround. :)
 
D

Deleted-172301

Guest
I don't know why the format was off when using gparted, but I am glad that its working. lol

@Cyan If I were to do that. Would I have to manually calculate the values used for the sectors? At this point I'm pretty lazy and I'm enjoying the switch lol.
 
  • Like
Reactions: lordelan

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
45
Location
Engine room, learning
XP
15,646
Country
France
Thanks for posting your partition hex values :)
MBR is fine, and partitions start look good too.
I don't know why the format was off when using gparted, but I am glad that its working. lol

@Cyan If I were to do that. Would I have to manually calculate the values used for the sectors? At this point I'm pretty lazy and I'm enjoying the switch lol.
noo, not at all.
create your two partitions (the unallocated MMC partitions is not a real partition, just nothing defined for it) using any tools you want.
once done and you have your partitions set, the MBR already contains the starting sector and size of both the Ext4 and FAT32 partitions :


4 MBR's primary partitions table :
1 - 00 01 01 00 83 FE FF FF 02 20 A4 03 FE 07 40 01 (Type Linux (83), starts around 30GB from the start, at 0x03A42002, right after MMC)
2 - 00 FE FF FF 0C FE FF FF 00 28 E4 04 00 D8 B8 36 (Type FAT32 (0C), starts around 38GB, after Linux)
3- empty
4- empty
the MMC is not defined, it's not raw but unallocated, starts from sector 1 to 0x03A42001

edit the MBR to swap the informations entirely, swap line 1 and 2 to have the FAT32 into the first slot of the table. keep all the same values
1 - 00 FE FF FF 0C FE FF FF 00 28 E4 04 00 D8 B8 36 (Type FAT32 (0C), starts around 38GB, after Linux)
2 - 00 01 01 00 83 FE FF FF 02 20 A4 03 FE 07 40 01 (Type Linux (83), starts around 30GB from the start, after MMC)
3- empty
4- empty

see, the FAT32 still starts after linux, but it's listed first in the table. there's nothing to calculate, just swapt the partition in the table.
it's like the table lists partition in reversed order, that's all, but their position and size are identical, you just swap the entire definition, no need to calculate anything.
like I said, partition manager could have issues with this, thinking anything located "before the LBA Start of the first defined partition in the table" is unallocated (meaning the linux partition could be also part of the unallocation). it all depends how tools are dealing with random partition definition order.


But, that's only if the switch works fine with FAT32 being listed first.
if you manage to make the switch work with FAT32 being listed second, then don't bother doing it. it was just an idea based on what you reported on previous page.
 
Last edited by Cyan,

tabzer

This place is a meme.
Member
Joined
Feb 15, 2019
Messages
5,844
Trophies
1
Age
39
XP
4,910
Country
Japan
I can boot between LAKKA and L4T. I didn't run into any issues setting it up, and frankly I am confused what people are talking about. (OP and Cyan)

I did it on Windows:

Using OSFMount you can mount the L4T image. You can mount the boot partition and the ext4 partition.

Using Diskgenius, I was able to create a 16GB partition followed by a 32GB partition at the end of my SD card. I was able to use Diskgenius to CLONE the ext4 partition from the image, to the 16 GB partition on my SD card. I was able to use the 32GB partition for emummc. Didn't need SXboot garbage. Did Tariq's method with DD -> https://gbatemp.net/threads/emummc-setup-win-linux-quadboot.541152/

For the FAT32 partition of the L4T image, copied all those files to a temporary directory, as wanted to apply the patches first. Got the patch from the L4T and deleted the files as requested by the L4T thread and added patch files. Put the completed product into the main partition. Add Lakka to primary partition. Setup Hekate.

I CAN boot between L4T, CFW, AND LAKKA with jig. I turned of autorcm for OFW and online play
 
Last edited by tabzer,
  • Like
Reactions: Deleted-172301

lordelan

Well-Known Member
OP
Member
Joined
Jan 4, 2015
Messages
5,769
Trophies
1
Age
44
XP
6,475
Country
Germany
I turned of autorcm for OFW and online play
Interesting post. Thx for letting us know that it can be done way easier.

But why did you turn off AutoRCM? I'm booting into stock (non CFW) sysNAND and playing online just fine with AutoRCM enabled.
 

tabzer

This place is a meme.
Member
Joined
Feb 15, 2019
Messages
5,844
Trophies
1
Age
39
XP
4,910
Country
Japan
But why did you turn off AutoRCM? I'm booting into stock (non CFW) sysNAND and playing online just fine with AutoRCM enabled.

Frankly, I am not certain of how much information is being logged in the boot sequence, so I try go safe.

Are you using fusee-secondary? Do you mind sharing a copy of the OFW configuration you use with hekate (5.0.1)? I might end up going back to autorcm, but I am not in a hurry.
 

lordelan

Well-Known Member
OP
Member
Joined
Jan 4, 2015
Messages
5,769
Trophies
1
Age
44
XP
6,475
Country
Germany
Frankly, I am not certain of how much information is being logged in the boot sequence, so I try go safe.

Are you using fusee-secondary? Do you mind sharing a copy of the OFW configuration you use with hekate (5.0.1)? I might end up going back to autorcm, but I am not in a hurry.
I'm really using absolute default config from Kosmos. Only added SX OS and L4T Ubuntu to it. :)
 
  • Like
Reactions: tabzer

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
45
Location
Engine room, learning
XP
15,646
Country
France
your setup is probably easier and working fine because you end with 3 partitions, with FAT32 first ?
what he tried to do in this thread is make SXOS compatible setup (with mmc at the beginning), and using l4t image would overwrite each other.

It's a guide for users with existing, or want to use, SXOS MMC.
what he wanted to achieved is that order:
MMC, FAT32, linux.

What lordelan did is flash the l4t image to another device, mount it in clonezilla to dump individual partitions to new image to write them back to SD in the order he wanted. it's only overcomplicated because he didn't know how to extract single partition from the full device image.
But fat32 and linux partitions can be read individually from the l4t image using dd (or diskgenius? or any other tools), no need to write them to a temporary device first. once you have the linux partition, you can write it to SD where you want and should be as easy as Tariq's guide.



Most guides end up expanding the Linux partition to fill the SD card size. but isn't FAT32 better to be bigger than linux? when you buy/install games to SD, it goes to FAT32/exFAT partition, not ext4.
Checking the MBR, I think FAT32 is 500MB? unless I miscalculated.
I guess partitions can be moved after flashing the l4t image, but if linux was first it would be easier to expand the fat32, instead of expanding the ext4, or moving it to make space for fat32, without overlapping the mmc at the end of the card.

the ext4 only contains linux's OS files, no homebrew and data right? these will go on FAT32?
so what I suggested is put FAT32 at the end:
32G MMC, 8G linux, remaining FAT32

which is what tito tried.
The issue Tito had is that he got no partition found on switch when doing it that way. I made a supposition that his MBR could be messed up, but it seems fine. only issue is that FAT32 is not listed first on the table. Maybe the switch doesn't mount the "first FAT32" but the "first listed" partition, because SD card for Switch are not supposed to have more than one, and Nintendo might have hardcoded the first partition. that's why I suggested to edit the MBR table to place FAT32 as first partition even if physically located farer.
create 3 partitions, write bin to MMC and Linux, edit MBR to put FAT32 first, linux second. (MMC unallocated). This is yet to be tested.

Edit:
And we could even now do a 5-boot method, with Android partition:
https://gbatemp.net/threads/experie...ly-released-version-of-lineageos-15-1.544519/
just follow the same method to write android to any partition.
 
Last edited by Cyan,
  • Like
Reactions: Deleted-172301

tabzer

This place is a meme.
Member
Joined
Feb 15, 2019
Messages
5,844
Trophies
1
Age
39
XP
4,910
Country
Japan
You could do it in any order using the method I described, because hekate is reading from the FAT32 before it forwards boot.scr command to tell it to boot from the ext4 partition. The boot.scr might need decrypted/edited/reencrypted, to have the partition reference modified to point at the 3rd partition instead of the 2nd. Maybe it'll work without that step. I didn't test it.

Most guides end up expanding the Linux partition to fill the SD card size. but isn't FAT32 better to be bigger than linux? when you buy/install games to SD, it goes to FAT32/exFAT partition, not ext4.
Checking the MBR, I think FAT32 is 500MB? unless I miscalculated.
I guess partitions can be moved after flashing the l4t image, but if linux was first it would be easier to expand the fat32, instead of expanding the ext4, or moving it to make space for fat32, without overlapping the mmc at the end of the card.

This is why I made my partitions first, and then cloned using diskgenius. Diskgenius will adapt to the size of the partition it is cloning to, so for the example of the ext4 partition, you don't have to tell linux to extend after the fact. Since I already have all my stuff on FAT32, I found it easier just to copy the files from the image, instead of "etching" or cloning the image.

I'm using 400GB SD, and the bulk is dedicated to fat32 for typical Switch CFW stuff. I use about 16GB for l4t (maybe it's too much) and then 32GB for emummc. With SXOS, it might be possible that it looks at the second partition for FAT32 when its emunand is used.

So tito might have to keep the EMUNAND/FAT32/L4T order if persisting with SXOS:

And change the partition reference in boot.scr by decrypt-> edit -> reencrypt

"dd if=boot.scr of=boot.txt bs=72 skip=1"
Decrypts

mkimage -A arm -T script -O linux -d boot.txt boot.scr
Encrypts

Don't exactly know the partition address layout. But it shouldn't be too hard to figure out once you have the boot.txt file opened.

Edit:
And we could even now do a 5-boot method, with Android partition:
https://gbatemp.net/threads/experie...ly-released-version-of-lineageos-15-1.544519/
just follow the same method to write android to any partition.

Except the complication is that the lineageos has like 5-7 partitions of wtfuckery.

the ext4 only contains linux's OS files, no homebrew and data right? these will go on FAT32?

That doesn't sound right. ext4 needs to be ext4. There is a case with drivegenius, when cloning a ext4 image to a fat32 partition, it will convert the fat32 partition to ext4.
 
Last edited by tabzer,
  • Like
Reactions: Cyan

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
45
Location
Engine room, learning
XP
15,646
Country
France
That doesn't sound right. ext4 needs to be ext4
I meant : which file need to be on the ext4 ? only essential linux files, kernel, etc.

All the homebrew and games data are not required to be on ext4 and can be located on FAT32?

"dd if=boot.scr of=boot.txt bs=72 skip=1"
Decrypts

mkimage -A arm -T script -O linux -d boot.txt boot.scr
Encrypts
that's probably what we missed !
 
Last edited by Cyan,

tabzer

This place is a meme.
Member
Joined
Feb 15, 2019
Messages
5,844
Trophies
1
Age
39
XP
4,910
Country
Japan
I meant : which file need to be on the ext4 ? only essential linux files, kernel, etc.

All the homebrew and games data are not required to be on ext4 and can be located on FAT32?
Yeah, homebrew and games data is useless on ext4. Switch CFW and OFW deosn't support it. What L4T can do, is access the FAT32 partition as storage just fine.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    LeoTCK @ LeoTCK: yes for nearly a month i was officially a wanted fugitive, until yesterday when it ended