Android copy apps from old sd to new sd card

First, do not do automount, otherwise all the ownership and permission will be wrong. Format new sd card from windows.
# mount /dev/sde1 /mnt/oldsd
# mount /dev/sdg1 /mnt/newsd
# cp -a /mnt/oldsd/* /mnt/newsd
# cp -a /mnt/oldsd/.* /mnt/newsd
# cd /mnt/newsd
# rsync -av /mnt/oldsd .
# umount /mnt/oldsd
# umount /mnt/newsd


Now the apps on the new sd will be recognized.

Editing Initrd

extracting initrd

mkdir initrd
cd initrd
zcat ../initrd.img | cpio -i --make-directories

repacking

(find . | cpio -H newc -o) > ../initrd.img
cd ..
gzip initrd.img
mv initrd.img.gz initrd.img

upbacking modules.cgz

gzip -dc modules.cgz > /tmp/modules.cpio
cd /tmp/
mkdir modules
cd modules
cpio -idumv < ../modules.cpio

repacking modules.cgz

find . -print -depth |cpio -H crc -ovF ../modules.cpio
cd ..
gzip -S .cgz modules.cpio 
cp modules.cpio.cgz  modules.cgz

custom kernel with rpmbuild

make targets:
make
make modules
make modules_install

Generate patch:
diff -Naurp old new > my.patch

Modify kernel steps
put the following in .rpmmacros:
cat ~/.rpmmacros
%_topdir %(echo /home/user/mypath)/rpm
%_tmppath %(echo /home/user/mypath)/rpm/tmp
%debug_package %{nil}
  • install the src package
    rpm -i kernel*.src.rpm
  • generate patches and put in SOURCES
  • modified kernel*.config in SOURCES
  • modified SPEC/kernel*.spec to pickup the patches
    Patch3000: my.patch
    %patch3000 -p1
apply the patch (cd to SPECS)
rpmbuild -bp --target=i686 kernel-2.6.spec


build:
rpmbuild -bb --with baseonly --without debug --without debuginfo --without kabichk --target=i686 kernel-2.6.spec
use buildid to change buildname
build without rpm
rpmbuild -bp kernelsrc.rpm
cd rpm/kernel/sourcedir
cp favor_config to .config
make menuconfig # set prefix
make -j8
make modules_install
make install