在x86平臺製作龍芯版debian 10系統(mips64el)+配置精簡系統

一、製作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

 

參考文章:

https://blog.csdn.net/mxcai2005/article/details/103663081

https://blog.csdn.net/Longyu_wlz/article/details/97886552

https://www.cnblogs.com/beanmoon/p/3387652.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章