新建Arch 64位虛擬機,內存1G,掛載Archlinux2015.05.01的ISO文件到光盤,網絡選擇橋接物理機網卡,硬盤設置32G。在"設置--系統--主板--擴展特性"下面勾選“啓用EFI",然後啓動虛擬機,選擇第一個菜單啓動。
啓動完成後自動登錄。
開始對虛擬機硬盤分區,GPT模式,分三個區,一個給EFI啓動,一個/,一個SWAP。
root@archiso ~ # parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
New disk label type? gpt
(parted) mkpart
Partition name? []?
file system type? [ext2]?
Start? 0
End? 300M
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I
(parted) mkpart
Partition name? []?
file system type? [ext2]?
Start? 300M
End? 32G
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I
(parted) mkpart
Partition name? []?
file system type? [ext2]?
Start? 32G
End? 34G
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I
(parted) quit
Information: You may need to update /etc/fstab
root@archiso ~ #
然後格式化分區
root@archiso ~ # mkfs.vfat -F32 /dev/sda1
root@archiso ~ # mkfs.ext4 /dev/sda2
root@archiso ~ # mkswap /dev/sda3
然後掛載分區
root@archiso ~ # mount /dev/sda2 /mnt
root@archiso ~ # mkdir -p /mnt/boot/efi
root@archiso ~ # mount /dev/sda1 /mnt/boot/efi
root@archiso ~ # swapon /dev/sda3
4. 清空mirrorlist文件,並寫入163的源。
root@archiso ~ # echo > /etc/pacman.d/mirrorlist
root@archiso ~ # nano /etc/pacman.d/mirrorlist
Server = http://mirrors.163.com/archlinux/$repo/os/$arch
5. 開始安裝系統
root@archiso ~ # pacstrap /mnt base base-devel
6. 安裝完後寫入分區表,切換到新系統
root@archiso ~ # genfstab -U -p /mnt >> /mnt/etc/fstab
root@archiso ~ # arch-chroot /mnt
sh-4.3#
7. 編輯/etc/locale.gen,去掉一下三個前面的#號註釋,並運行
sh-4.3# nano /etc/locale.gen
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
zh_CN.GB2312
sh-4.3# locale-gen
8. 設置主機名和root密碼
sh-4.3# echo arch150501 > /etc/hostname
sh-4.3# passwd
Enter new UNIX password: Ab12345678
Retype new UNIX password: Ab12345678
passwd: password updated successfully
sh-4.3#
9. 安裝幾個軟件和grub啓動器,要裝EFI版本的。
sh-4.3# pacman -S openssh net-tools vim grub-efi-x86_64 efibootmgr
10. 把GRUB裝到EFI分區裏,這樣就多一條GRUB啓動項了。
sh-4.3# grub-install --efi-directory=/boot/efi --bootloader-id=arch-grub --recheck
11. 生成grub配置文件,在Grub里加一條啓動項。
sh-4.3# grub-mkconfig -o /boot/grub/grub.cfg
12. 到此安裝完成,卸載,重啓,或者關機,卸載光盤ISO再啓動
sh-4.3# exit
sh-4.3# umount /mnt/boot/efi
sh-4.3# umount /mnt
sh-4.3# reboot
13. 關機後卸載ISO文件再啓動出現一個BUG,可能是Virtualbox的EFI有問題,不能正確引導GRUB。
臨時解決辦法,在UEFI Shell提示符後面輸入以下命令啓動GRUB.
2.0 Shell> fs0:\EFI\arch-grub\grubx64.efi
找到最終解決辦法:
A. 在shell提示符裏面查看啓動的菜單.
2.0 Shell> bcfg boot dump -v
Option: 00. Variable: Boot0000
DeSC - EFI DVD/CDROM
DevPath - PciRoot(0x0)/Pci(0xD,0x0)/Sata(0x1,0x0,0x0)
Optional- N
Option: 01. Variable: Boot0001
DeSC - EFI Hard Drive
DevPath - PciRoot(0x0)/Pci(0xD,0x0)/Sata(0x0,0x0,0x0)
Optional- N
Option: 02. Variable: Boot0002
DeSC - EFI Internal Shell
DevPath - MemoryMapped(0xB,0x3FC4F000,0X3FFBEFFF)/FvFile(7C04A583-9E3E-4F1C-AD
65-E05268D0B4D1
Optional- N
B.刪除光驅啓動目錄
2.0 Shell> bcfg boot rm 0
C.然後進入EFI分區,查看目錄
2.0 Shell> fs0:
2.0 FS0:\> ls
Directory of: FS0:\
05/05/2015 07:03 <DIR> 4,096 EFI
0 File(s) 0 bytes
1 Dir(s)
2.0 FS0:\>
D.在EFI目錄下建立boot目錄,複製arch-grub目錄下的grubx64.efi到此目錄
2.0 FS0:\> cd EFI
2.0 FS0:\EFI> mkdir boot
2.0 FS0:\EFI> cd arch-grub
2.0 FS0:\EFI\arch-grub> cp grubx64.efi FS0:\EFI\boot
Copying FS0:\EFI\arch-grub\grubx64.efi -> FS0:\EFI\boot\grubx64.efi
- [OK]
E.將grubx64.efi該名爲bootx64.efi
2.0 FS0:\EFI\arch-grub> cd ..
2.0 FS0:\EFI\> cd boot
2.0 FS0:\EFI\> mv grubx64.efi bootx64.efi
Moving FS0:\EFI\arch-grub\grubx64.efi -> \EFI\boot\grubx64.efi
- [OK]
F.重啓,見到GRUB啓動菜單,然後就到登錄界面。