參考資訊:
http://talk.maemo.org/showthread.php?t=59374
命令如下:
$ sudo ./M32GBboot.sh $ sudo ./M32GBinit.sh $ sudo reboot
M32GBboot.sh
#!/bin/sh
# Script to prepare Maemo 5 root FS on /home (/dev/mmcblk0p2 = eMMC partition 2)
# Author: Leonid Yegoshin
# remove old Maemo5 from /home first
echo "Remove old Maemo5 root files from /home before copying..."
(cd /home; rm -fr bin boot cdrom dev etc floppy initrd lib proc \
root sbin srv sys syspart usr var mnt tmp media home)
# copy vital files
echo "Unmount /opt bindings (one error on /opt is expected)..."
MOUNTS=`mount | grep /opt | cut -d " " -f 1`
for MOUNT in $MOUNTS ;
do
umount $MOUNT
done
echo "Start copying Maemo5 root file system to /home..."
echo "(device can be unresponsible around 10 minutes)"
cp -a /bin /boot /cdrom /dev /etc /floppy /initrd /lib \
/root /sbin /srv /usr /var /home
echo "Copying done."
echo "Remount /opt back (error about / is expected)..."
start pymaemo-optify
# create dirs and links
echo "Create dirs..."
mkdir /home/proc
mkdir /home/sys
mkdir /home/syspart
mkdir -p /home/sys/kernel/debug
mkdir -p /home/mnt/initfs
mkdir /home/tmp
ln -s / /home/home
if [ ! -d /mnt/new_root ]; then
mkdir /mnt/new_root
fi
echo "Edit a vital scripts on new root file system in /home partition..."
rm -f /home/etc/event.d/hildon-startup-progress
sed -i '/send_interface=/a\\ <allow send_type="method_call"/>' /home/etc/dbus-1/system.d/mce.conf
if [ -f /home/usr/sbin/maemo-optify-lib.sh ]; then
sed -i -e "/test_home_mount\(\)/{n;a\\ return 0" -e "}" /home/usr/sbin/maemo-optify-lib.sh
sed -i -e "/test_opt_mount\(\)/{n;a\\ return 0" -e "}" /home/usr/sbin/maemo-optify-lib.sh
fi
sed -i "/mount_home \&\& /s///" /home/etc/event.d/rcS-late
sed -i "/__home {/,/}/s/^/#/" /home/usr/lib/genfstab.awk
cat <<EOF >/home/etc/event.d/restart-mce
description "Restart mce to avoid a bug for loosing GPS in M32GB"
author "Leonid Yegoshin"
console output
start on started rcS-late
script
sleep 20
stop mce
sleep 2
start mce
end script
EOF
if [ -f /home/user/.config/tracker/tracker.cfg ]; then
if ! grep -q '/mnt/initfs/' /home/user/.config/tracker/tracker.cfg; then
sed -i '/NoWatchDirectory=/s?=?=/mnt/initfs/;?' /home/user/.config/tracker/tracker.cfg
chown user:users /home/user/.config/tracker/tracker.cfg
fi
fi
echo "Done: Maemo5 has been prepared in /home partition"
M32GBinit.sh
#!/bin/sh
# Script to prepare Maemo 5 boot from /home (/dev/mmcblk0p2) partition
# Author: Leonid Yegoshin
chksum=`/usr/bin/md5sum /sbin/preinit`
if [ "x$chksum" != "x10926aa4e68958c387bc08aacc39b4fa /sbin/preinit" ]; then
if [ "x$chksum" != "x8b030c7e22f4b58a644d2282144339a5 /sbin/preinit" ]; then
echo "/sbin/preinit is a modified (non PR1.2 or PR1.2 + kernel-power) version. Stop"
exit 1
fi
fi
# fix bugs in /sbin/preinit
echo "Modifing /sbin/preinit..."
if [ -f /sbin/preinit.M32GBPR12-orig ]; then
mv /sbin/preinit.M32GBPR12-orig /sbin/preinit
fi
mv /sbin/preinit /sbin/preinit.M32GBPR12-orig
cp /sbin/preinit.M32GBPR12-orig /sbin/preinit
sed -i '/attempting to use bootmenu/a\\ default_root="mmc"' /sbin/preinit
sed -i '/if search_root_onmmc; then/a\\ root_mounted=0' /sbin/preinit
if [ ! -f /bootmenu.sh.M32GBPR12-orig ]; then
mv /bootmenu.sh /bootmenu.sh.M32GBPR12-orig
fi
echo "Creating /bootmenu.sh..."
cat <<EOF >/bootmenu.sh
rm -rf /bootmenu.log
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1>/bootmenu.log 2>&1
echo "start+++"
cd /dev; /sbin/MAKEDEV input; cd /
modprobe omap_hsmmc
rm -f /dev/mmcblk*
sleep 2
for p in /sys/block/mmcblk*/ /sys/block/mmcblk*/mmcblk*p*/; do
n=`basename $p`
rm -f /dev/$n
mknod /dev/$n b `cat $p/dev | sed "s/:/ /g"`
done
modprobe mmc_block
modprobe mmc_core
modprobe mbcache
modprobe jbd
modprobe ext3
sleep 1
chmod 660 /dev/mmcblk*
mount -t ext3 -o noatime,nodiratime,commit=1,data=writeback /dev/mmcblk0p2 /mnt/new_root
ls /dev/mmcblk*
echo "end---"
EOF
echo "Done. Booting with open keyboard will use root FS on eMMC partition 2."
M32GBrm.sh
#!/bin/sh
# Script to remove Maemo 5 root FS from /home (/dev/mmcblk0p2) partition
# Author: Leonid Yegoshin
# remove old Maemo5 from /home first
echo "Remove old Maemo5 root files from /home..."
(cd /home; rm -fr bin boot cdrom dev etc floppy initrd lib proc \
root sbin srv sys syspart usr var mnt tmp media home)
# restore bootmenu and preinit
if [ -f /sbin/preinit.M32GBPR12-orig ]; then
echo "Restore /bootmenu.sh and /sbin/preinit..."
mv /sbin/preinit.M32GBPR12-orig /sbin/preinit
if [ -f /bootmenu.sh.M32GBPR12-orig ]; then
mv /bootmenu.sh.M32GBPR12-orig /bootmenu.sh
else
rm /bootmenu.sh
fi
fi
echo "Done."
完成