トップ «前の日(01-08) 最新 次の日(01-10)» 追記

Masa's blog

検索キーワード:

2017年01月09日 SlackwareARM 14.2 with chroot on rooted android smart phone(Sony Xperia SO-03D)

_ Equipments

_ Applications on android side

Required

Recommended

_ Extract Slackware file tree into MicroSD (on Slackware 14.2 x86)

Get SlackwareARM 14.2

Format MicroSD

  • fdisk -l /dev/sdb
Disk /dev/block/mmcblk1: 31.9 GB, 31914983424 bytes
4 heads, 16 sectors/track, 973968 cylinders
Units = cylinders of 64 * 512 = 32768 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdb1              33       32800     1048576   b Win95 FAT32
Partition 1 does not end on cylinder boundary
/dev/sdb2           32801      973968    30117376  83 Linux
Partition 2 does not end on cylinder boundary
  • mkfs -t vfat /dev/sdb1
  • mkfs -t ext4 /dev/sdb2

Extract phase1

  • mount /dev/sdb2 /mnt/tmp
  • mkdir /mnt/tmp/slackware
  • cd ~/ftp.arm.slackware.com/slackwarearm/slackwarearm-14.2/slackware/
  • find . -name '*.txz' | xargs -I '{}' installpkg --root /mnt/tmp/slackware '{}'

Extract phase2

  • cd /mnt/tmp/slackware
  • tar xvpif ~/ftp.arm.slackware.com/slackwarearm/slackwarearm-devtools/minirootfs/roots/slack-14.2-miniroot_01Jul16.tar.xz
  • sync;sync;sync
  • cd ~
  • umount /mnt/tmp

_ Android smart phone side

create mount point for Slackware's partition

  • Put MicroSD into SD slot in phone
  • start Terminal emulator
  • su -
  • cd /mnt/sdcard
  • mkdir chroot

Create scripts to start Slackware

  • mount /dev/block/mmcblk1p2 /mnt/sdcard/chroot
  • mkdir chroot/slackware/system
  • mkdir chroot/slackware/external_sd
  • vi slackware.sh
#! /system/bin/sh
(
        export CHROOT=/mnt/sdcard/chroot
        export ROOT=${CHROOT}/slackware
        /system/xbin/mount -t ext4 /dev/block/mmcblk1p2 ${CHROOT}
        /system/xbin/mount -t proc none ${ROOT}/proc
        /system/xbin/mount -t sysfs none ${ROOT}/sys
        /system/xbin/mount -o bind /dev ${ROOT}/dev
        /system/xbin/mount -o bind /dev/pts ${ROOT}/dev/pts
        /system/xbin/mount -o bind /dev/socket ${ROOT}/dev/socket
        /system/xbin/mount -o bind /system ${ROOT}/system
        /system/xbin/mount -o bind /mnt/sdcard/external_sd ${ROOT}/external_sd
        export HOME=/root
        export SHELL=/bin/bash
        export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/arm-slackware-linux-gnueabi/lib:${LD_LIBRARY_PATH}

        /system/xbin/chroot ${ROOT} /bin/su -c /etc/rc.d/rc.local
#       /system/xbin/chroot ${ROOT} /bin/bash -l

        for i in `lsof | egrep /mnt/sdcard/chroot/ | tr -s ' ' | cut -d ' ' -f 2 | sort | uniq`
        do
                kill $i
        done

        sync;sync;sync
        umount ${ROOT}/external_sd
        umount ${ROOT}/system
        umount ${ROOT}/dev/socket
        umount ${ROOT}/dev/pts
        umount ${ROOT}/dev
        umount ${ROOT}/sys
        umount ${ROOT}/proc
        umount ${CHROOT}
)
  • vi chroot/slackware/etc/rc.d/rc.local
#!/bin/sh
if [ -e /dev/graphics/fb0 ]
then
        (cd /dev && ln -sf graphics/fb0 .)
fi

if [ -x /sbin/ldconfig ]
then
        /sbin/ldconfig
fi

if [ -r /etc/HOSTNAME ]
then
        /bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .)
fi

if [ -x /usr/bin/rsync ]
then
        /usr/bin/rsync --daemon -config=/etc/rsyncd.conf
fi

if [ -x /etc/rc.d/rc.sshd ]
then
        /etc/rc.d/rc.sshd start
fi

if [ -x /etc/rc.d/rc.pulseaudio ]
then
        /etc/rc.d/rc.pulseaudio start
fi

if [ -x /usr/local/canna/sbin/cannaserver ]
then
        rm -f /tmp/.iroha_unix/IROHA
        /usr/local/canna/sbin/cannaserver -inet -u bin
        echo "Starting cannaserver."
fi

if [ -x /usr/local/OpenPOBox/server/pbserver.sh ]
then
        /usr/local/OpenPOBox/server/pbserver.sh
fi

/bin/bash -l
  • vi chroot/slackware/root/.xinitrc
#!/bin/sh
DISPLAY=127.0.0.1:0.0; export DISPLAY

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    /usr/bin/xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    /usr/bin/xmodmap $sysmodmap
fi

if [ -f $userresources ]; then
    /usr/bin/xrdb -merge $userresources
fi

if [ -f $usermodmap ]; then
    /usr/bin/xmodmap $usermodmap
fi

# start some nice programs

/usr/bin/xkbset m
/usr/bin/xkbset exp m

/usr/bin/xterm -ls &
exec /usr/bin/twm

Start slackware

start Slackware with next commands from Terminal emulator.

  • su -
  • cd /mnt/sdcard
  • sh slackware.sh
  • sh .xinitrc

Change application to XSDL, then you will see xterm and twm running in it.

Some setting in Slackware

  • vi /etc/rsyncd.conf
uid = root
gid = root
[root_partition]
        comment = so03d root partition
        path = /
        read only = true
        hosts allow = 192.168.0.100
        hosts deny = *
  • vi /etc/ssh/sshd_config
Port 8022
  • vipw
aid_system:x:1000:1000::/:/bin/false
aid_radio:x:1001:1001::/:/bin/false
aid_bluetooth:x:1002:1002::/:/bin/false
aid_graphics:x:1003:1003::/:/bin/false
aid_input:x:1004:1004::/:/bin/false
aid_audio:x:1005:1005::/:/bin/false
aid_camera:x:1006:1006::/:/bin/false
aid_log:x:1007:1007::/:/bin/false
aid_compass:x:1008:1008::/:/bin/false
aid_mount:x:1009:1009::/:/bin/false
aid_wifi:x:1010:1010::/:/bin/false
aid_adb:x:1011:1011::/:/bin/false
aid_install:x:1012:1012::/:/bin/false
aid_media:x:1013:1013::/:/bin/false
aid_dhcp:x:1014:1014::/:/bin/false
aid_sdcard_rw:x:1015:1015::/:/bin/false
aid_media_rw:x:1023:1023::/:/bin/false
aid_shell:x:2000:2000::/:/bin/false
aid_cache:x:2001:2001::/:/bin/false
aid_diag:x:2002:2002::/:/bin/false
aid_net_bt_admin:x:3001:3001::/:/bin/false
aid_net_bt:x:3002:3002::/:/bin/false
aid_inet:x:3003:3003::/:/bin/false
aid_net_raw:x:3004:3004::/:/bin/false
aid_misc:x:9998:9998::/:/bin/false
aid_nobody:x:9999:9999::/:/bin/false
aid_app:x:10000:10000::/:/bin/false
  • vipw -g
aid_system:x:1000:root,pulse
aid_radio:x:1001:root,pulse
aid_bluetooth:x:1002:root,pulse
aid_graphics:x:1003:root,pulse
aid_input:x:1004:root,pulse
aid_audio:x:1005:root,pulse
aid_camera:x:1006:root,pulse
aid_log:x:1007:root,pulse
aid_compass:x:1008:root,pulse
aid_mount:x:1009:root,pulse
aid_wifi:x:1010:root,pulse
aid_adb:x:1011:root,pulse
aid_install:x:1012:root,pulse
aid_media:x:1013:root,pulse
aid_dhcp:x:1014:root,pulse
aid_sdcard_rw:x:1015:root,pulse
aid_media_rw:x:1023:root,pulse
aid_shell:x:2000:root,pulse
aid_cache:x:2001:root,pulse
aid_diag:x:2002:root,pulse
aid_net_bt_admin:x:3001:root,pulse
aid_net_bt:x:3002:root,pulse
aid_inet:x:3003:root,pulse
aid_net_raw:x:3004:root,pulse
aid_misc:x:9998:root,pulse
aid_nobody:x:9999:root,pulse
aid_app:x:10000:root,pulse
  • vi /etc/pulse/system.pa
load-module module-simple-protocol-tcp rate=44100 format=s16le channels=2 source=auto_null.monitor record=true port=8000
  • chmod +x /etc/rc.d/rc.pulse
  • vi /root/.Xresource
! F1 for Button1, F2 for Button2, F3 for Button3 of Rii RT-MWK02(bluetooth mini keyboard)
keycode 67 = Pointer_Button1
keycode 68 = Pointer_Button2
keycode 69 = Pointer_Button3
remove Shift = Shift_L
remove Control = Control_L
keysym Control_L = Shift_L
keysym Shift_L = Control_L
add Shift = Shift_L
add Control = Control_L

_ BUGS

Unfortunatery, binary built by gcc-4.7 or later requires __kernel_cmpxchg64 system call in kernel-3.1 or later.

So I have to say that SlackwareARM-14.2 is not suitable for Xperia SO-03D which is powerd by Android 4.0 with kernle-3.0.8.