- 1 Introduction
- 2 Pre-installation preparations
- download vmware workstation
- Download the files required for Gentoo
- knowledge points
- 1 We have downloaded a x86 architecture-based installation package Here we can learn what to use to differentiate architectures such as X86sparc MIPS, which are primarily used to differentiate between the different systems of the CPU's instruction set Different types of CPUs have different instruction sets so we choose to install packages and we need to select packages that match CPU instructions
- 2 Almost all PC PCs are x86x86_64
- 3 64-bit and 32-bit difference is CPU bus width different CPU total The line has a data bus control bus and address bus, the more the number of bits of the traffic is the greater the throughput of a single transmission, the more memory addresses that can be accessed by more address bus bits can support larger memory
- 3 start a virtual machine
- to create a new virtual machine from the VMware New wizard
- start virtual machine
- 4 Hard disk operation
- hard disk operation refers to formatting and partitioning the hard disk
- Many people will find this step a little difficult to use Windows too long accustomed to Windows Settings
- fdisk and Gdisk are available How do you differentiate between these two tools by partitioning and formatting the hard disk?
- that's so long.
- start hard disk operation
- 5 pre-installation of
- 6 Enter a new environment chroot
- 7 Install kernel
- Let's learn the manual installation kernel
- The really convenient way to install is Genkernel all
- 8 System Configuration
- etcfstab
- Network information
- install bootloader
- installation complete
1.1 Introduction
Why is Gentoo?
In the past, learning Linux could start with installing a Linux system, but now Linux systems are getting easier to install, but to learn, we have to pick a somewhat challenging Linux distribution, Gentoo is a slightly cumbersome Linux distribution, Just right for us to learn the installation system.
The Gentoo installation is basically network-dependent, so before installing, we must ensure that our computer can connect to the network.
We use VMware virtual a computer to install the system, so that more convenient to learn and play, under the Linux learning, under the Windows game, learning the game two.
1.2 Pre-installation preparations 1. Download VMware Workstation
可以在这里下载:http://www.vmware.com/cn/products/workstation/workstation-evaluation
2. Download the required files for Gentoo
1. 启动计算机所需要的启动CD [点击下载当前使用的启动CD](http://distfiles.gentoo.org/releases/x86/autobuilds/20160621/install-x86-minimal-20160621.iso) 2. stage,stage的文件档案包含了安装gentoo的基本环境,linux文件目录结构。 [点击下载当前使用的版本](http://distfiles.gentoo.org/releases/x86/autobuilds/20160628/stage3-i686-20160628.tar.bz2) 3. portage,是一个软件文件快照,是gentoo软件包管理的仓库目录 [点击下载当前使用的portage](http://gentoo.osuosl.org/snapshots/portage-20160602.tar.bz2) 4. xshell 为了方便控制虚拟机,我们需要一个终端模拟器,xshell正是我们所需 [在这里可以下载到它](http://xshell.en.softonic.com/)
3. Knowledge points (1). We download the x86 architecture-based installation package, where we can learn what to differentiate between schemas, such as: X86,SPARC, MIPS, etc., which are mainly used to distinguish between different systems of the CPU instruction set, different types of CPUs have different instruction sets, So when we choose to install the package, we need to select the package that matches the CPU instructions. (2). Almost all personal computers (PCs) are X86 (x86_64). (3). The difference between 64-bit and 32-bit is that the CPU bus width is different, the CPU bus has the data bus, the control bus and the address bus, the more the number of bus bits represents the larger the volume of the transmission (throughput); the more address bus bits, the more memory addresses you can access (which can support larger memory). 1.3 Start the virtual Machine 1. Create a new virtual machine from the VMware New wizard
is the choice of the disc image, which is the install CD we downloaded
Figure 1.3.1
我选择了网络桥接方式,等同于把虚拟机和主机接着同一个集线器般,这样方便分配IP地址。
Figure 1.3.2
Figure 1.3.3
2. Start the virtual machine
When the screen appears, press ENTER directly.
The Install CD loads the default kernel and returns a root shell to the user.
When you see the screen, the virtual machine starts successfully, which is a LiveCD based Linux system.
Now it's your turn to Xshell, do not know if you have installed the Xshell?
In order to use Xshell, we have to open the LiveCD sshd service, but also to set the root password, livecd default root is a blank password.
We entered the virtual machine and typed the following command:
passwd root #输入任意能记住的密码vi /etc/ssh/sshd_config #修改sshd配置文件,具体修改看/etc/init.d/sshd start #启动sshd服务
The 44th line in the Sshd_config configuration is changed to Permitrootlogin Yes, allowing root to log in remotely via SSH
Line 72nd Open Passwordauthentication Yes
Call Xshell to create a new connection, as shown in the following illustration:
Name is any word, host please fill in the IP of the virtual machine, can be typed into the virtual machine:
Ifconfig
In order to cater to the preferences and more tall, Xshell can be configured as follows:
1.4 HDD Operation 1. Hard disk operation refers to the format and partitioning of the hard disk.
The popular format for Linux is EXT3,EXT4,XFS, which can be compared to the ntfs,fat of Windows.
EXT3/EXT4/XFS and other formats are called file systems under Linux.
We can partition and format the hard disk by using the tools provided by Linux: Fdisk,gdisk, etc.
2. Many people will find this step a bit difficult, difficult to use Windows too long, accustomed to the Windows settings.
- Linux file system does not have the name of the disk, it has only one character '/', called root, root of roots, it is also like roots, is the origin of all files.
- To access any Linux file, its absolute path must start at '/'.
- Linux any regular directory can be similar to Windows-like letter, the use of conventional to describe, because some directories are more special, such as/dev, is the hardware device mount directory,/dev inside the file is the system can access the hardware devices, This is where Linux differs from window, where Linux uses hardware as a file, and when you manipulate (read and write) hardware, it is as simple as manipulating files. Also like/proc, this is an in-memory data map of the file directory, the contents of the file is a true reflection of the current system kernel settings, read and write/proc files can be real-time interaction with the kernel.
- After the hard disk partition can be arbitrarily mounted in the Linux directory, a successful mount scenario is the premise: the root directory '/' must have a partition mount. That is, if the hard disk has only one partition, the partition must be hung under the '/', if the hard disk has two partitions, in addition to the partition mounted under the '/', another partition can be arbitrarily mounted to the general directory of Linux, for example:/home.
- The mount of the partition is actually equivalent to assigning a drive letter to the hard disk, like Windows, the partition is mounted under the '/', we can call this partition as a '/' disk (root disk), but I suggest or forget the windows about the letter of the title.
- Linux has a standard to spec file directory: Filesystem Hierarchy (FHS), we only need to know a few important directories for the time being:
(1)/: root root directory;
(2)/usr:unix software resource, is the Linux software installation and implementation of the directory;
(3) configuration file directory of/etc:linux software
3. Fdisk and Gdisk are all tools that can partition and format hard disks, how do you differentiate between these two tools?
- First of all, we need to know that the hard disk has a table to record: in several areas? Size of each area?
- Therefore, there are different partitioning methods, mainly MBR (Master Boot Record) and GPT (GUID partition table)
- MBR mode only a small amount of space (64 bytes) to record the partition table, the size of the space can only record 4 sets of partition information, so the MBR method can only divide a hard disk into 4 zones, sometimes 4 areas may not meet the demand, smart people come up with a method of indirect records, This is the main partition and extension (logical) partition of the salutation, extended partition means that in the partition to expand the extra space to record the hard disk partition table, the expansion of the new record space is not subject to the size of the MBR 64byte, can be divided into multiple logical partitions. This is equal to the first record a message in the MBR, the more detailed partition table to the extended partition to find space, this indirect method is like a C language pointer.
- GPT mode does not have MBR restrictions, GPT uses 34 equivalent to MBR block size of the space used to record the partition table, and GPT is different from the MBR only one chunk is destroyed and dead, GPT in addition to using the hard disk to start the 34 block record partition table, The last 33 blocks of the hard drive are also used to back up the tables. Why is 33 chunks, not 34 backup chunks? Because the GTP 1th block is used to store the boot manager, this is also to be compatible with MBR, MBR itself size is 512 bytes, but reserved 446 bytes is used to store the boot program.
- Boot Manager (boot loader) is the first (number No. 0) block in which a hard disk is placed
(1) Why in the first chunk? For the convenience of reading and remembering.
(2) What program will go to read boot loader? The answer is BIOS, I believe everyone knows, BIOS is written on the motherboard rom a program, as long as the motherboard is powered on, the BIOS will automatically run.
4. What's the difference between Fdisk and gdisk when you say so long?
The difference is that Fdisk only knows the MBR partition table.
and Gdisk knows GPT.
5. Start the hard drive operation
Let's keep it a little more conservative by using Fdisk to split the hard drive.
Lsblk #输入这个命令可以列出当前可系统里面的存储设备
FDISK/DEV/SDA #列出的sda, the path is under/dev
Below I divide the hard disk into two disks, one is 1024M size, the other is 39G size
Finally press W to save, hard disk partition completed, next to the hard disk format
, I use a command, MKFS.XFS the/DEV/SDA2 format into XFS format, where MKFS.XFS can set a lot of parameters to change the performance of the hard drive, but we use the preset parameters are already very good, my plan is to put/dev/sda2 mounted in/below.
I then use Mkswap to format the/DEV/SDA1 into swap format partition, this is used for virtual memory, when the physical memory is low, the system will use this virtual memory space (hard disk to simulate memory, so called virtual memory).
Until this, the partition and format of the hard disk is complete, then the Gentoo system environment installation, stage installation.
1.5 Pre-installation sequence
We download a tool WINSCP transfer the files mentioned in section 1.2.2 to the virtual machine
WINSCP download
Mount/dev/sda2/mnt/gentoo#把硬盘sda2这个分区挂载到/mnt/gentoo This directory#然后我们打开winscp将方件伟输到 the/mnt/gentoo directoryCD/mnt/gentoo#进入到gentoo目录, after the hard drive is mounted, the/mnt/gentoo directory is equivalent to the partition drive letter of the hard diskTar xvf stage3-i686-20160628. tar.bz2#解压stage包, the tar command is equivalent to the RAR of window, which is the package management commandTar xvf portage-20160602. tar.bz2-c/usr#安装Portage快照, a collection of files used to tell Portage which software titles are available for installation, which profiles can be selected by the administrator, and so on. Mirrorselect-i-O >>/mnt/gentoo/etc/portage/make.conf#选择镜像文件Cp-l/etc/resolv.conf/mnt/gentoo/etc/#复制DNS信息#下面命令是挂载必要的文件系统MOUNT-T proc Proc/mnt/gentoo/proc Mount--rbind/sys/mnt/gentoo/sys#/sys is a file system similar to/procMount--make-rslave/mnt/gentoo/sysThe #--make-rslave operation is required to install SYSTEMD support later. Mount--rbind/dev/mnt/gentoo/dev#--make-rslave The meaning of a bound mountMount--make-rslave/mnt/gentoo/dev
After the preparation (installation), we have created a new Linux environment, then we will enter this new environment
1.6 Entering the new environment chroot
Now that all the partitions have been initialized and the underlying environment is installed, it is time to go into the new installation environment. This means that the session will change the root (the topmost location you can access) from the current installation environment (installation CD or other installation media) to the installation system (called the initialization partition). So called change root or chroot.
There are three steps to completing a chroot:
Use chroot to change the root position from/(in the installation medium) to/mnt/gentoo/(in the partition)
Use the source command to reload some settings (those in/etc/profile) into memory
Change the main prompt to help us remember that the current session is in a chroot environment.
Chroot/mnt/gentoo/bin/bashSource/etc/profile#profile is the variable setting of the system about the environment parameterExportps1="(chroot) $PS 1" #PS1变量是命令提示字符, that's the character we'll reappear when we finish pressing ENTER.Echo "Asia/shanghai">/etc/timezone#更改/Add time zone# Configure Regions# Regions Not only specify the languages that the system should use to interact with the system, but also specify rules for string sorting, date and time display, and so on. Sed-i' s/#en_US. UTF-8 Utf-8/en_us. UTF-8 utf-8/g '/etc/locale.gen#复制上面的命令把/etc/locale.gen file en_US. UTF-8 UTF-8 in front of the # removedLocale-gen#运行locale-gen, it will generate all the regions specified in the/etc/locale.gen file. Env-update &&Source/etc/profile &&Exportps1="(chroot) $PS 1"#执行上面这条命令再次更新系统环境, we can view all the variables in the current system environment through the SET command.Swapon/dev/sda1#将虚拟内存打开, avoid insufficient physical memory when compiling software, resulting in compilation failure
Through the above steps, we basically completed the Gentoo system configuration, then we do the most important step, that is to install kernel, strictly speaking, Linux is only a kernel.
1.7 Installing Kernel
Without kernel, the system will not be able to start, not to mention running. Maybe you'll ask: we don't have kernel installed, why can we run the system now? In fact, we are using the LiveCD inside the kernel,chroot into the Gentoo environment is also because LiveCD has compiled good kernel, also because there is this KERNEL,LIVECD to provide a minilinux environment.
In the past, kernel compilation and installation is the most difficult step, but in Gentoo, you can use Genkernel this tool to automate the generation and installation of the Linux kernel, simple to fool.
1. Let's learn the manual installation kernel
Manually configuring the kernel is often considered by Linux users to be the most difficult step. That's not true--but once you've configured the kernel several times, you won't find it hard anymore:)
In any case, one thing is true: when you manually configure the kernel, it is important to understand the (hardware) system. Most of the information can be collected by installing the Sys-apps/pciutils that contains the LSPCI command:
Emerge–ask sys-apps/pciutils #这条命令用来安装pciutils
In addition to running lsmod to see what kernel modules are used by the installation CD, it may provide a good hint of what to enable.
First we have to download the source code for kernel:
Emerge–ask sys-kernel/gentoo-sources
Here is a connection to the kernel configuration:
Kernel Configuration guidance
Because there are many chapters in the Linux kernel configuration, it is no longer discussed here.
2. The truly convenient installation method is Genkernel all
Manual configuration is cumbersome, but with manual configuration there is no doubt that you have a deeper understanding of the hardware and a preliminary understanding of the kernel architecture.
Genkernel method is very simple, it is all the hardware driver, use of the unused to compile into a module, when the system starts dynamically detect the computer needs to use the driver, and then load.
emerge --ask sys-kernel/genkernel #安装genkernel软件genkernel all #自动编译和安装kernel
Kernel installed, the Linux system is initially installed, followed by several system configuration.
1.8 System Configuration 1. /etc/fstab
This file is a Linux system-mounted configuration file for hard disk partitions
File record partition mount point (in which directory to hang), partition format, partition Mount property (read and write), etc.
#通过下面的方法编辑/etc/fstab file, join the hard drive that we want to mount:Cat >/etc/fstab <<EOF/DEV/SDA2/XFS noatime0 1/DEV/SDA1 Swap swap Defaults0 0Eof# ' cat > ' means to put the standard output input ' > ' after the file; ' <<eof ' means input ' eof ' end output# Fstab A total of six fields#第一个字段是对分区的描述, which is the path to the device file#第二个字段是分区挂载点, where the partition should be mounted#第三个字段给出分区所用的文件系统#第四个字段给出的是挂载分区时mount命令所用的挂载选项. Since each file system has its own mount option, we recommend that you read the #mount manual (man mount) to get a list of all mount options. Multiple mount options are separated by commas. #第五个字段是给dump使用的 to determine if dump is required for this partition. In general, you can set this field to 0 (0). #第六个字段是给fsck使用的 to determine the order in which file systems are inspected after a system is not properly shut down. The root filesystem should be 1, while the others should be # 2 (set to 0 if the file system self-test is not required).
2. Network Information
Nano-w/etc/conf.d/hostname#nano是一个简易编辑器, you need to press Ctrl+x to exit# Set Host name variable, select Host nameNano-w/etc/conf.d/net# Copy the following lines to the shell, set the IP address and RouteCat >/etc/conf.d/net <<eofconfig_eth0="192.168.1.2 netmask 255.255.255.0 brd 192.168.0.255"routes_eth0="default via 192.168.1.1"Eof#注意上面的eth0是网卡接口名, may be different from eth0, first take a look at IfconfigIfconfig | Head-n1| Cut- D ': ' - F 1 #用上面这条命令可以输出第一个网卡接口名, if it's not eth0, use it to replace eth0.CD/etc/init.dln- SNet.lo net.eth0rc-update Add net.eth0 Default#这三条命令可以让eth0在电脑启动时自动启动, remember to replace eth0 with your network card name.passwd#敲入这个命令设置root密码, please remember the password you set.
3. Installing bootloader
We mention the boot loader in the hard disk partition, it is used to boot the operating system, so boot loader is generally installed in the first space of the hard disk-mbr, if the partition is recorded in GPT, boot loader also need to install to the first block of the hard disk.
Boot Loader has a lot of options for different bios, there is another BIOS called UEFI (Unified extensible Firmware Interface), which is used in conjunction with GPT. Different BIOS has different boot loader options, GRUB2 supports all current BIOS, so we choose GRUB2 as the bootloader of the system.
GRUB2 is simple, you can complete the installation by following this command
Emerge–ask Sys-boot/grub:2
Install the GRUB2, you need to configure it to enter the working state, the following command is to put GRUB2 into the head of the MBR.
Grub2-install/dev/sda
The following command is configured GRUB2, which automatically looks for the compiled kernel and generates the configuration file.
Grub2-mkconfig-o/boot/grub/grub.cfg
4. Installation Complete
After a toss-up, Linux installation is complete, reboot!
One of Linux getting Started step-by-step installation system