To install the ArchLinux tutorial on a mobile hard drive

Source: Internet
Author: User
Tags get ip locale uuid arch linux

The best way to familiarize yourself with the Arch Linux is to use it often and toss it. My Linux experience is not rich, change Arch will certainly encounter many new problems, in order not to delay the normal use, can not be installed in the formal work on the machine (including the company and the home), there is no additional machine, had to choose to install it on the U disk or mobile hard disk.

As for the server, I do not recommend easy to replace into Arch, not to mention the desktop is not familiar with the use, is familiar with, and do not have the energy to regularly upgrade the server. So the server is still using the current Ubuntu bar, more convenient, also calculate stability. Even an old release that is no longer maintained, the official offers an old release warehouse. There are no individual new software in the warehouse, and the installation method can be found on the Internet. So, before mastering Arch and having enough energy to regularly upgrade, don't toss the production server and choose carefully.

Basic System Installation

has been looking for a 2G u disk installed, streamlined installation, the speed is considerable. But the U disk is too small, installed to be able to use the basic words, the user available space is only 100M, so can only be reserved for emergency. In addition, the operating system for a long time on the U disk operation, but also affect the life of flash memory, so this time with mobile hard disk to install, ready for longer term use.

This mobile hard drive is to carry around, so choose 32-bit system, no way home is a classic machine. Partitions are also conservative, and still use MBR rather than GPT. The installation media uses Archlinux-2012.11.01-dual.iso to burn the disc.

Use CD-ROM to boot and automatically enter the system as root.

Insert a removable hard drive, partition, format, mount.

Because you do not use GPT partitions, Gdisk and Cgdisk are not available, only Fdisk and Cfdisk. FDISK reserves 2048 sectors, but Gdisk starts with 64 sectors. The partitions are completed as follows:

# FDISK/DEV/SDB

disk/dev/sdb:40.1 GB, 40060403712 bytes, 78242976 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk IDENTIFIER:0XB245C8A1

Device Boot Start End Blocks Id System
/DEV/SDB1 * 2048 20973567 10485760 Linux
/DEV/SDB2 20973568 41945087 10485760 Linux
/DEV/SDB3 41945088 77596671 17825792 7 Hpfs/ntfs/exfat
/DEV/SDB4 77596672 78242975 323152 Linux Swap/solaris

The first partition 10g,btrfs format, as the Arch Linux partition, the second partition 10G,EXT4 format, as the $HOME; the third partition 17g,ntfs format, used for daily data storage and exchange, and occasionally for mobile hard disk; Fourth partition 300M, do SW Ap.

Format partitions:

# mkfs.btffs/dev/sdb1-l F006-a
# mkfs.ext4/dev/sdb2-l F006-b
# mkfs.ntfs-f/dev/sdb3-l f006-c

Without a detailed study of the management of btrfs partitions, it is just as well to be used as other formats.

Mount Partition:

# mount/dev/sdb1/mnt
# Mkdir/mnt/home
# Mount/dev/sdb2/mnt/home

Df-h look:

FileSystem Size Used Avail use% mounted on
/DEV/SDB1 10G 312K 8.0G 1%/mnt
/DEV/SDB2 9.9G 151M 9.2G 2%/mnt/home

As you can see, the Btrfs partition takes up less space than the EXT4 partition itself, but it seems to retain 20% of the hard disk space as a standby? No wonder I have a small disk space.

Install the basic system

There is no line from the home, the network is not configured, has been automatically connected.

Edit/etc/pacman.d/mirrorlist, put the fastest source on the top. I put the 4 sources in the Chinese area above, and the 163 move to the front. Once the installation is complete, the configuration file is automatically copied to the new system. Since the vi is really more difficult than vim, a moment to replace the first time.

According to the official website instructions, with the # PACSTRAP/MNT base base-devel installation of the basic system, Base-devel also installed, sooner or later will be used to AUR or ABS. Tip A total of 130 packages, you need to download 150M content, installation is completed after 550M.

Install Grub: # arch-chroot/mnt Pacman-s Grub-bios.

Generate Fstab: # genfstab-p/mnt >>/mnt/etc/fstab, then change fstab (U disk must be optimized for top 3):

Use Relatime to mount parameters.

Previously, it was recommended to increase the Noatime mount parameters, not to record the file read time, but this would result in errors in software such as Mutt that require file read time. Now instead of using the Relatime parameter (which has been added by default, Linux 2.6.30 becomes the default), the read time data is updated only if the file read time is earlier than the file update time.

Use discard to mount parameters.

This parameter is mainly for SSD hard disk, the ordinary hard disk should also have some effect.

Put the/tmp on the TMPFS.

Considering the data security, there is no log to close the file system, its speed-increasing effect is not obvious in daily use.

Because there is no big application to run, to reduce the frequency of swap, modify the/mnt/etc/sysctl.conf:

vm.swappiness = 1
Vm.vfs_cache_pressure = 50

The previous sentence is to try not to use swap, the latter is to cache file system information.

The following actions can be run in a chroot environment:

# arch-chroot/mnt

Set Hostname:echo ' f006 ' >/etc/hostname.

To set the time zone:

# ln-s/usr/share/zoneinfo/asia/shanghai/etc/localtime

The new/etc/locale.conf content is:

Lang= ' en_US. UTF-8 '
Lc_collate= ' C '
lc_messages= ' C '

Edit/etc/locale.gen and Cancel en_US. UTF-8, ZH_CN. UTF-8, ZH_TW. UTF-8 the previous comment, and then execute the locale-gen command.

Change root password: passwd root.

Install the Grub boot system.

Still operates in the chroot environment. Edit/etc/mkinitcpio.conf, add USB parameters to the HOOKS segment, and then # Mkinitcpio-p Linux to generate an img file. At the same time add the resume and shutdown parameters, the effect will try again. (Note: The block parameter in the new version replaces USB PATA SATA SCSI and other parameters)

To install grub to MBR:

# grub-install--target=i386-pc--recheck--boot-directory=/boot--no-floppy/dev/sdb
# cp-v/USR/SHARE/GRUB/{UNICODE.PF2,ASCII.PF2}/boot/grub/
# cp-v/usr/share/locale/en@quot/lc_messages/grub.mo/boot/grub/locale/en.mo

Whether 32-bit or 64-bit systems are using the--TARGET=I386-PC parameter,--no-floppy does not check the floppy drive (this thing should not be used now). The latter two sentences do not carry out, still do not understand what is done.

Then, never forget to generate the Grub.cfg file:

# Grub-mkconfig-o/boot/grub/grub.cfg
# grep ' Set=root '/boot/grub/grub.cfg
# BLKID/DEV/SDB1

The GRUB2 now uses a UUID to find the hard disk partition, and the second sentence checks to see if the partition UUID used by the newly generated grub.cfg matches the hard drive. If you forget to generate GRUB.CFG, you can start it again with a CD.

Finally, exit the chroot environment, Umount move the hard drive, reboot. The boot CD can be put away.

Initial Settings

If everything works, you can now log on to the system with root:

# uname-a
Linux f006 3.6.8-1-arch #1 SMP preempt Tue Nov 07:58:01 CET i686 gnu/linux

# free-h
Total used free shared buffers Cached
mem:499m 62M 436M 0B 676K 39M
-/+ buffers/cache:22m 477M
swap:0b 0B 0B

# df-h
FileSystem Size Used Avail use% mounted on
Rootfs 10G 814M 7.3G 10%/
Dev 248M 0 248M 0%/dev
Run 250M 4.5M 246M 2%/run
/DEV/SDB1 10G 814M 7.3G 10%/
Tmpfs 250M 0 250M 0%/dev/shm
Tmpfs 250M 0 250M 0%/sys/fs/cgroup
Tmpfs 60M 0 60M 0%/tmp
/DEV/SDB2 9.9G 151M 9.2G 2%/home

Install VIM, the default VI is not used to:

# pacman-s Vim
# Pacman-r VI
# ln-s/usr/bin/vim/usr/bin/vi

Turn off the PC small horn.

This is really annoying, disabled at startup:

# cat/etc/modprobe.d/nopcspkr.conf
Blacklist PCSPKR

This file needs to be created by itself.

Configure the Wired network.

If you use DHCD to dynamically assign an address:

# DHCPCD # automatically let Eth0 get IP
# # or configured as a service self-starter (more convenient)
# Systemctl Enable Dhcpcd@eth0
# Systemctl Start Dhcpcd@eth0

If you use a static address, one way is to configure the network service, which is troublesome, I use another method, Ifplugd + netcfg:

# pacman-s IFPLUGD
# systemctl Disable Dhcpcd@eth0
# Systemctl Stop Dhcpcd@eth0 # to stop DHCP, or interfere
# cd/etc/network.d/
# CP Examples/ethernet-static Home
# VI Home # Set my static IP settings profile
# Systemctl Enable net-auto-wired
# Systemctl Start net-auto-wired

If you want to quickly switch network environment, and then create a new profile under the/etc/network.d/, with netcfg-u profiles to switch, will automatically stop the old.

Configuring Networks= (last) in/etc/conf.d/netcfg automatically records the end-used profile, but only for network service methods. With net-auto-wired, it's sorted by file name, one Test profile, until the one that can be used, so to change the profile priority, change the file name.

Install NTP Automatic Update time

# pacman-s NTP Libedit
# Systemctl Enable NTPD
# Systemctl Start ntpd

In addition, Arch recommends adding Iburst parameters to the/etc/ntp.conf, such as:

Server 0.pool.ntp.org Iburst
Server 1.pool.ntp.org Iburst
Server 2.pool.ntp.org Iburst
Server 3.pool.ntp.org Iburst

Check ntpd Sync:

# NTPQ-NP

After the time synchronization is complete, write the hardware clock with hwclock-w.

Create an ordinary user.

# useradd-m Fwolf
# passwd Fwolf

Typically, this user will give sudo permission:

# pacman-s sudo
# cat/etc/sudoers.d/fwolf_sudo_conf
Defaults Env_reset
Defaults secure_path= "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
Fwolf all= (All:all) all
%admin all= (All)
%sudo all= (All:all) all
# chmod 0440/etc/sudoers.d/fwolf_sudo_conf

Note that the file under/etc/sudoers.d/, with a name of ~ or. Does not take effect, see centos–0005017:the #includedir directive in sudoers does not work, the file attribute must also be 0440.

Install other common tools

Bash-completion Htop

Graphics System

Because the mobile hard drive to carry around, so the graphics drive must be everything. Also do not pursue how fancy interface effect, concise and crisp, so choose Lxde+openbox.

Character Interface resolution

The default is to enter the character interface, resolution is the maximum resolution, if you want to specify, you can modify the/etc/default/grub:

grub_cmdline_linux_default= "Quiet video-1024x768m@75m"

Then grub-mkconfig-o the grub configuration file/boot/grub/grub.cfg.

Default Light NumLock

Two commands are required: The setleds of the system and the Numlockx installed via Pacman.

To open NumLock under the character interface, you can add in the $HOME/.BASHRC:

# NumLock
if [-x/usr/bin/setleds]; Then
For TTY in/dev/tty{1..6}; Todo
/usr/bin/setleds-d +num </dev/tty >/dev/null 2>&1
Done
Fi

This setting automatically turns on NumLock after you log on and opens before you log on, and you can add the above to/etc/rc.local or/etc/inittab in the context of an Arch Wiki, but it's easier to back up the user configuration.

To open NumLock under X, you can add the following in $HOME/.XINITRC:

# Set NumLock
if [-x/usr/bin/numlockx]; Then
/usr/bin/numlockx on
Fi

Install xorg and graphics drivers
Xorg:xorg-server Xorg-xinit Xorg-server-utils Mesa
Graphics driver: Xf86-video-ati xf86-video-intel Xf86-video-nouveau Nouveau-dri
Notebook Touch pad Support: xf86-input-synaptics
Test X is working correctly: XORG-TWM Xorg-xclock xterm

Now you can start X with StartX to see the rough graphical interface. If you want to turn off X with Ctrl+alt+backspace, you need to add a paragraph to the/etc/x11/xorg.conf.d/10-evdev.conf:

section "Inputclass"
Identifier "Keyboard Defaults"
Matchiskeyboard "Yes"
Option "Xkboptions" "Terminate:ctrl_alt_bksp"
Endsection

Install LXDE
All packages of the LXDE group, and then copy the three profiles of Openbox according to official instructions
Gamin of monitoring file system changes
Common software: Leafpad obconf Epdfview
Display Manager (graphical login interface) Slim, and sudo systemctl enable Slim

Configure a simple $HOME/.xinitrc, copy a copy from/ETC/SKEL/.XINITRC, and then add:

Xrandr-s 1024x768 # Specify resolution in advance
EXEC Startlxde

Install Startup Manager SLiM

This is good to install, the default can also be used, but the resolution and refresh rate is problematic. My old computer The best resolution for 1024X768@85HZ,LXDE is easy to set, but SLiM no direct way to set up, only to build a/etc/x11/xorg.conf as follows:

section "Monitor"
Identifier "Monitor0"
Vertrefresh 60.0-85.0
Usemodes "Modes1024x768@85"
Endsection

section "Device"
Identifier "Device0"
Driver "Nouveau"
Endsection

section "Modes"
Identifier "Modes1024x768@85"

# 1024x768 @ 85.00 Hz (GTF) hsync:68.60 kHz; pclk:94.39 MHz
Modeline "1024x768_85.00" 94.39 1024 1088 1200 1376 768 769 772 807-hsync +vsync

# 1024x768 @ 75.00 Hz (GTF) hsync:60.15 kHz; pclk:81.80 MHz
Modeline "1024x768_75.00" 81.80 1024 1080 1192 1360 768 769 772 802-hsync +vsync
Endsection

Section ' Screen '
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
Defaultdepth 24
Subsection "Display"
Depth 24
Modes "1024x768_85.00"
Endsubsection
Endsection

This configuration file is very simple (where modeline is generated by GTF), but given the compatibility of different machines, there is no SLiM, manual startx bar.

Chinese related

Basic font Ttf-dejavu artwiz-fonts Wqy-zenhei Wqy-microhei

Input Method Fcitx-im Fcitx-configtool fcitx-fbterm, added in $HOME/.xinitrc:

Export GTK_IM_MODULE=FCITX
Export QT_IM_MODULE=FCITX
Export xmodifiers= "@im =FCITX"

Font configuration, the original use of other common fonts and configuration files are moved over, is $HOME/.fonts directory, Ubuntu under the very good, here can also be used directly. $HOME/.fonts/fonts.conf link to/etc/fonts/local.conf is effective, and then the 40-nonlatin.conf and 60-latin.conf under/etc/fonts/conf.avail will be SimSun or any other font you like is set to the preferred font, the last $ fc-cache-vf update font cache, restart X on it.

At this point, a basic, graphical interface of the Arch Linux installation is completed, the basic program occupies about 1.4G of space. Overall feeling, the speed is affected by the read and write speed of the mobile hard disk very much (computer is USB 1.1 interface).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.