linux 实验1

Experiment1 for linux

计算机科学与技术学院

2151539   樊烁硕

一、熟悉linux. 1

二、编译内核... 1

三、实验心得... 3

四、原实验要求... 3

Experiment 1. 3

1 Install and use a commercial Linux system (1.5 hours). 3

2 Build a Linux kernel (1.5 hours). 4

Reference. 4

 

一、熟悉linux

 

常用的命令行

 

uname –r               查看系统内核版本

 

tar xvJf                 解压.tar.xz…文件

 

mv sourcefile destination 移动文件

 

sudo su                切换到root用户

 

reboot                 重启

 

gedit  sourcefilename    用gedit编辑文件

 

 

二、编译内核

 

实验我一共做了三次:

 

第一次编译2.6内核,完全按照教材的步骤来,因为不熟悉一些命令导致出错,主要原因可能是配置.config文件的时候出错

 

第二次用3.19内核编译3.18内核,编译的时候没有出错,修改了grub.cfg文件之后重启出现如下界面,基本已经成功

但是进入的时候还是报错,上网差的原因大部分集中在需要给源代码打补丁,没有去尝试解决这个问题,又换了一个版本进行编译。

 

第三次3.19内核安装4.2.3内核,成功。其中4.2.3内核作为stable 内核是在10.3号官网更新的。

 

主要分为三大步,

a、下载,可以直接在kernel.org直接下载,也可以用git下载,为了熟悉gi的下载方式,我尝试了一下,但是用git下载速度很慢,以后不建议用这种方式,git下载无需解压,已经自动解压

b、配置.config文件 这里最好是用make menuconfig来配置,我用make defaultconfig没有成功

c、编译安装,原课本上的命令可能适用于2.6版本,但是3.0以上版本应该用如下四条命令来编译

make | make -j4

make modules

make modules_install

make install

 

 

 

 

 

总结一下,所有步骤如下

  (1) Download latest stable linux kernelsource code

https://www.kernel.org

Copy the kernelsource code to /usr/src

(2) Install libncurses-dev

   Use command su root to change to super usermode

apt-get update

apt-get install libncurses-dev

(3) Decompress.tarxvJf fileName.tar.xz

(4) Generate the .config file

     makemenuconfig

(5) make andinstall

make | make -j4

make modules

makemodules_install

make install

 

三、实验心得

 

a、编译4.2.3内核一次成功,这里感谢第一组同学详细的教程,我自己做的时候或多或少出错

 

b、如果是ubuntu下编译新内核,ubuntu官网有官网教程,可以参照,其他

   linux应该也有相应的官网

 

c、截至实验报告书写,还没有完全熟悉linux源码的目录结构,以后在课程进行中,可以不断的熟悉

四、原实验要求

 

 

 Experiment 1

1 Installand use a commercial Linuxsystem (1.5 hours)

(1)  Choosea commercial Linux version (eg. CentOS) and install.

(2)  Becomefamiliar with terminal, elementary commands, common utilities, basic shellscripts, and network configuration.

n  If youare on a Mac then you are in luck, you already have a terminal.

n  Anotheroption is to run Linux. Linux is completely free and there are many gooddistros out there. Some I would recommend include Ubuntu (which is quite popular and easy to use), CentOS and OpenSuSe. If you take this approach then there are a few ways youcan go.

­   If you have a spare machine then you can just install iton that.

­   You can create a dual boot system (i.e., both Windows andLinux are installed on the computer, you choose which to run when you boot up).Most modern Linux distros will handle creating this for you when you install it(resizing existing windows partitions as well). Do back up any important filesbefore doing this method though.

­   You can run Linux in a virtual machine. VMWare is a nicetool to use for this and it's totally free too.

n  Youmay also have access to a machine remotely. If you do then remotely logginginto these to access a terminal is an option as well.

 

2 Builda Linux kernel (1.5 hours)

(1)  Usegit to obtain the kernel source of linux-2.6

(2)  Installthe kernel source

(3)  Studythe kernel source tree

(4)  Buildthe kernel

(5)  Installthe new kernel

(6)  Usethe new kernel

 

Reference

https://www.kernel.org/

 

你可能感兴趣的:(linux)