设为首页 收藏本站
查看: 546|回复: 0

[经验分享] archlinux下安装btrfs gpt 使用bios_grub方式启动

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-10-23 09:28:57 | 显示全部楼层 |阅读模式
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分区



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-26518-1-1.html 上篇帖子: CentOS 6.5下DNS服务器搭建与配置 下篇帖子: 搭建CentOS在线yum源镜像服务器(上)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表