Some detailed optimizations of Gentoo

Gentoo manual

1. Boot partition and cdrom are mounted correctly when booting

After installing gentoo Linux according to the gentoo manual, according to the manual example, the partition configuration file /etc/fstab should be as follows.

/dev/sda2   /boot        ext2    defaults,noatime     0 2
/dev/sda3   none         swap    sw                   0 0
/dev/sda4   /            ext4    noatime              0 1
/dev/cdrom  /mnt/cdrom   auto    noauto,user          0 0

We use EFI firmware to start the system, then the boot partition /dev/sda2 should be formatted as vfat partition format. If the partition is configured according to the above configuration file, the system cannot be set to /dev because the format is not the et2 format determined in the configuration file when the system starts. /sda2 is mounted to the directory /boot.

Although the system can be started, all existing kernel files and boot files on /dev/sda2 cannot be found in the directory /boot.

And with this configuration, cdrom does not automatically mount and open. So we do the following details to improve the boot partition /dev/sda2 and cdrom automatically and correctly mount the boot partition.

1.1 The configuration table is changed as follows

/dev/sda2   /boot        vfat    defaults,noatime     0 2
/dev/sda3   none         swap    sw                   0 0
/dev/sda4   /            ext4    noatime              0 1
/dev/cdrom  /mnt/cdrom   auto    auto                 0 0

1.2 Create a new directory /mnt/cdrom and mount cdrom to this directory

~# mkdir /mnt/cdrom
~# mount /dev/cdrom /mnt/cdrom

2. The network interface name of the predictable naming rule is changed to the traditional eth0

After installing gentoo linux according to the manual, the network interface name of the system is named according to the foreseeable network device naming rules. The virtual network card on the VMware virtual machine is named eno16777736, which is different from the traditional network interface name eth0 shown in the manual. Similarly, if you follow the manual completely, the network will not start correctly after restarting.

Some friends just like the traditional interface name. Is it possible to change the network interface name to the traditional interface name? of course can.

2.1 Edit the configuration file /etc/default/grub

(On any line) add the statement GRUB_CMDLINE_LINUX=”net.ifnames=0 to force the foreseeable network device naming rules to be disabled (enabled by default); if the sentence already exists in the configuration file, add net. ifnames=0 in quotation marks

~# nano -w /etc/default/grub

2.2 Use the grub-mkconfig command to update the kernel startup parameters in the shell

~# grub-mkconfig -o /boot/grub/grub.cfg

3. Add sudo command for admin user

After the system is installed, you should add an administrator user and try to use the administrator user to manage the system, unless it is necessary to never log in as the root user. Assuming that a normal user zhangsan has been added (as for how to add a normal user zhangsan, all friends should know), how to make zhangsan an administrator user and manage the system with the sudo command?

3.1 Install sudo command

~# emerge --ask app-admin/sudo

3.2 Edit the configuration file /etc/sudoers file

Copy the root ALL = (ALL) ALL line and modify root to the username zhangsan to allow the user zhangsan to obtain root privileges.

~# nano -w /etc/sudoers

4. Shell system output information shows garbled correction

The real terminal does not support the display of Chinese (Chinese can only be displayed in terminal emulators such as terminal under xwindow), and the Chinese display garbled (small squares) in the terminal.

Modify the LANG environment variable to make the system output information in English, which can be displayed correctly on the terminal. Of course, if the user enters Chinese into the document, the document editor (such as nano) opened in the terminal can still only display garbled characters (small squares).

~# export LANG=en_US

5. Time synchronization

Use the date command to check the time and find that the system time is not necessarily the same as the local time. Install and configure the time synchronization server ntp to make the system time be determined as Beijing time.

5.1 Install time synchronization server ntp

~# emerge ntp

5.2 Edit the configuration file /etc/ntp.conf and change the time service center to the China National Time Service Center.

~# nano -w /etc/ntp.conf

5.3 Finally, the time synchronization service ntpd is added to the startup

~# rc-update add ntpd default

Leave a Reply