将ArchLinux安装到U盘上
最近可能比较蛋疼,想在笔记本上安装Archlinux,但是又不敢把硬盘格式化掉,怕原来配置好的Ubuntu13.04废了,Archlinux也没装好,那就白费了。
所以就打算把Archlinux安装到U盘上,感谢https://wiki.archlinux.org/,还有Google和度娘帮了不少忙,有点遗憾的是UEFI没配好,不怎么明白,希望路过的大神点播下.
接下来,Let's begin:
#
# Program:
# Install archlinux to Flash-disk
# History:
# 2014/04/05 Potter version 1.01
#
#
#
# 第8-9步至关重要,否则无法从usb启动
#
# 1.Partition
fdisk -l # Here's /dev/sdc is my Flash-disk ( 8G )
fdisk /dev/sdc
# need 3 partitions
# boot 100M
# / 6G
# /home ..
# 2、mkfs
mkfs.ext4 /dev/sdc1 # /boot
mkfs.ext4 /dev/sdc2 # /
mkfs.ext4 /dev/sdc3 # /home
# 3、mount
mount /dev/sdc2 /mnt
mkdir /mnt/boot
mount /dev/sdc1 /mnt/boot
mkdir /mnt/home
mount /dev/sdc3 /mnt/home
# 4、Modify /etc/pacman.d/mirrorlist
vi /etc/pacman.d/mirrorlist
# Speed First (China)
Server = http://ftp.tku.edu.tw/Linux/ArchLinux/$repo/os/$arch
Server = http://mirrors.163.com/archlinux/$repo/os/$arch
Server = http://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
# 5、pacstrap base system
pacstrap /mnt base base-devel
# 6、chroot
arch-chroot /mnt /bin/bash
# 7、download vim
pacman -S vim
# 8、
#Here you need to set the right hooks if the root is on a USB drive , if you use RAID , LVM , or if / usr is on a separate partition .
#
# Modify /etc/mkinitcpio.conf. Make my flash-disk can be supported
# Add 'usb' to "HOOKS" (Maybe in line 52)
# 因为这是U盘,要修改一下 /etc/ mkinitcpio .conf,找到 HOOKS= 这行,然后在等号后面加入 usb 。这样才会支持usb设备启动
# Like the following:
HOOKS="base udev usb block autodetect modconf filesystems keyboard fsck"
# 9、Renew mkinitcpio
mkinitcpio -p linux
# 10、Passwd root
passwd root
# 11、Something
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime # time zone
echo we > /etc/hostname # Hostname
# locale configure
vim /etc/locale.gen
en_US.UTF-8 UTF-8
zh_CN.GBK GBK
zh_CN.UTF-8 UTF-8
zh_CN GB2312
#
locale-gen
# 12、Install Grub
pacman -S grub
# 13、Install Grub On flash-disk (Here is /dev/sdc)
grub-install --target=i386-pc --no-floppy --recheck --debug /dev/sdc
# If Something errors , Run the follow commands
#That's add options '--force'
# grub-install --target=i386-pc --no-floppy --recheck --force --debug /dev/sdc
# 14、Generate 'grub.cfg'
grub-mkconfig -o /boot/grub/grub.cfg
# 15、Reboot to Your flash-disk. Congratulations!
exit
umount -R /mnt
reboot