背景:

我们直接用yum install 下载安装包,因为用的是国外的源,下载速度难免会受限,我们可以改为用阿里源,当然你不改也是没问题的。还有因为在手机安装的linux是安装在一个容器里的,当我们使用systemctl命令时,无法启用服务,提示:Running in chroot, ignoring request. 百度了很多,找到有可以替代的方法。

原料:

还是那部萌萌的小米6手机

一,禁用Yum插件

用vim编辑 /etc/yum.conf 文件,找到 plugins=1 这一行改为0即可

vim /etc/yum.conf 

 二,替换yum源为阿里源

先用cat /etc/redhat-release 命令查看自己的系统版本

cat /etc/redhat-release

 用vim编辑文件:/etc/yum.repos.d/CentOS-Base.repo

编辑前先备份,用cp命令复制一份

cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bk_20220508

将下面的 7.9.2009 换成你自己当前系统的版本号
适用于aarch64构架的阿里云镜像源配置文件

用 vim /etc/yum.repos.d/CentOS-Base.repo 编辑文件

可以用命令ggdG 快速清空当前文件,在命令模式下,首先执行 gg 这里是跳至文件首行 再执行: dG 也就是直接按 ggdG 这样就清空了整个文件,然后用下面的内容粘贴替换,:wq保存退出。

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-7.9.2009 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-altarch/7.9.2009/os/aarch64/
        http://mirrors.aliyuncs.com/centos-altarch/7.9.2009/os/aarch64/
        http://mirrors.cloud.aliyuncs.com/centos-altarch/7.9.2009/os/aarch64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-altarch/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-7.9.2009 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-altarch/7.9.2009/updates/aarch64/
        http://mirrors.aliyuncs.com/centos-altarch/7.9.2009/updates/aarch64/
        http://mirrors.cloud.aliyuncs.com/centos-altarch/7.9.2009/updates/aarch64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-altarch/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-7.9.2009 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-altarch/7.9.2009/extras/aarch64/
        http://mirrors.aliyuncs.com/centos-altarch/7.9.2009/extras/aarch64/
        http://mirrors.cloud.aliyuncs.com/centos-altarch/7.9.2009/extras/aarch64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-altarch/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7.9.2009 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-altarch/7.9.2009/centosplus/aarch64/
        http://mirrors.aliyuncs.com/centos-altarch/7.9.2009/centosplus/aarch64/
        http://mirrors.cloud.aliyuncs.com/centos-altarch/7.9.2009/centosplus/aarch64/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-altarch/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-7.9.2009 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-altarch/7.9.2009/contrib/aarch64/
        http://mirrors.aliyuncs.com/centos-altarch/7.9.2009/contrib/aarch64/
        http://mirrors.cloud.aliyuncs.com/centos-altarch/7.9.2009/contrib/aarch64/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-altarch/RPM-GPG-KEY-CentOS-7

更新下载新的rpm秘钥: 下面的7.9.2009替换成自己的版本号
下载地址: https://mirrors.aliyun.com/centos-altarch/7.9.2009/os/aarch64/
下载 需要的两个文件:
RPM-GPG-KEY-CentOS-7 
RPM-GPG-KEY-CentOS-Testing-7


然后在这个/etc/pki/rpm-gpg/目录下把原来的替换掉,替换之前也要有做备份的习惯


然后执行更新命令

yum makecache 下载需要点时间,主要看你网络

yum makecache
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 三,添加环境变量

这里默认/usr/local/bin并不在系统变量中,我们需要在/etc/bashrc中添加它

echo export PATH=$PATH:/usr/local/bin >> /etc/bashrc

四,寻找systemctl的替代品

执行systemctl start cpolar命令时,无法启动服务,提示以下信息。

 可以用以下方法解决:

# 下载包并解压
wget https://github.com/smaknsk/servicectl/archive/1.0.tar.gz

# 解压指定到路径 
tar -xf 1.0.tar.gz -C /usr/local/lib/

# 软链接
ln -s /usr/local/lib/servicectl-1.0/servicectl /usr/local/bin/servicectl
ln -s /usr/local/lib/servicectl-1.0/serviced /usr/local/bin/serviced

使用方法:
servicectl:
sudo servicectl [action] [service]
‎此命令仅执行文件 /usr/lib/systemd/system/${service}.service中的${action}, 如果通过的操作启用或禁用,则 servicectl将在 ${service}.service上创建或删除symlink以供使用服务。‎

参数:
action  - 可以是 {start, stop, restart, reload, enable, disable}
service - 在/usr/lib/systemd/system/文件夹中的文件

例如:

# inside chroot
sudo servicectl start mariadb


serviced:
sudo serviced [action]
‎此命令执行 ${action} 为所有启用服务。‎

参数:
action -默认是start,也可以是: {start, stop, restart, reload, disable}

例如:

# outside chroot: 
# init startup and run all enabled daemons
sudo chroot /path/to/chroot serviced

上篇:[手机Linux] 三,安卓手机Linux内网穿透(cpolar),实现远程连接_虾稿的博客-CSDN博客

下篇:[手机Linux] 五,打造属于自己的私有网盘(Cloudreve),跟百度网盘说拜拜_虾稿的博客-CSDN博客

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐