zoukankan      html  css  js  c++  java
  • Nexus5安装PostmarketOS(Alpine Linux)并装上Docker

    Postmarket OS是一个基于Alpine Linux。能够安装到手机或其他移动设备上。当然linux deploy也可以使用SSH,但linux deploy运行在容器里.使用上会有些限制.

    Nexus5 硬件信息

    芯片组 Qualcomm MSM8974 Snapdragon 800
    中央处理器 4x2.3 GHz Krait 400
    显卡 Adreno330
    屏幕 1080x1920 IPS
    存储 16/32 GB
    内存 2 GB
    处理器架构 armv7
    Unixbench Whe / Dhry score 840.9
    1.准备环境
    • 科*学( 环境(最好路由器支持,实测ProxyChains只能部分代理)

    • Ubuntu系统 (或虚拟机 注:Windosw子系统WSL不能工作,实测alpine ,suse Centos 安装会出其他莫名问题)

    • python(>=3.6) pip3 git

      sudo apt install python3 git fastboot
      sudo python3.8 -m easy_install pip #pyhton3.8以下版本可用 sudo apt install python3-pip
      
    2.安装pmbootstrap
    • 安装

      pip3 install --user pmbootstrap
      
    • 更新

      pip3 install --user --upgrade pmbootstrap
      
    • 安装后需要注销并重新登陆刷新path

      pmbootstrap log #查看日志记录
      pmbootstrap pull#更新
      
    3.初始化 pmbootstrap init

    镜像源地址列表https://mirrors.postmarketos.org/ https://mirrors.alpinelinux.org/

    zp@zp:~$ pmbootstrap --mirror-pmOS="http://postmarketos-mirror.southafricanorth.cloudapp.azure.com/"  --mirror-alpine="http://mirrors.ustc.edu.cn/alpine/" init
    [07:03:26] Location of the 'work' path. Multiple chroots (native, device arch, device rootfs) will be created in there.
    ##设置工作路径确保该位置有几个GB的可用空间,并且它是一个相对标准的Linux文件系统
    [07:03:26] Work path [/home/zp/.local/var/pmbootstrap]:
    [07:03:27] NOTE: pmaports path: /home/zp/.local/var/pmbootstrap/cache_git/pmaports
    [07:03:27] Choose the postmarketOS release channel.
    [07:03:27] Available (2):
    [07:03:27] * edge: Rolling release channel
    [07:03:27] * stable: Stable release channel (first beta v20.05, does not have many devices yet)
    ##选择更新通道 Stable稳定版  edge 滚动更新版
    [07:03:27] Channel [edge]:
    [07:03:29] Choose your target device vendor (either an existing one, or a new one for porting).
    [07:03:29] Available vendors (55): acer, alcatel, amazon, arrow, asus, bq, chuwi, cubietech, essential, fairphone, finepower, fly, fujitsu, google, gp, hisense, htc, huawei, infocus, jolla, leeco, lenovo, lg, medion, meizu, motorola, nextbit, nobby, nokia, oneplus, oppo, ouya, pine64, planet, purism, qemu, raspberry, samsung, semc, sharp, sony, surftab, t2m, tablet, teclast, tokio, trekstor, vernee, wexler, wiko, wileyfox, xiaomi, yu, zte, zuk
    ##选择 设备的供应商和代码
    [07:03:29] Vendor [lg]:
    [07:03:30] Available codenames (14): bullhead, d285, d722, d851, d855, dory, e610, h815, hammerhead, lenok, mako, p700, vee7e, w5
    ##nexus5 是hammerhead
    [07:03:30] Device codename [hammerhead]:
    [07:03:33] This device has proprietary components, which trade some of your freedom with making more peripherals work.
    [07:03:33] We would like to offer full functionality without hurting your freedom, but this is currently not possible for your device.
    [07:03:33] device-lg-hammerhead-nonfree-firmware: WiFi, GPU, Modem and ADSP firmware
    ##是否安装 Wifi GPU Modem 等驱动 
    [07:03:33] Enable this package? (y/n) [y]:
    ##设备登陆用户名
    [07:03:35] Username [xx]: lg3
    [07:03:41] Available user interfaces (13):
    #用户界面
    [07:03:41] * none: No graphical environment #无图形环境
    [07:03:41] * fbkeyboard: Plain framebuffer console with touchscreen keyboard support#带有触摸屏键盘支持的纯帧缓冲控制台
    [07:03:41] * gnome: (Wayland) Gnome Shell
    [07:03:41] * i3wm: (X11) Tiling WM (keyboard required)#(需要键盘)
    [07:03:41] * mate: (X11) MATE Desktop Environment, fork of GNOME2 (stylus recommended)#MATE桌面环境,GNOME2的分支(建议使用手写笔)
    [07:03:41] * phosh: (Wayland) Mobile UI developed for the Librem 5 (works only with numeric passwords!)#为Librem 5开发的移动UI(仅适用于数字密码!)
    [07:03:41] * plasma-bigscreen: (Wayland) 10-feet variant of Plasma, made for big screen TVs#用于大屏幕电视
    [07:03:41] * plasma-desktop: (X11/Wayland) KDE Desktop Environment (works well with tablets)#KDE桌面环境(与平板电脑配合使用)
    [07:03:41] * plasma-mobile: (Wayland) Mobile variant of KDE Plasma (does not run without hardware acceleration, allows only numeric passwords!)#(在没有硬件加速的情况下不能运行,仅允许输入数字密码!)
    [07:03:41] * shelli: Plain console with touchscreen gesture support#带有触摸屏手势支持的普通控制台
    [07:03:41] * sway: (Wayland) Tiling WM, drop-in replacement for i3wm (DOES NOT RUN WITHOUT HW ACCELERATION!)#(不能在没有硬件加速的情况下运行!)
    [07:03:41] * sxmo: (X11) Simple X Mobile: Mobile environment based on simple & suckless software (best compatibility on pinephone)
    [07:03:41] * weston: (Wayland) Reference compositor (demo, not a phone interface)
    [07:03:41] * xfce4: (X11) Lightweight desktop (stylus recommended)
    #选择Gui fbkeyboard 其他图形界面不推荐,太卡
    [07:03:41] User interface [weston]: fbkeyboard
    #除非您知道要更改某些内容,否则只需按一下return键即可在此处使用默认值进行回答
    [07:03:48] Additional options: extra free space: 0 MB, boot partition size: 128 MB, parallel jobs: 3, ccache per arch: 5G, sudo timer: False
    [07:03:48] Change them? (y/n) [n]:
    [07:03:51] Additional packages that will be installed to rootfs. Specify them in a comma separated list (e.g.: vim,file) or "none"
    [07:03:51] Extra packages [none]:
    [07:03:52] Your host timezone: Etc/UTC
    [07:03:52] Use this timezone instead of GMT? (y/n) [y]:
    [07:03:54] Available locales (14): C.UTF-8, ch_DE.UTF-8, de_CH.UTF-8, de_DE.UTF-8, en_GB.UTF-8, en_US.UTF-8, es_ES.UTF-8, fr_FR.UTF-8, it_IT.UTF-8, nb_NO.UTF-8, nl_NL.UTF-8, pt_BR.UTF-8, ru_RU.UTF-8, sv_SE.UTF-8
    [07:03:54] Choose default locale for installation (y/n) [C.UTF-8]:
    #安装后手机显示的计算机名
    [07:03:54] Device hostname (short form, e.g. 'foo') [lg-hammerhead]:
    [07:03:56] After pmaports are changed, the binary packages may be outdated. If you want to install postmarketOS without changes, reply 'n' for a faster installation.
    [07:03:56] Build outdated packages during 'pmbootstrap install'? (y/n) [y]:
    [07:03:56] WARNING: The chroots and git repositories in the work dir do not get updated automatically.
    [07:03:56] Run 'pmbootstrap status' once a day before working with pmbootstrap to make sure that everything is up-to-date.
    [07:03:56] Done!
    
    
    4.初始化安装pmbootstrap install

    执行pmbootstrap install 并等待执行完成(需要漫长等待,可以通过pmbootstrap log 查看详细日志,如果中断可以重新重试)

    pmbootstrap --mirror-pmOS="http://postmarketos-mirror.southafricanorth.cloudapp.azure.com/"  --mirror-alpine="http://mirrors.ustc.edu.cn/alpine/" install
    

    中间会提示创建进入手机系统的新密码

    5.刷入手机
    • 进入Fastboot Mode .在关闭设备电源的情况下,同时按住“降低音量”和“电源”按钮几秒钟,直到出现“快速启动模式”屏幕 并连接到电脑

    • 解锁OEM (已解锁跳过)

      sudo fastboot oem unlock
      
    • 将系统刷入到手机

      pmbootstrap --mirror-pmOS="http://postmarketos-mirror.southafricanorth.cloudapp.azure.com/"  --mirror-alpine="http://mirrors.ustc.edu.cn/alpine/"  flasher flash_rootfs --partition userdata
      
      sudo fastboot format system
      
      pmbootstrap  --mirror-pmOS="http://postmarketos-mirror.southafricanorth.cloudapp.azure.com/"  --mirror-alpine="http://mirrors.ustc.edu.cn/alpine/"   flasher flash_kernel
      
    6.Docker安装
    #编辑内核 qcom-msm8974代表的是芯片组Qualcomm MSM8974  其他手机需要自行对应
    pmbootstrap  --mirror-pmOS="http://postmarketos-mirror.southafricanorth.cloudapp.azure.com/"  --mirror-alpine="http://mirrors.ustc.edu.cn/alpine/"  kconfig edit postmarketos-qcom-msm8974
    #编译
    pmbootstrap  --mirror-pmOS="http://postmarketos-mirror.southafricanorth.cloudapp.azure.com/"  --mirror-alpine="http://mirrors.ustc.edu.cn/alpine/"  build linux-postmarketos-qcom-msm8974 --force
    
    
    • 编译后文件~/.local/var/pmbootstrap/packages/edge/armv7/linux-postmarketos-qcom-msm8974***.apk

    • 通过 sudo apk add -u linux-postmarketos-qcom-msm8974-5.9.0_rc4-r0.apk (此方法我手机安装后重启并未生效,直接重新执行 3,4,5 步骤重新刷入系统生效)

    • 检Docker支持 https://raw.githubusercontent.com/moby/moby/master/contrib/check-config.sh

    • 安装Docker

      
      sudo sed  -i '$a199.232.28.133 raw.githubusercontent.com' /etc/hosts
      wget https://raw.githubusercontent.com/moby/moby/master/contrib/check-config.sh
      chmod 777 check-config.sh
      ./check-config.sh
      
      #安装Docker
      sudo apk add docker
      #启动docker服务
      sudo service docker start
      #设置为自动启动
      sudo rc-update add docker default
      #创建docker用户组并把用户加入组
      sudo groupadd docker
      #把用户添加进docker组中
      sudo gpasswd -a ${USER} docker
      #重启
      sudo reboot
      #docker 加速
      sudo vi /etc/docker/daemon.json
      {
      "registry-mirrors": [
      "https://dockerhub.azk8s.cn",
      "https://reg-mirror.qiniu.com",
      "https://registry.docker-cn.com",
      "http://docker.mirrors.ustc.edu.cn",
      "http://hub-mirror.c.163.com"
      ]
      }
      docker run --rm hello-world
      
      
    7.其他说明
    • 使用poweroff 并不能完全关机,得进入快速模式下关机,开机也一样

    • 系统自带一个usb网卡,通过电脑与手机连接,电脑自动获取Ip地址,就可以通过usb连接到手机

    • 使用Usb网卡不识别时. 可以先在电脑上查询对应的USB芯片是什么 在编辑内核 Device Drivers => Network device support => <*> USB Network Adapters 中勾选对应USB网卡驱动apk

    • docker 运行时需要选择基于arm的镜像

    • 相机还不能正常工作

    • apk软件包中的openjdk8不建议使用,有性能bug,Docker中使用都比较快

    • 其他常用软件

      sudo apk add python3 py3-pip openjdk8 screen htop unrar curl
      
      sudo apk add mysql mysql-client  
      #https://wiki.alpinelinux.org/wiki/Mysql
      
      sudo apk add jenkins 
      #sudo service jenkins start 
      #sudo rc-update add jenkins default 
      
      #我的世界服务器
      docker run --rm -e EULA=TRUE -it -p 25565:25565  -v ~/mcdata:/data --name mc2 janbe/minecraft-server:multiarch
      #.net core
      docker pull mcr.microsoft.com/dotnet/core/aspnet:3.1.11-buster-slim-arm32v7
      docker pull mcr.microsoft.com/dotnet/core/aspnet:5.0.2-focal-arm32v7
      
    • 参考

      https://wiki.postmarketos.org/wiki/User_talk:Docker

      https://wiki.postmarketos.org/wiki/Main_Page

      https://wiki.postmarketos.org/wiki/Mirrors

  • 相关阅读:
    20155239 2016-2017-2 《Java程序设计》第7周学习总结
    20155231 2016-2017-2 《Java程序设计》第4周学习总结
    20155231 2016-2017-2 《Java程序设计》第3周学习总结
    20155231 2016-2017-2 《Java程序设计》第2周学习总结
    20155231 2016-2017-2 《Java程序设计》第1周学习总结
    第三次预作业20155231邵煜楠:虚拟机上的Linux学习
    预备作业2:阅读心得(20155231邵煜楠)
    博客初体验:我期望的师生关系
    安装虚拟机
    20155227第二次预备作业
  • 原文地址:https://www.cnblogs.com/hongshao/p/14351045.html
Copyright © 2011-2022 走看看