This article is based on the last mobile hard disk installed ArchLinux experience modified to add, but half a year, some of the basic components have been changed, Arch Linux is really enough to "toss".
PS: Based on the experience of the arch Linux for half a year, I rented the Linode VPS also used arch, now feel good, Nginx + php-fpm is really a good combination. Linode using the modified Linux kernel, AUR also published their own version of the update, has not yet been studied how to upgrade.
Basic System Installation
As with the last mobile HDD installation, select the 32-bit system. The installation media uses ARCHLINUX-2013.07.01-DUAL.ISO DD to another USB drive.
Use U disk to start, automatically enter the system as root.
Insert a removable hard drive, partition, format, mount.
Would like to use GPT partition table, check some information, in order to make this U disk in the BIOS and UEFI computer can be used, need to create a BIOS boot partition, 2M size enough, position as far as possible. Multiple systems also create a 200M EFI system Partition (ESP) partition. These are not the problem, but actually do it, GPT in the NTFS partition in the Win7, want to use this partition as a regular U disk use is not, had to go back to the MBR partition table. If you are moving a hard drive with GPT you should have no problem.
So you still use MBR partitions, so you'll need to use Fdisk or cfdisk, you can't use Gdisk and cgdisk that support GPT, and 4k alignment is automatically done. Interestingly, if you want to convert a GPT partition table into an MBR partition table, you have to use Gdisk:r to enter the Recovery mode, G into MBR mode, and W for conversion. Depending on the actual situation, some partitioning conversions may not be successful, but changing back to the MBR partition table is not a problem.
NTFS partitions are on the first partition, or Windows does not recognize them.
The launch U disk is/dev/sdb, the target u disk is/DEV/SDC.
# FDISK/DEV/SDB
disk/dev/sdc:8022 MB, 8022982656 bytes, 15669888 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk label Type:dos
Disk identifier:0x00000000
Device Boot Start End Blocks Id System
/DEV/SDB1 2048 1804287 901120 7 Hpfs/ntfs/exfat
/DEV/SDB2 * 1804288 2009087 102400 Linux
/DEV/SDB3 2009088 10405887 4198400 Linux
/DEV/SDB4 10405888 15669887 2632000 Linux
First partition with NTFS, when the normal U disk use, if you need to use the ESP partition, directly with this partition, or cut a part of the space past. The second partition 100M, Hang/boot, third partition 4G, as ArchLinux root partition, fourth partition 2.5G, as $HOME;
Format partitions:
If you use the XFS partitioning format:
# mkfs.ntfs-f/dev/sdc1-l f004-c
# mkfs.xfs-n Size=64k-l lazy-count=1/dev/sdc2-l f004-boot
# mkfs.xfs-n Size=64k-l size=128m,lazy-count=1/dev/sdc3-l f004-a
# mkfs.xfs-n Size=64k-l size=128m,lazy-count=1/dev/sdc4-l f004-b
The-n size=64k parameter increases the file name (directory) area size (default 4k), which reduces IO consumption, at the cost of more CPU consumption, which is clearly not a problem for modern computers. The-l size=128m parameter expands the capacity of the log (default 10m), and is more secure, at the cost of a longer mount time. The-l lazy-count=1 parameter reduces superblock read and write times and improves performance.
If you use the EXT4 partition format:
# mkfs.ntfs-f/dev/sdc1-l f004-c
# mkfs.ext4-b 4096-m 0-i 16384-o ' ^has_journal '/dev/sdc2-l f004-boot
# mkfs.ext4-b 4096-m 1-i 16384-o ' ^has_journal '/dev/sdc3-l f004-a
# mkfs.ext4-b 4096-m 0-i 16384-o ' ^has_journal '/dev/sdc4-l f004-b
The-b 4096 is the size of each storage block. -M 1 is to specify that the root reserve space for the 1%,home area is not left. -I 16384 is to specify how many bytes of data set an Inode node, increase its value will reduce the total number of inode, occupy less space, the corresponding ability to store the number of files also reduced, this a little attention is good, generally enough. -O ' ^has_journal ' is a little dangerous to turn off file system logs.
After two days of tossing, personal feeling ext4 on the U disk to read and write faster.
Mount Partition:
# mount/dev/sdc3/mnt
# Mkdir/mnt/boot
# Mount/dev/sdc2/mnt/boot
# Mkdir/mnt/home
# Mount/dev/sdc4/mnt/home
Df-h Check:
# XFS
FileSystem Size Used Avail use% mounted on
/DEV/SDC3 3.9G 33M 3.9G 1%/mnt
/DEV/SDC2 82M 5.2M 77M 7%/mnt
/DEV/SDC4 2.4G 33M 2.4G 2%/mnt/home
# EXT4
FileSystem Size Used Avail use% mounted on
/DEV/SDC3 3.9G 8.1M 3.8G 1%/mnt
/DEV/SDC2 96M 48K 96M 1%/mnt
/DEV/SDC4 2.5G 3.8M 2.4G 1%/mnt/home
EXT4 Change Bytes-per-inode does have a significant impact on the space occupied by the partition.
Install the basic system
There is no line from the home, the network is not configured, has been automatically connected.
Edit the/etc/pacman.d/mirrorlist and move the fastest source to the top. Generally speaking, the source of 163 and Taiwan is relatively fast, 163 seems to be unstable at times, and some sources of Chinese universities are IPv6. 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 128 packages, you need to download 158.37M content, installation is completed after 507.09M.
Install Grub: # arch-chroot/mnt Pacman-s Grub.
Generate Fstab: # genfstab-p-u/mnt >>/mnt/etc/fstab, and then change fstab (System defaults are generally better, not optimized also line):
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 the Nodiratime mount parameter to not record the directory read access time.
Put the/tmp on the TMPFS. (No separate partitions, free)
Discard mount parameters are no longer used.
This parameter is mainly for SSD hard disk, to do not support the mechanical hard disk of TRIM is invalid, to U disk seemingly effect is not obvious.
The Async mount parameter is no longer used to turn on asynchronous read-write mode. Because it's just "looks" fast, the actual data write speed does not improve, considering the stability, should this parameter be used?
Do not use barrier=0 mount parameters, this option seems to be suddenly cut off, pull a U disk, there is a chance of losing files or damaged partitions. (Based on my experience + reference)
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 ' f004 ' >/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 the/etc/mkinitcpio.conf, check the HOOKS segment, have the block parameter next to the Udev parameter (load earlier), and then # Mkinitcpio-p Linux to generate the img file. At the same time add the shutdown parameters, the role of the test later. Resume parameters on the forget, U disk is small, slow, support sleep more painful. (Note: The block parameter in the new version replaces USB PATA SATA SCSI and other parameters)
To install Grub:
# grub-install--target=i386-pc--recheck--boot-directory=/boot--NO-FLOPPY/DEV/SDC
# 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/SDC2
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, reboot. Start the USB drive can be closed.
Startup, the new installation of the U disk into a/dev/sdb, it is best to Mkinitcpio grub-install grub-mkconfig again, otherwise it is possible to start on the next or another machine, damaged partition table, lost files. It may not make sense, but this is how many times I have repeated the installation, there may be the following reasons:
Live plug, but I have been umount ah, should not be so fragile.
was damaged by USB 3.0 High Current, did not pull a U disk burn I am lucky? I have heard of USB 3.0 damage U disk data.
/boot originally did not have separate partitions, this should not.
Did you originally use GPT partitioning to acclimatized on your BIOS computer? Can't you use a GPT partition on a USB disk?
Anyway, after changing back to the MBR partition, looks more normal.
Initial Settings
If everything works, you can now log on to the system with root:
# uname-a
Linux f004 3.9.9-1-arch #1 SMP preempt Wed June 3 22:52:05 CET 2013 i686
# free-h
Total used free shared buffers Cached
mem:1.0g 54M 951M 0B 5.6M 27M
-/+ buffers/cache:21m 984M
swap:0b 0B 0B
# df-h
FileSystem Size Used Avail use% mounted on
/DEV/SDB3 3.9G 764M 3.1G 20%/
Dev 499M 0 499M 0%/dev
Run 503M 7.1M 496M 2%/run
Tmpfs 503M 0 503M 0%/dev/shm
Tmpfs 503M 0 503M 0%/sys/fs/cgroup
Tmpfs 503M 0 503M 0%/tmp
/DEV/SDB4 2.5G 3.8M 2.4G 1%/home
/DEV/SDB3 96M 39M 58M 41%/boot
Install U disk to take off, this U disk becomes/dev/sdb.
Configure the Wired network.
No network, you can directly set IP emergency, the back netctl is the normal settings:
# ip addr Add 192.168.0.100/24 dev enp0s4
# IP link set dev enp0s4 up
# IP route add default via 192.168.0.1
# echo nameserver 208.67.222.222 >>/etc/resolv.conf
Feel the device name ENP0S4 not accustomed to, can also be renamed in Udev (restart effective):
# Cat/etc/udev/rules.d/10-network.rules
subsystem== "NET", action== "Add", attr{address}== "00:50:70:a2:49:7d", name= "eth0"
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, you are now managing with Netctl:
# pacman-s IFPLUGD
# systemctl Disable Dhcpcd@eth0
# Systemctl Stop Dhcpcd@eth0 # to stop DHCP, or interfere
# Cd/etc/netctl
# CP Examples/ethernet-static Home
# VI Home # Set my static IP settings profile
# Systemctl Enable Netctl
# reboot, clear just temporary IP settings
# Netctl Start Home
# Netctl Enable Home
If you want to quickly switch network environment, and then create a new profile under the/etc/netctl/, with Netctl switch-to profiles to switch, will automatically stop the old. In more detail, I can see how I have chosen profile in my previous netctl.
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.
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:
# systemctl Restart NTPD
# 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 Yaourt
Add in/etc/pacman.conf:
[ARCHLINUXFR]
Siglevel = Never
Server = http://repo.archlinux.fr/$arch
Then Pacman-sy Yaourt completes the installation.
Install other common tools
Bash-completion ctags git htop openssh subversion tk
Graphics System
Because the U disk to carry around, so the graphics drive must have everything. Also do not pursue how fancy interface effect, concise and crisp, so choose Lxde+fluxbox.
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 & Fluxbox
All packages for the LXDE group
Fluxbox
Gamin of monitoring file system changes
Common software: Leafpad obconf Epdfview
Configure a simple $HOME/.xinitrc, copy a copy from/ETC/SKEL/.XINITRC, and then add:
#xrandr-S 1024x768 # If necessary, specify resolution in advance
EXEC Startlxde
Now are liquid crystal world, rarely appear resolution refresh rate beyond the bounds of the situation, the command line resolution can be used automatically, too small word on the above have modified Grub settings method, graphics under the LXDE also support auto resolution, generally also automatically set up.
In order to replace Openbox with Fluxbox, you need to modify the/etc/xdg/lxsession/lxde/desktop.conf:
[Session]
Window_manager=fluxbox
Chinese related
Basic Font Ttf-dejavu artwiz-fonts 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, PACMAN-SCC clean up, the installed program occupies about 1.4G of space. Overall feeling, running speed is affected by U disk read and write speed very big, sometimes will card.
...... After about two weeks of repetition, I finally came to the conclusion that the Linux system on a U disk would be almost without availability unless it was used only in read-only mode. Probably because of the restart, shutdown, Umount always can't wait for a U disk lights flashing to flash, forced to restart or shutdown, and then the file system is not normal umount, and then the file system is damaged, a repair are files lost, damaged inode. Is it because the quality of my u disk is not good? In any case, the idea of taking this to do with the system has been shattered, or magnetic media, mechanical hard disk is a little more reliable.