歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

將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
 

Copyright © Linux教程網 All Rights Reserved