一、制作mips64el架构的系统
OS: ubuntu 16.04
使用debootstrap制作根文件系统会分成两个阶段。第一阶段是,使用debootstrap命令来下载软件包。 第二阶段是安装软件包。
安装debootstap 等相关工具
$ sudo apt install binfmt-support qemu qemu-user-static debootstrap使用debootstrap 下载软件包
$ mkdir debian10_mips64el
$ sudo debootstrap --arch mips64el --foreign buster debian10_mips64el http://mirrors.ustc.edu.cn/debian/--arch:指定要制作文件系统的处理器体系结构,比如mipsel或者mips64el
buster:指定Debian的版本。buster是Debian10系统的代号。
debian10_mips64el:本地目录,最后制作好的文件系统会在此目录。
--foreign:只执行引导的初始解包阶段,仅仅下载和解压。
http:/mirrors.ustc.edu.cn/debian/:国内中科大镜像源地址因为主机跑在x86架构上,而我们要制作的文件系统是跑在龙芯上,因此可以使用qemu-mips64el-static来模拟成mips64el的执行环境。
$ cp /usr/bin/qemu-mips64el-static debian10_mips64el/usr/bin/通过chroot 使用debootstrap命令进行软件包的安装和配置。其中命令参数--second-stage表示执行第二阶段的安装
$ sudo chroot debian10_mips64el/ debootstrap/debootstrap --second-stage显示"I:Base system installed successfully."这句话,说明第二阶段已经完成。
通过chroot 进入刚制作的根文件系统
$ sudo chroot debian10_mips64el/
二、配置刚制作的系统
刚制作完成后的系统是最精简的,很多功能和命令都没有,因此需要配置一些必要的环境,因为我主要做C/C++,所以现在操作配置gcc的步骤。
刚装上的系统如果连接不上网的话,就需要配置网络,外部网络配置好基本就可以用。所以这部分就不说啦。
咱们说一说安装mips架构的gcc等工具,上面的中科大的源里我找了debian区没有找到支持mips的工具包,所以我找了找,最终切换到清华的源。(以下都是以root权限执行)
具体修改方法如下:
1.备份原始源文件,当然需要系统管理员权限操作
cp /etc/apt/sources.list /etc/apt/sources.list.backup
2.修改sources.list文件内容为清华源
vi /etc/apt/sources.list# tsinghua source
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb http://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free
deb-src http://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free
3.更新源
apt-get update
接下来就是执行安装gcc、g++等的命令了
apt-get install gcc
在安装时我遇到了一些问题导致安装失败,报错如下:
root@ubuntu:/tmp/mips64el-ubuntu-gcc6.3# apt-get install gcc
Reading package lists... Done
Building dependency tree... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
g++-6 : Depends: libisl15 (>= 0.15) but it is not installable
Depends: libmpc3 but it is not going to be installed
Depends: libmpfr4 (>= 3.1.3) but it is not installable
gcc : Depends: cpp (= 4:8.3.0-1) but it is not going to be installed
Depends: gcc-8 (>= 8.3.0-1~) but it is not going to be installed
Recommends: libc6-dev but it is not going to be installed or
libc-dev
gcc-6 : Depends: cpp-6 (= 6.3.0-18+deb9u1) but it is not installable
Depends: libcc1-0 (>= 6.3.0-18+deb9u1) but it is not going to be installed
Depends: binutils (>= 2.28) but it is not going to be installed
Depends: libgcc-6-dev (= 6.3.0-18+deb9u1) but it is not installable
Depends: libisl15 (>= 0.15) but it is not installable
Depends: libmpc3 but it is not going to be installed
Depends: libmpfr4 (>= 3.1.3) but it is not installable
Recommends: libc6-dev (>= 2.13-5) but it is not going to be installed
libstdc++-6-dev : Depends: libgcc-6-dev (= 6.3.0-18+deb9u1) but it is not installable
Depends: libc6-dev (>= 2.13-5) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
大意就是很多gcc依赖的库有损坏或不兼容的,那么我们可以执行这个操作,来修复或直接卸载这些包来适配合适的库:
apt-get -f install
然后重新执行之前未成功的gcc就OK了!接下来缺什么装什么~
End~~~
其他:给系统添加普通用户
- 创建一个新的普通用户
$ sudo useradd -m jeff -s /bin/bash #创建了可以登录的jeff用户并使用/bin/bash作为shell。
$ sudo passwd jeff #设置密码。
$ sudo adduser jeff sudo #为jeff用户增加管理员权限。
$ su jeff #切换登录用户为jeff。
- 给用户授权
$ groups jeff #查看jeff所在的组
$ usermod -aG sudo jeff #设置jeff权限为superuser
$ visudo #查看sudoer的文本文件,可以添加jeff ALL=(ALL:ALL) ALL为meow设置superuser权限
- 删除用户
$ deluser --remove-home jeff