Virtual SD card for Android. Download AParted (Sd Card Partition) for Android. An application for creating and managing partitions on an SD card on Android. Preparing for stakeout

The need to split a memory card into several sections usually arises when an Android phone/tablet does not have enough built-in memory to install applications. By performing a similar operation, you can free up space on your phone, for example, by moving to the second section of a microSD card. Previously, we already told you how you can create/merge partitions on a memory card using and.

It is not always possible to find a recovery for a specific phone/tablet that supports memory card partitioning, so in this article we will tell you how to do this using the Android application AParted.

This application provides the following features (from the official documentation):

  • Partitioning of external/internal memory of an Android device.
  • Formatting the external/internal memory of an Android device.
  • Removing partitions.
  • Checking and fixing file system errors.
  • Resizing partitions.
  • Updating file systems.

In this article we will use only the first of them.

Preparing for stakeout

Before splitting, be sure to make a backup copy of your important data (photos, videos, etc.), since all files will be deleted from the memory card during the splitting process.

Make sure that is present on your phone; without it AParted will not work.

Before launching the application, you must disable the memory card in the Android settings. To do this, go to "Settings > Memory", in the connected microSD card section, click on the "Safely Remove" item and confirm the action.

Layout of future sections

Launch the AParted application, on the "CREATE" tab you will see two graphical representations of the memory card in the form of rectangles: the lower rectangle with the inscription "SD memory card msdos partition tables" displays the current partition layout, and the upper one "New msdos partition tables" - the layout of future partitions on microSD card.

Click on the "ADD" button to add the first section and use the slider to specify its size. This section will be available to the phone/tablet as external memory for photos, music, etc. For a more accurate breakdown, click on the number with MB, in the field that appears, enter the exact size in megabytes and confirm the changes by clicking “OK”. Leave the "Format" checkbox enabled and the "fat32" file system unchanged.

Click on the "ADD" button again to add a second partition on the microSD card, which in the future will serve as an extension of the system memory of the Android device. Use the slider to select all the remaining space, leave the "Format" checkbox enabled, click on the "fat32" inscription and select one of the following file systems: "ext2", "ext3" or "ext4".

And here is where the fun begins, it is advisable to select the “ext4” option, but there are a number of reasons why you will not be able to create a partition in this file system: the kernel/firmware of the Android system, the class/manufacturer (quality) of the memory card, etc.

Therefore, experiment, try first creating a partition with “ext4”, then “ext3” and “ext2”. After all, the Link2SD app supports all of the above file systems.

After performing the operations above, the rectangle labeled “New msdos partition tables” should display the layout of the future partitions of your memory card.

Performing a stakeout

To apply the layout of new partitions to the memory card, click on the "APPLY" button. The AParted application will warn you that all data on the removable media will be erased.

Next, the process of partitioning and formatting the memory card partitions will be displayed, upon completion of which the lower graph “SD memory card msdos partition table” will display the result of media partitioning. Go to “Settings > Storage” of your phone/tablet again and in the external memory section, click on “Connect SD card”. After connecting and analyzing the microSD card by the Android system, you will see that its memory has decreased to the size you set.

If the phone status shows a message that the SD card is damaged, reboot the Android system, after rebooting the memory card should connect automatically.

Setting up Link2SD

Install and run. The program should automatically detect the presence of a second partition on the memory card and prompt you to create a mount script. Select in the list the file system of the second partition that you specified when partitioning the memory card in the AParted application, confirm the request and after completing the operation, click on the “Reboot device” button.

After rebooting the Android system, you can transfer applications from the device memory to the second partition of the external memory card.

Dolphin can store data to a virtual SD card named sd.raw. By default, it will be created with the size of 128MB.

The virtual SD card has important use for homebrew apps on Dolphin. Project M and Mario Kart Wii custom tracks are two good examples, as some homebrew apps can only work using files stored on the SD card of the real hardware for which they were designed.

Contents

Creating a Virtual SD Card

It is recommend to create one with size at least 1GB for large homebrew apps, for example, Project M, and no more than 2GB for best compatibility as there are compatibility issues with some homebrew apps trying to run under an SDHC card on the real hardware .

Command Line and Executable Files

WinImage is unreliable, because oddly enough, it will cause desync and few other unforeseeable problems. ImDisk will be fine.

Quick guide for mounting and editing the virtual SD card with the ImDisk Virtual Disk Driver:

  1. Right-click on sd.raw file then click "Mount as ImDisk Virtual Disk" from the context menu.
  2. Check box Removable media then hit "OK". The predefined drive letter and everything else will do just fine.
    • The virtual SD card will now appear as "Removable Disk" in which the native Explorer window can read and write in there.
  3. When done editing the virtual SD card, simply unmount it by right-click on the "Removable Disk" then click "Unmount ImDisk Virtual Disk" from the context menu.
    • The virtual SD card must be dismounted before using with Dolphin.

Dolphin Setting

Go to Options > Configure... > Wii > and enable Insert SD Card.

Usage

With Homebrew App

The external files used for the homebrew app must be stored within sd.raw and the homebrew app itself ( boot.elf or boot.dol) must exist outside of it for Dolphin to load. Project M, for example, will load from SD root \projectm\ and Dolphin will need to launch Project M through \apps\projectm\boot.elf, NOT in the virtual SD card. For convenience"s sake, it is ideal to have same copies paralleled between inside and outside of the virtual SD card.

Though, it is possible to start homebrew app from virtual SD card through homebrew exploits for Wii.

The Wii game launcher app will only work if a particular Wii game is set as the default ISO. Within the Dolphin game list, open context menu (right-click) on any Wii game and click Set as default ISO. Do this before loading a homebrew app with Dolphin.

For Netplay

Netplay will eventually desync if anything reads the virtual SD card that is not cloned, regardless of the same size it was created, and identical file/folder structures within its root. To prevent that, sd.raw must be copied from host"s computer to joiners" computers before starting netplay. If the virtual SD card was used offline or online with write block disabled, the MD5 checksum will change ("Date Accessed" of the files are what"s different in virtual SD card), but will not cause desync. The SD card got to be coming from elsewhere or subjected to the files modified within to be "different".

For the Wii game launcher app, users on both ends must have the same copies of homebrew app and the game in their game list first, then set the game as default ISO, as mentioned in previous section.

This tool allows you to create and manage partitions on the SD card/USB drive of your phone or tablet. You can add more RAM to your device by creating a swap partition. You can also repair damaged SD card file systems. Only supports "main" partition type.
Functions:

  • creating partitions;
  • deleting partitions;
  • recovery of damaged file systems.

Supported file systems:

  • FAT16, FAT32, EXT2, EXT3, EXT4, SWAP, NTFS (starting from the MoalBoal version).

Requirements:

  • Root phone;
  • availability of Busybox;
  • installation into internal memory;
  • Before starting to work with the application, disconnect the SD card.

Instructions on how to create partitions using the program

The very first thing is to transfer all your valuable files from the flash drive to your PC, that is, after that everything will be deleted from the flash drive.

- Open the program

In the Create section, double-click the plus sign “+”

The first section "Part 1" select Fat32, the second "Part 2" select the desired ext2/3/4 or swap.
- Use the slider to set the size of each section; the “Format” checkbox should be checked.

Confirm "Ok"

All is ready.

How to return a flash drive to full capacity
If you decide to delete the second partition from the flash drive, you can do this.
- Go to the phone settings, “Memory” and click “Remove SD card”.
- Open the program
- In the Create section, click the plus sign “+” once
- In "Part 1" select Fat32, set the slider to the full capacity of the flash drive, the "Format" checkbox should be checked.

Soft key, click "apply changes"

While developing a competition application, I encountered a database storage problem. The problem was how do I identify the external memory card. In general, a search on the Internet did not give an exact answer. Therefore, combining all the results found, I assembled my class. If anyone is interested, look under the cut.

So, let's start with the theory.

Terminology

Google tells us that there are the following concepts:
  1. Internal ( internal) memory is part of the memory card built into the phone. When used by default, the application folder is protected from access by other applications (Using the Internal Storage).
  2. External ( external) memory is the general "external storage", i.e. this can be either part of the built-in memory or a device that can be removed. Usually this is part of the built-in memory, the last time I saw a device being removed was on Android 2.2, where the built-in memory was about 2GB, and the connected memory became external (Using the External Storage).
  3. Deleted ( removable) memory - all storage that can be removed from the device without “surgical” interventions.

Prior to KitKat 4.4, the API did not provide functionality for retrieving external memory paths. Starting with this version (API 19), the public abstract File function appeared getExternalFilesDirs(String type), which returns an array of strings with paths to internal and external memory. But what about our SD Card, which is inserted into the slot? We again cannot get the path to it.

searching results

To answer the question, I turned to the all-knowing Google. But he didn’t give me a clear answer either. Many definition options were considered, from using standard functions that lead to external memory, but they have nothing to do with the storage devices being removed, to processing device mounting rules (Android runs on the Linux kernel). In the latter cases, “hardwired” paths to the folder with mounted devices were used (this directory is different in different versions). Do not forget that mounting rules change from version to version.

Ultimately, I decided to combine all the knowledge I had gained and wrote my own class, which can return paths to external and deleted devices.

Code description

A class has been created MountDevice, which contains the path to the device, the device type and a hash.
There are two types of devices (I did not touch the internal memory, since it can be accessed through the system API).

Public enum MountDeviceType ( EXTERNAL_SD_CARD, REMOVABLE_SD_CARD )
And the class was created StorageHelper, which searches for available memory cards.

The StorageHelper class implements two search methods - through the system environment ( Environment) and using the Linux utility mount, or rather the result of its execution.

Method one - Environment
When working with the environment, I use the standard getExternalStorageDirectory() function to obtain information about external memory. To get information about the memory being deleted, I use the environment variable " SECONDARY_STORAGE".

There is always one external memory and usually always exists, so we check it for readability, calculate the hash and remember it. There can be a lot of memory to be deleted, so it is necessary to split the resulting string by delimiter and check each value.

function fillDevicesEnvirement

String path = android.os.Environment.getExternalStorageDirectory() .getAbsolutePath(); if (!path.trim().isEmpty() && android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) ( testAndAdd(path, MountDeviceType.EXTERNAL_SD_CARD); ) // Get the remover String rawSecondaryStoragesStr = System.getenv("SECONDARY_STORAGE"); if (rawSecondaryStoragesStr != null && !rawSecondaryStoragesStr.isEmpty()) ( // All Secondary SD-CARDs split into array final String rawSecondaryStorages = rawSecondaryStoragesStr .split(File.pathSeparator); for (String rawSecondaryStorage: rawSecondaryStorages) ( testAndAdd(rawSecondaryStorage, MountDeviceType.REMOVABLE_SD_CARD); ) )


The solution was taken from stackoverflow. The answer is somewhere down there.
Method two - mount
Since I couldn’t get the system to tell me the path to the memory being deleted for a long time, I decided to look in the direction of mounted devices. The system has configuration files that describe the rules for mounting external devices. Everything would be fine, but on Android version 4.* mere mortals do not have access to this file, so I will not consider this method.

Let's return to the mount utility. When run without parameters, the command returns a list of mounted file systems. The devices being deleted are usually in the FAT file system format, so we will highlight lines that contain the characteristic " fat". External memory will be characterized by the parameter " fuse".

Note: when using this method, the types of mounted devices are not always determined correctly (most likely I did not take something into account). I noticed the difference on different versions of Android. Therefore, this method can be used as an additional one.

fillDevicesProcess function

try ( Runtime runtime = Runtime.getRuntime(); proc = runtime.exec("mount"); try ( is = proc.getInputStream(); isr = new InputStreamReader(is); br = new BufferedReader(isr); while ( (line = br.readLine()) != null) ( if (line.contains("secure")) continue; if (line.contains("asec")) continue; if (line.contains("fat") ) (// TF card String columns = line.split(" "); if (columns != null && columns.length > 1) ( testAndAdd(columns, MountDeviceType.REMOVABLE_SD_CARD); ) ) else if (line.contains(" fuse")) (// internal(External) // storage String columns = line.split(" "); if (columns != null && columns.length > 1) ( // mount = mount.concat(columns + " \n"); testAndAdd(columns, MountDeviceType.EXTERNAL_SD_CARD); ) ) ) ) finally ( ... ) ) catch (Exception e) ( ... )

The source code for the entire class is not located anywhere yet. One of these days I'll try to post it on gitHub.

Who else uses what methods?

Tags: Add tags

Some Android devices have slots for memory cards (usually microSD format). If your device supports SD cards, you can:

  • increase memory capacity;
  • use the card for some functions and applications.

To find out if your device has an SD card slot, visit the manufacturer's website.

Note. Some of these steps can only be performed on devices running Android 6.0 and later.

How to install an SD card

Step 1: Insert the SD card.
  1. Check where the SD card slot is located.
  2. Turn off your phone.
  3. Remove the SD card tray or remove the back cover of the device (depending on the model). If necessary, lift the tab that holds the card.
  4. Place the SD card in the slot. If you raised the retaining tab, lower it.
  5. Reinstall the SD card tray or back cover of the device.
Step 2: Turn on the SD card.
  1. Wait for the SD card notification to appear.
  2. Click Tune.
  3. Select the desired storage type.
    • Removable storage:
      You can transfer the card to another device along with all your files (such as photos and music). Applications cannot be moved to a removable drive.
    • Inner memory:
      The card can store apps and data only for that device. If you move it to another device, all data on it will be deleted.
  4. Follow the onscreen instructions to set up your SD card.
  5. When finished, click Ready.

How to use an SD card

How to move apps to SD card

If you have connected the card as internal storage, you can transfer applications to it.

Note. Not all applications can be transferred to an SD card.

How to move files to SD card

If you have installed an SD card as a removable storage device, you can transfer various files to it, such as music and photos. After that, they can be deleted from the device’s internal memory.

Step 1: Copy files to SD card.

Step 2: Delete files from your internal storage.

You can view the contents of the SD card and see how much space is left.

When the SD card is used as internal storage

When the SD card is used as a removable storage device

  1. Swipe down from the top of the screen to open the notification panel.
  2. Under the SD card notification, tap Open.