============================================

구형 안드로이드 폰인 옵티머스 마하에 리눅스를 설치하는 프로젝트

============================================

 크게 다음과 같은 과정이 진행된다.

  • 옵티머스 마하 루팅
  • 외장 SD 카드에 우분투 설치
  • 실제 우분투로부터 이미지 추출
  • ssh 접속하기

 

1. 루팅

루팅에 대해서 자세히 설명하지는 않는다. 참고로 옵티머스 마하 버전이 31 (가장 최상위 버전으로 알고 있음) 이면 루팅이 되지 않으므로 29 로 다운그레이드가 필요하다. 필자의 옵티머스 마하는 29 버전이었으므로 바로 루팅 과정을 진행하였다.

루팅은 여러 방법으로 진행할 수 있는데 SuperOneClick 을 사용하였다. 다만 SuperOneClick은 이미 종료된 프로젝트이며 SuperOneClick 다운로드 페이지 중에는 fake가 많으므로 유의한다. 그리고 루팅 시에는 SD 카드를 제거하도록 한다.

루팅이 완료되었다면 adb를 통하여 폰에 연결할 수 있다. adb 는 Android Debug Bridge의 약자로 adb shell을 실행하면 익숙한 shell 화면을 볼 수 있게 된다.

참고로 Windows 계열에서 SuperOneClick을 사용하였다면 패키지 내에 adb가 들어있을 것이다. 단 독자의 OS가 OS X라면 다음과 같이 adb를 설치하도록 한다.

  • http://developer.android.com/sdk/installing/index.html?pkg=tools 에서 android-sdk-macosx.zip 다운로드
  • tools 안의 android 실행
  • Android SDK Manager 프로그램이 실행되며 Android Platform-tools를 추가 설치함
  • platform-tools 디렉토리가 추가로 만들어지며 그 안에 adb가 설치되어 있음

adb shell 을 통한 진입이 되었다면 거의 다 됐다고 보면 된다. 

  

2. 외장 SD 카드에 우분투 설치

다음은 외장 SD 카드에 우분투를 설치한다. SD 카드를 분리하여 PC에 삽입하면 작업을 진행하면 된다.

우분투는 http://downloadandroidrom.com/file/AndroLinux URL에서 ubuntu.zip을 다운로드 받는다. 이 zip 파일 안에는 6개의 파일이 포함되어 있는데 SD 카드에 ubuntu 디렉토리를 만들고 나서 그 안에 풀도록 한다. ubuntu.img는 실제 우분투의 이미지이다. 크기는 아마 2G일 것이다.

그럼 이제 우분투를 실행해보자. 

  1. ubuntu 실행
  2. bootubuntu 실행

드디어 우분투의 프롬프트를 만날 수 있다.

root@localhost:/#

파일시스템을 확인해보자.

root@localhost:/# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/block/loop2       2064208   1744116    215236  90% /
none                   2064208   1744116    215236  90% /dev
none                   2064208   1744116    215236  90% /dev/shm
none                   2064208   1744116    215236  90% /var/run
none                   2064208   1744116    215236  90% /var/lock
none                   2064208   1744116    215236  90% /lib/init/rw

 여유공간이 많지 않다는 단점이 있다.

 

3. 실제 우분투로부터 이미지 추출

ubuntu.img의 크기가 2G 밖에 안되는데 그나마 90% 가량 사용 중이다. 실제 무언가 해보기에는 많이 부족한 용량이다. 따라서 좀 더 큰 이미지를 사용하기 위해 실제 우분투로부터 이미지를 추출하는 작업을 진행한다.

필자는 rootstock을 이용하려고 한다. 참고로 이 rootstock 역시 종료된 프로젝트이다. 따라서 과거 참고자료에는 apt-get을 통한 다운로드가 가능하다고 되어 있는 경우가 많지만 2015년 현재 불가능한 경우가 많다. rootstock 페이지인 https://launchpad.net/project-rootstock 에서도 "RootStock has been deprecated and is no longer maintained"라고 표시되어 있다. 다만 tar.gz파일은 제공되고 있으므로 다운로드하여 실행한다.

그럼 rootstock을 이용하여 6G짜리 이미지를 생성해보겠다.

# ./rootstock --fqdn ubuntu --login root --password root --imagesize 6G
I: Running on a x86_64 machine
I: Second stage will run inside a full virtual machine
qemu not installed, please use:
sudo apt-get install qemu
(or on ubuntu > karmic sudo apt-get install qemu-kvm-extras)
to install the qemu package !

안타깝게 qemu의 설치가 선행되어야 한다. 또한 본 문서에서는 따로 언급하지 않지만 fakeroot도 필요하다. 정리하자면 rootstock 실행을 위해 apt-get을 통해 다음 패키지들을 설치한다.

  • qemu-kvm-extra
  • fakeroot

정상적으로 rootstock이 실행되면 꽤 많은 시간이 소요된다.

# ./rootstock --fqdn ubuntu --login root --password root --imagesize 6G
I: Running on a x86_64 machine
I: Second stage will run inside a full virtual machine
I: Creating temporary qemu Image to be used as rootfs
I: Mounting temporary Image
I: Running first stage
I: Retrieving Release
I: Retrieving Release.gpg
I: Checking Release signature
I: Valid Release signature (key id 630239CC130E1A7FD81A27B140976EAF437D05B5)
I: Retrieving Packages
I: Validating Packages
I: Resolving dependencies of required packages...
I: Resolving dependencies of base packages...
I: Checking component main on http://ports.ubuntu.com/ubuntu-ports...
I: Retrieving adduser
I: Validating adduser
I: Retrieving apt
I: Validating apt
(계속진행됨)

그런데 문제가 있다. 필자가 추출한 이미지는 6G의 크기인데 옵티머스 마하의 SD 카드는 FAT32 포맷으로 되어 있어 6G짜리 단일 파일을 저장할 수 있다. 그래서 SD 카드를 exFAT으로 재포맷하여 6G의 이미지 파일을 넣을 수 있게 되었다. 여기까지는 좋았는데 옵티머스 마하에서는 exFAT을 인식하지 못한다. 따라서 FAT32의 한계인 4G 이내로 이미지를 추출해야 한다. 이미지 추출 관련된 작업은 여기까지만 설명한다.

 

4. ssh 접속하기

이제까지는 PC와 옵티머스 마하가 USB로 연결된 상태에서 adb를 통해 통신하였다. 하지만 옵티머스 마하는 WiFi가 내장되어 있으므로 다른 장비에서 옵티머스 마하의 우분투에 접속이 가능할 것이다.

이제 옵티머스 마하 내부의 우분투에 ssh 서버를 설치해보자.

# apt-get install openssh-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libbeagle1 python-dev python-nautilus python2.6-dev
Use 'apt-get autoremove' to remove them.
Suggested packages:
  rssh molly-guard openssh-blacklist openssh-blacklist-extra ufw
The following NEW packages will be installed:
  openssh-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 284kB of archives.
After this operation, 733kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  openssh-server
Install these packages without verification [y/N]? y
Err http://ports.ubuntu.com karmic/main openssh-server 1:5.1p1-6ubuntu2
  404  Not Found [IP: 91.189.88.140 80]
Failed to fetch http://ports.ubuntu.com/ubuntu-ports/pool/main/o/openssh/openssh-server_5.1p1-6ubuntu2_armel.deb  404  Not Found [IP: 91.189.88.140 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

그런데 저장소에 대한 404 에러가 나면서 설치가 실패하였다. 이유는 더 이상 사용할 수 없는 저장소로 old-releases.ubuntu.com 으로의 우회가 필요하다. 방법은 /etc/apt/sources.list 파일을 수정한다. 

#deb http://ports.ubuntu.com/ubuntu-ports karmic main universe
deb http://old-releases.ubuntu.com/ubuntu karmic main universe

그리고 저장소를 업데이트한다.

# apt-get update
Get:1 http://old-releases.ubuntu.com karmic Release.gpg [189B]
Get:2 http://old-releases.ubuntu.com karmic Release [65.9kB]
Get:3 http://old-releases.ubuntu.com karmic/main Packages [1329kB]
Get:4 http://old-releases.ubuntu.com karmic/universe Packages [4885kB]
Fetched 6280kB in 37s (167kB/s)
Reading package lists... Done

 이제 다시 ssh 서버를 설치해본다.

# apt-get install openssh-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libbeagle1 python-dev python-nautilus python2.6-dev
Use 'apt-get autoremove' to remove them.
Suggested packages:
  rssh molly-guard openssh-blacklist openssh-blacklist-extra ufw
The following NEW packages will be installed:
  openssh-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 284kB of archives.
After this operation, 733kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  openssh-server
Install these packages without verification [y/N]? y
Err http://ports.ubuntu.com karmic/main openssh-server 1:5.1p1-6ubuntu2
  404  Not Found [IP: 91.189.88.140 80]
Failed to fetch http://ports.ubuntu.com/ubuntu-ports/pool/main/o/openssh/openssh-server_5.1p1-6ubuntu2_armel.deb  404  Not Found [IP: 91.189.88.140 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
root@localhost:/etc# apt-get update
Ign http://ports.ubuntu.com karmic Release.gpg
Ign http://ports.ubuntu.com karmic Release
Need to get 284kB of archives.
After this operation, 733kB of additional disk space will be used.
Get:1 http://old-releases.ubuntu.com karmic/main openssh-server 1:5.1p1-6ubuntu2 [284kB]
Fetched 284kB in 15s (18.3kB/s)
E: Could not open file /data/local/tmp/openssh-server.template.43210 - open (2: No such file or directory)
E: Unable to write to /data/local/tmp/openssh-server.template.43210 - ofstream::ofstream (2: No such file or directory)
E: Could not open file /data/local/tmp/openssh-server.config.43211 - open (2: No such file or directory)
E: Unable to write to /data/local/tmp/openssh-server.config.43211 - ofstream::ofstream (2: No such file or directory)
debconf: apt-extracttemplates failed: Bad file descriptor
Selecting previously deselected package openssh-server.
(Reading database ... 120477 files and directories currently installed.)
Unpacking openssh-server (from .../openssh-server_1%3a5.1p1-6ubuntu2_armel.deb) ...
Processing triggers for man-db ...
Processing triggers for sreadahead ...
Setting up openssh-server (1:5.1p1-6ubuntu2) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
 * Restarting OpenBSD Secure Shell server sshd                           [ OK ]

 중간에 오류 같은 것들도 있는 것 같지만 어쨌든 잘 설치가 되고 sshd까지 가동된 것을 볼 수 있다. ps 명령어로도 확인해본다.

# ps -e | grep ssh
 4451 ?        00:00:00 sshd

그럼 이제 외부에서 ssh를 통해 접속하기 위해 옵티머스 마하 무선랜의 IP 주소를 확인해본다. 이 과정에서 반드시 옵티머스 마하의 WiFi가 활성화되어 있고 AP에 접속된 상태여야 한다.

tiwlan0   Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:192.168.1.10   Bcast:192.0.1.255  Mask:255.255.255.0

그리고 inet addr의 주소인 192.168.1.10을 이용하여 외부에서 옵티머스 마하로 ssh를 해본다. 아래 root 패스워드는 사전에 설정한 root 패스워드를 입력한다. 물론 별도의 계정을 생성하여 접속할 수도 있다.

$ ssh -l root 192.168.1.10
The authenticity of host '192.168.1.10 (192.168.1.10)' can't be established.
RSA key fingerprint is ~~~~.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.10' (RSA) to the list of known hosts.
이 이메일 주소가 스팸봇으로부터 보호됩니다. 확인하려면 자바스크립트 활성화가 필요합니다.'s password: (패스워드 입력)
Linux localhost 2.6.35.7+ #1 PREEMPT Tue Nov 8 00:16:40 KST 2011 armv7l

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/

0 packages can be updated.
0 updates are security updates.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

root@localhost:~# 

 

이제까지 구형 안드로이드 폰인 옵티머스 마하에서 우분투를 설치하는 프로젝트 진행 결과를 공유하였다.