« Termux-Ubuntu Trouble Shoot#1(groups: cannot find name for group ID xxxxx) | トップページ | PC-linuxで異なるCPUのlinuxを動かす »

2018年11月17日 (土)

prootでubuntuを動かす

prootでubuntuを動かす

1.概要
参考URLにあるTermux(Android)でubuntuを動かすスクリプトを流用して
PC-linuxでprootを利用してubuntuを動かしてみる。

注意:prootは最新版である必要がある。
実際には以下のバージョンで動作確認した:
proot --version
_____ _____ ___
| __ \ __ \_____ _____| |_
| __/ / _ \/ _ \ _|
|__| |__|__\_____/\_____/\____| 5.1.0

built-in accelerators: process_vm = yes, seccomp_filter = no

Visit http://proot.me for help, bug reports, suggestions, patchs, ...
Copyright (C) 2014 STMicroelectronics, licensed under GPL v2 or later.

2.変更したスクリプト
x86ubuntuX86-gen.sh
---------------------------
#!/usr/bin/bash
### #!/data/data/com.termux/files/usr/bin/bash
folder=ubuntuX86-fs
#folder=ubuntuARM64-fs
if [ -d "$folder" ]; then
first=1
echo "skipping downloading"
fi
tarball="ubuntu.tar.gz"
if [ "$first" != 1 ];then
if [ ! -f $tarball ]; then
echo "downloading ubuntu-image"
case `dpkg --print-architecture` in
aarch64)
archurl="arm64" ;;
arm)
archurl="armhf" ;;
amd64)
archurl="amd64" ;;
i*86)
archurl="i386" ;;
x86_64)
archurl="amd64" ;;
*)
echo "unknown architecture"; exit 1 ;;
esac
#archurl="arm64"
wget "https://partner-images.canonical.com/core/bionic/current/ubuntu-bionic-core-cloudimg-${archurl}-root.tar.gz" -O $tarball
fi
cur=`pwd`
mkdir -p "$folder"
cd "$folder"
echo "decompressing ubuntu image"
proot tar -xf ${cur}/${tarball} --exclude='dev'||:
### proot --link2symlink tar -xf ${cur}/${tarball} --exclude='dev'||:
echo "fixing nameserver, otherwise it can't connect to the internet"
echo "nameserver 1.1.1.1" > etc/resolv.conf
cd "$cur"
fi
mkdir -p binds
bin=start-ubuntu.sh
#bin=startARM64-ubuntu.sh
echo "writing launch script"
cat > $bin <<- EOM
#!/bin/bash
cd \$(dirname \$0)
## unset LD_PRELOAD in case termux-exec is installed
###unset LD_PRELOAD
command="proot"
###command+=" --link2symlink"
command+=" -0"
command+=" -r $folder"
if [ -n "\$(ls -A binds)" ]; then
for f in binds/* ;do
. \$f
done
fi
command+=" -b /dev"
command+=" -b /proc"
## uncomment the following line to have access to the home directory of termux
#command+=" -b /data/data/com.termux/files/home:/root"
## uncomment the following line to mount /sdcard directly to /
#command+=" -b /sdcard"
command+=" -w /root"
command+=" /usr/bin/env -i"
command+=" HOME=/root"
command+=" PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/games:/usr/local/games"
command+=" TERM=\$TERM"
command+=" LANG=C.UTF-8"
command+=" /bin/bash --login"
com="\$@"
if [ -z "\$1" ];then
exec \$command
else
\$command -c "\$com"
fi
EOM

###echo "fixing shebang of $bin"
###termux-fix-shebang $bin
echo "making $bin executable"
chmod +x $bin
echo "You can now launch Ubuntu with the ./${bin} script"
---------------------------

3.ubuntuのfs作成
上のスクリプトを実行する:
bash x86ubuntuX86-gen.sh

実行後、以下のディレクトリとスクリプトが作成される:
ubuntuX86-fs
start-ubuntu.sh

4.ubuntu実行
以下を実行する:
./start-ubuntu.sh

実行例:
./start-ubuntu.sh
#以下のようなエラーが表示されるが動作はしている
/usr/bin/groups: cannot find name for group ID 108
/usr/bin/groups: cannot find name for group ID 124
/usr/bin/groups: cannot find name for group ID 1000

pwd
/root

uname -m
x86_64

id
uid=0(root) gid=0(root) groups=0(root),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108,124,1000

apt-get update
apt-get upgrade

apt-get install nano

which nano
/bin/nano

5.ダウンロード
上のスクリプトは以下のリンクからダウンロードできる:
「x86ubuntux86gen.sh.txt」をダウンロード
# 誤操作でスクリプトを動作することを避けるためにtxtにしてある

7.エラー
同様のスクリプトでAMR系のubuntuを動作させようとしたが
以下のようなエラーで動作しなかった。
proot info: pid 15654: terminated with signal 11

# prootのバグか設定の問題かは不明。


8.参考URL
https://wiki.termux.com/wiki/Ubuntu
Ubuntu - Termux Wiki
https://github.com/Neo-Oli/termux-ubuntu/blob/master/ubuntu.sh

以上

|

« Termux-Ubuntu Trouble Shoot#1(groups: cannot find name for group ID xxxxx) | トップページ | PC-linuxで異なるCPUのlinuxを動かす »

linux」カテゴリの記事

Termux」カテゴリの記事

コメント

コメントを書く



(ウェブ上には掲載しません)




トラックバック


この記事へのトラックバック一覧です: prootでubuntuを動かす:

« Termux-Ubuntu Trouble Shoot#1(groups: cannot find name for group ID xxxxx) | トップページ | PC-linuxで異なるCPUのlinuxを動かす »