[HOWTO] "Partitioning" your Nexus S using LVM

Search This thread

ILCAMPIONE

Senior Member
May 23, 2009
71
7
sorry @KreAch3R but i dont understat this point

"MODIFY FRAMEWORK-RES.APK"

which changes i must intergrate? where i can find them?

thanks

Ps. May be saturday i will try on my grilsfriend's smarthphone .... will you be online, saturday or sunday??? (If i will need help???)
 

KreAch3R

Inactive Recognized Developer
Nov 15, 2010
1,080
2,020
sorry @KreAch3R but i dont understat this point

"MODIFY FRAMEWORK-RES.APK"

which changes i must intergrate? where i can find them?

thanks

Ps. May be saturday i will try on my grilsfriend's smarthphone .... will you be online, saturday or sunday??? (If i will need help???)
This is the wrong thread, go to my thread and find the necessary changes in my git repository (link included). It is a small change in storage-list.xml. Be careful when following my guide, do not use the files from this thread, you should only apply the procedure used here, to my guide.

I could help you but I don't know if I am going to be free/close to a PC on the weekend. I am currently studying for exams. I am notified however, when posts come up to my threads, so shoot there and I will try to answer ASAP.:)
 

Eleanor1967

Senior Member
Feb 18, 2013
70
14
Hey guys,

I just wanted to ask if this thread is the right solution for my problem (because I'm a noob and I haven't understand to much after reading whole thread). I have a Galaxy S1 with a super slow internal memory (2mb/s read / 0.5 mb/s write ) and the internal sd isn't doing to hot, too. So I wanted to use a externel sdcard as system partition and maybe use the internal stuff for extra space. Am I right in thinking that this thread will help me achieving this ? (sorry for the probably dumb question, last time I played with something linuxlike ext4 was the new hot ****.)

All the best

Eleanor1967
 
Last edited:

Spacexplosion

New member
Jul 28, 2015
1
0
I have the newest ClockworkMod recovery image and the 4.1.2+ boot image with LVM if anyone is interested. How do I attach them to a post?

---------- Post added at 06:51 AM ---------- Previous post was at 06:41 AM ----------

Hey guys,
I have a Galaxy S1 with a super slow internal memory (2mb/s read / 0.5 mb/s write ) and the internal sd isn't doing to hot, too. So I wanted to use a externel sdcard as system partition and maybe use the internal stuff for extra space.

Eleanor,
The general approach of using LVM could theoretically do what you're looking for, but everything might be different with a Galaxy S1.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 9
    Always wanted a larger /data partition? Want to add a swap partition or an extra partition for your Debian/Ubuntu/Fedora chroot? Want your ROM to have the combined /data and /sdcard of Honeycomb and ICS devices? Then this guide is for you.

    Table of contents

    The Linux [URL="http://sourceware.org/lvm2/]Logical Volume Manager[/URL] (LVM) is a set of tools which allows you to create virtual disks ("logical volumes", "LVs") backed by a set of real storage devices ("physical volumes", "PVs") organized into "volume groups" ("VGs"). Using LVM, you can:

    • Create logical volumes which are larger than any of the individual physical volumes available on your device's real storage.
    • Create an arbitrary number of logical volumes of arbitrary size, regardless of the number of physical volumes or partitions available on your real storage devices. You could, for example, add a dedicated swap partition, or create a separate /system and /data for a dual-boot setup.
    • Take a snapshot of a logical volume -- a copy of the LV which only stores differences between it and the original (requires additional kernel support). You could, for example, take a snapshot of the external storage LV and export it via USB mass storage to a computer, without needing to unmount the LV from your device.
    • Grow or shrink logical volumes without unmounting the file system ("online resize", requires filesystem support).

    LVM was developed to manage storage on Linux servers and workstations, but was also used by Palm/HP in WebOS devices. It uses the Linux device-mapper technology used in Android for apps installed on the SD card, so any Android kernel will work with LVM.

    This guide was developed with the Nexus S in mind, but the technique described should be applicable to many other Android devices as well.
    7
    Modifying your phone to use LVM

    WARNING WARNING WARNING

    While unlikely, you could brick your phone if you do this incorrectly!!!

    Read this guide completely before attempting. If you don't understand the procedure, read it again until you do. If you still don't understand, wait for someone else to make this easier. If you're not sure you understand, you probably don't.

    BACK UP EVERYTHING ON YOUR PHONE, INCLUDING THE CONTENTS OF /sdcard, BEFORE ATTEMPTING THIS PROCEDURE! This will erase everything on your phone.

    The preassembled images attached to this post are for Nexus S GT-i9020T running stock Android 4.0.4 IMM76D ONLY. They may or may not work with other phones and ROMs. (See the next post for how to modify any ROM to use LVM.)

    You will need:
    • A Nexus S with unlocked bootloader
    • A computer with fastboot and adb installed and working
    • A USB cable
    • Factory images for your phone, in case something goes wrong

    Procedure:
    1. Take a nandroid backup of your phone and copy it to your computer. We'll use it to restore the ROM later. You MUST copy the backup to your computer! This procedure will erase EVERYTHING on your phone, including the contents of /sdcard.
    2. Download the boot and recovery images attached to this post. Reboot your phone into the bootloader, then flash the recovery to your phone using fastboot:
      Code:
      fastboot flash recovery recovery-lvm-clockwork-5.0.2.0-crespo.img
      (GPL information: this is the stock kernel image from ClockworkMod 5.0.2.0. For LVM source, see this post.)
    3. Boot into recovery.
    4. Enter the shell on the device:
      Code:
      adb shell
      In the shell on the device, do the following (# is your prompt):
      Code:
      # /lvm/sbin/lvm pvcreate /dev/block/mmcblk0p1 /dev/block/mmcblk0p2 /dev/block/mmcblk0p3
      # /lvm/sbin/lvm vgcreate lvpool /dev/block/mmcblk0p1 /dev/block/mmcblk0p2 /dev/block/mmcblk0p3
      This marks the partitions normally used for /system, /data, and /sdcard for use with LVM, and creates an LVM volume group named "lvpool" using those devices.
    5. In the shell on the device, set up your desired logical volumes (partitions).
      Code:
      # /lvm/sbin/lvm lvcreate -L 320M -n system lvpool
      # /lvm/sbin/lvm lvcreate -L 1G -n userdata lvpool
      # /lvm/sbin/lvm lvcreate -L 10G -n media lvpool
      [...]
      This creates the mandatory logical volumes named "system", "userdata", and "media", which will be mounted on /system, /data, and /sdcard, respectively. Replace the argument to -L with the desired size of each partition. (/system needs to be at least 300 MB to fit the stock ROM.) You can create additional volumes similarly:
      Code:
      # /lvm/sbin/lvm lvcreate -L [size] -n [name] lvpool
      replacing [size] with the desired size and [name] with the desired name. You have a little less than 15 GB space in the volume group to work with; depending on how many partitions you want to create, you can adjust the size of the "media" and "userdata" logical volumes as required.
    6. Reboot back into recovery. Mount the USB storage on your computer. On your computer, format your phone's USB storage as you would a USB flash drive.
    7. Copy your nandroid backup from your computer onto your phone.
    8. Reboot back into recovery. Restore the nandroid backup.
    9. Reboot into the bootloader. Flash the boot image to your phone via fastboot:
      Code:
      fastboot flash boot boot-lvm-crespo-IMM76D.img
      (GPL information: this is the stock kernel image for IMM76D. Source is available from AOSP git. For LVM source, see this post.)
    10. Reboot. You should have a working device running on LVM.

    Additional tips and hints
    • To see the logical volumes you've created, use
      Code:
      # /lvm/sbin/lvm lvs
      and to see how much free space you have remaining in the volume group, use
      Code:
      # /lvm/sbin/lvm vgs
    • If you want to delete a logical volume (for example, if you screwed up), use
      Code:
      # /lvm/sbin/lvm lvremove /dev/lvpool/name
      (replacing "name" with the name of the LV you want to delete).
    • It's often useful to leave a bit of free space in the volume group (512 MB to 1 GB or so). This gives you a bit more flexibility to modify the layout or grow partitions in the future, and allows you to take snapshots of logical volumes.

    Removing LVM from your phone
    1. Flash a standard recovery such as the regular ClockworkMod recovery to your phone.
    2. Do a full wipe/factory reset.
    3. Restore your phone from a backup.

    If things go really wrong, flash the factory image to your phone via fastboot.
    4
    Modifying an existing ROM to use LVM

    (This is a condensed version of the full guide: https://raw.github.com/steven676/android-lvm-mod/master/HOWTO-MOD)

    You will first want to grab a copy of the binaries and config files by cloning my git repository: https://github.com/steven676/android-lvm-mod.

    Unpack the ramdisks from your boot and recovery images. Make the following changes:
    • Copy the contents of lvm-bin/ in the git repository to lvm/ in the ramdisks.
    • Copy devices/crespo/lvm.conf to lvm/etc/lvm.conf in the ramdisks.
    • For the boot image, integrate the changes in devices/crespo/boot/init.herring.rc-changes.diff into your init.herring.rc.
    • For the recovery image, integrate the changes in devices/crespo/recovery/init.rc-changes.diff into your init.rc.
    • For the recovery image, copy devices/crespo/recovery/recovery.fstab to etc/recovery.fstab.
    Repack the ramdisks and create new boot and recovery images with them (the original kernels are fine to use).

    If creating a flashable zip to install your ROM, you will also want to modify the installer script to set up the LVM volume group and logical volumes (see the previous post).

    If you're building your own kernel, consider enabling CONFIG_DM_SNAPSHOT in your kernel's build configuration, to allow taking snapshots of logical volumes.

    Remember that LVM is released under the terms of the GPL v2 (same as the Linux kernel), so you are required to comply with the GPL's source distribution requirements with respect to LVM.

    More extensive modifications (such as changing the devices used to form the volume group) are possible; see the full HOWTO guide for details.
    3
    Building LVM from source for Android

    The LVM source was written for standard glibc-based GNU/Linux systems, and doesn't build agains Android libc. We could invest time and effort into porting it to Android, but it's easier to just statically link the LVM binary against glibc (we already have to use a statically linked binary, since the boot image doesn't ship shared libraries).

    To build LVM with glibc, you will need either an actual GNU/Linux ARM system with a development environment (gcc, make, and glibc header files) set up, or a GNU/Linux ARM cross-compiler toolchain (more difficult to set up). The binaries in lvm-bin/ were compiled with an Emdebian squeeze/armel toolchain running on a Debian squeeze/amd64 machine; this procedure has also been tested with a Nexus S running a Debian squeeze chroot (though any recent Linux distribution and any device should do). The Linaro prebuilt GCC toolchain and the CodeSourcery CodeBench Lite toolchain for ARM GNU/Linux should work; the Android NDK toolchain will not.

    Getting the source

    Clone the lvm-mod git repository. Then, in the newly cloned repository, do
    Code:
    git submodule init
    git submodule update
    You will have a copy of the LVM source (as used to build the binaries in lvm-bin/) in lvm-src/.
    (Alternately, clone https://github.com/steven676/lvm2 and checkout branch android-lvm-mod. You can also use upstream's git repository or source tarballs; see their website for details.)

    Building the source

    (This is a condensed version of the full guide: https://raw.github.com/steven676/android-lvm-mod/master/HOWTO-BUILD)

    These instructions are written for a native build (building in a Debian/Ubuntu/Fedora chroot on an actual ARM device).

    1. Configure the LVM source:
      Code:
      $ ./configure --prefix=/lvm --enable-static_link --disable-readline \
            --disable-selinux --with-pool=none --with-cluster=none \
            --with-confdir=/lvm/etc --with-default-run-dir=/data/lvm/run \
            --with-default-system-dir=/lvm/etc \
            --with-default-locking-dir=/data/lvm/lock \
            --with-optimisation="-Os -march=armv5te -mtune=cortex-a8 -mthumb"
      For a cross build, you need to set up the system to run ARM binaries using QEMU (see the full HOWTO for details). (For extra credit, fix the build so that it works with the configuration produced by running configure without qemu-arm enabled.) Then configure the source with:
      Code:
      $ export CC=arm-linux-gnueabi-gcc	# replace with your cross compiler
      $ ./configure --host=arm-linux-gnueabi \
            --prefix=/lvm --enable-static_link --disable-readline \
            --disable-selinux --with-pool=none --with-cluster=none \
            --with-confdir=/lvm/etc --with-default-run-dir=/data/lvm/run \
            --with-default-system-dir=/lvm/etc \
            --with-default-locking-dir=/data/lvm/lock \
            --with-optimisation="-Os -march=armv5te -mtune=cortex-a8 -mthumb"
    2. Build the source:
      Code:
      $ make
    3. Grab the pieces you need: the statically linked, unstripped lvm binary is located in tools/lvm.static, and a sample configuration file is in doc/example.conf.
    3
    AW: [HOWTO] "Partitioning" your Nexus S using LVM

    I just need a little clarification. It seems to me that after doing this I would need to edit my rom to allow it to be installed, is that correct? I can't just do this one time then leave it and install roms the same way I've always done in the past?

    You got it.
    The updater script is calling the partitions to mount by its path, specified in crespo device tree, in the fstab. You would always need to modify the updater script (or the device tree, if you want to publish the rom), and you need to include the lvm files.

    By using this great guide here, I started to implement lvm at my hellybean i9000 rom. And now cm10 and almost all roms are using it.

    Gesendet von meinem GT-I9000 mit Tapatalk 2