archlinux下安裝btrfs gpt 使用bios_grub方式啓動


https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#EFI_System_Partition 
https://wiki.archlinux.org/index.php/Beginners'_Guide_(簡體中文)#Grub_2 
https://wiki.archlinux.org/index.php/Beginners%27_guide_(簡體中文) 
http://www.linuxsir.org/bbs/thread379335.html 虛擬機中測試使用全btrfs + GPT 過程需要注意的事項[分享] 
https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#EFI_System_Partition 
https://wiki.archlinux.org/index.php/GRUB2_(簡體中文)#.E5.88.9B.E5.BB.BA.E5.B9.B6.E6.8C.82.E8.BD.BD_UEFI_.E7.B3.BB.E7.BB.9F.E5.88.86.E5.8C.BA 

以前舊的fstab中 
/dev/disk/by-label/btrfs-root / btrfs defaults,noatime,compress=lzo,space_cache,autodefrag 0 0 
/dev/disk/by-label/btrfs-root / btrfs defaults,noatime,compress=lzo,space_cache,autodefrag 0 0 


#/dev/disk/by-label/debian64 / ext4 defaults,noatime 0 1
/dev/disk/by-label/arch64 / btrfs subvol=arch64_rootfs,compress=lzo,space_cache,autodefrag,rw,relatime,noatime 0 1 
/dev/disk/by-label/arch64 /home btrfs subvol=arch64_homefs,compress=lzo,space_cache,autodefrag,rw,relatime,noatime 0 1 
/dev/disk/by-label/arch64 /var/cache/pacman/pkg btrfs subvol=arch64_pkg,compress=lzo,space_cache,autodefrag,rw,relatime,noatime 0 1 


menuentry 'Arch Linux Btrfs' {

load_video

set gfxpayload=keep

insmod gzio

#insmod zlib

insmod btrfs


#set root='hd1'


set btrfs_rootfs=arch64_rootfs

set root_label=arch64

search --label --no-floppy --set=root $root_label

linux /$btrfs_rootfs/boot/vmlinuz-linux root=/dev/disk/by-label/$root_label ro rootfstype=btrfs rootflags=subvol=$btrfs_rootfs,compress=lzo,space_cache,autodefrag rootwait init=/usr/lib/systemd/systemd

initrd /$btrfs_rootfs/boot/initramfs-linux.img

#linux /boot/vmlinuz-linux root=/dev/disk/by-label/$root_label rw rootfstype=btrfs rootflags=subvol=$btrfs_rootfs rootwait init=/usr/lib/systemd/systemd

#initrd /boot/initramfs-linux.img

}



parted -a optimal -s ${DISC} mkpart 1 1 ${GUID_PART_SIZE} >${LOG} 
parted -a optimal -s ${DISC} set 1 bios_grub on 腳本自動設置指定分區爲bios_grub 


ip link set enp2s0f0 up 
ip addr add 192.168.1.2/24 dev enp2s0f0 
ip route add default via IP地址 
nano /etc/modules-load.d/virtio-net.conf 
# Load 'virtio-net.ko' at boot. 

virtio-net 
# pacman -S grub 
# grub-install --target=i386-pc --recheck /dev/sda

提示: 若想自動檢測硬盤上安裝的其它操作系統,請在執行下面命令前先安裝 os-prober, 即 pacman -S os-prober. 



# grub-mkconfig -o /boot/grub/grub.cfg 
Gummiboot 

安裝 gummiboot, 執行 gummiboot install 以安裝 bootloader 至 EFI 系統: 

# pacman -S gummiboot 
# gummiboot install 

GRUB 

安裝 grub 和 efibootmgr, 再執行 grub-install 來安裝 bootloader: 

# pacman -S grub efibootmgr 
# grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=arch_grub --recheck 

btrfs subvolume create /mnt/arch64_rootfs 
mount -t btrfs -o subvol=arch64_rootfs,space_cache,autodefrag,compress=lzo,noatime /dev/disk/by-label/arch64 /mnt 

顯示當前分區佈局: 
# lsblk -f 

UEFI 用戶也要格式化相應的 EFI 系統分區(以 /dev/sdaXY 爲例): 

# mkfs.vfat -F32 /dev/sdaXY 
# pacman -S dosfstools 

注意: 對於 UEFI 引導模式,磁盤需要有 GPT 分區表和 Unified Extensible Firmware Interface#EFI 系統分區,FAT32 格式,512 MiB 或更大,gdisk type 爲 EF00). 在以下示範中,假設 ESP 被掛載至 /boot. 

在第一扇區選擇 New (或者按 N) – Enter – Enter 以使用全部剩餘空間(或者您也可以輸入確定的大小,比如 "30G") – Enter 以保持默認的十六進制碼 (8300) – 

UEFI boot. It should be marked as EF00 or ef00 type code in gdisk, 
Create a FAT32 partition and in GNU Parted set/activate the boot flag (not legacy_boot flag) on that partition 
Note: If you get the message WARNING: Not enough clusters for a 32 bit FAT!, reduce cluster size with mkfs.fat -s2 -F32 ... or -s1, otherwise the partition may be unreadable by UEFI. 
Shell代碼 

GUID Partition Table aka GPT 
Main article GUID_Partition_Table 

Bit 2 of the attributes for the /boot partition need to be set. 
# sgdisk /dev/sda --attributes=1:set:2 

This would toggle the attribute legacy bios bootable on partition 1 

Verify: 
# sgdisk /dev/sda --attributes=1:show 
1:2:1 (legacy BIOS bootable) 

Install the master boot record: 
# dd bs=440 conv=notrunc count=1 if=/usr/lib/syslinux/gptmbr.bin of=/dev/sda 

Shell代碼 

error filesystem 'btrfs' doesn't support blocklists 
網上也多建議/boot單獨分區,非btrfs,但貌似樓上諸位都是btrfs的/boot分區,需要什麼特別的hack嗎 
已解決:還是需要gpt,分一個2M的bios分區,看來grub2還是不能象支持ext4及其它分區一樣簡單支持btrfs 

額外要求的分區: 
如果您使用 UEFI 主板,您需要創建一個額外的 EFI 系統分區。 

如果您使用 BIOS 主板(或打算以 BIOS 兼容模式引導),並且您希望在 GPT 分區驅動器上安裝 GRUB, 您需要創建一個額外的 1 至 2 MiB,類型代碼爲 EF02 的 BIOS 引導分區。syslinux 則不用 

EF00類型爲UEFI分區 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章