码迷,mamicode.com
首页 > 系统相关 > 详细

支持 efi 的主板 双系统安装 ubuntu - 学习 EFI 和 gpt

时间:2016-04-29 18:36:33      阅读:494      评论:0      收藏:0      [点我收藏+]

标签:


这次 在有两块硬盘的 机器上 双系统安装 ubuntu, 遇到了一些 以前没有的情况
了解到 两个以前没听过的名词

EFI  vs  BIOS
gpt  vs  mbr   两种分区表

参考链接 二里 还提到了  快速启动  安全启动过


详细介绍了 MBR+ BIOS 启动  以及 GPTF分区的格式
http://www.iruanmi.com/what-is-gpt-and-what-is-uefi/
http://tieba.baidu.com/p/3754146793



这篇文章介绍了 uefi 的启动方法 和启动顺序调整
http://blog.sina.com.cn/s/blog_53918a450102uzi6.html
UEFI的两种启动模式


https://help.ubuntu.com/community/Installation/FromUSBStick





UEFI 模式安装 ubuntu 的流程  官方 文档
https://help.ubuntu.com/community/UEFI


Installing Ubuntu in UEFI mode

The following sections describe how to install Ubuntu in UEFI mode, either because you‘re single-booting and want to try this boot mode or because you‘re dual-booting with another OS that‘s already installed in this mode.

Case when Ubuntu must be installed in UEFI mode

Having a PC with UEFI firmware does not mean that you need to install Ubuntu in UEFI mode. What is important is below: 

  • if the other systems (Windows Vista/7/8, GNU/Linux...) of your computer are installed in UEFI mode, then you must install Ubuntu in UEFI mode too.
  • if the other systems (Windows, GNU/Linux...) of your computer are installed in Legacy (not-UEFI) mode, then you must install Ubuntu in Legacy mode too. Eg if your computer is old (<2010), is 32bits, or was sold with a pre-installed Windows XP.

  • if Ubuntu is the only operating system on your computer, then it does not matter whether you install Ubuntu in UEFI mode or not.
我的机器上之前的windows 应该是 legacy mode 的,但是自动安装的 ubuntu却是 UEFI的
情况应该是  像这样
https://help.ubuntu.com/community/Installation/FromUSBStick#Ubuntu_single_boot_in_UEFI_mode

Ubuntu single boot in UEFI mode

Single boot Ubuntu systems are still often installed in BIOS/CSM mode. Normally you install in UEFI mode because Windows is installed in UEFI mode and you want to dual boot. But it is possible to install Ubuntu (and the flavours Kubuntu Lubuntu, Xubuntu) as a single boot system in UEFI mode too, which can be useful for two purposes

  • to keep the systems separated, Ubuntu in one drive and Windows in another drive (so it will actually be a dual boot system, but not during the installation). Probably stable when installed in an internal drive.  ----》  比较符合我的安装情况

  • to make a portable installed Ubuntu USB pendrive for UEFI mode (portable alias works in many computers). Not stable when installed in an external drive (USB stick).


所以系统安装时 相当于是 single mode 的方式,但为什么 没有给我默认安装成 legacy 方式呢。看来是 这个 live disk 系统启动的时候就是 通过 uefi 的方式启动的
https://help.ubuntu.com/community/Installation/FromUSBStick#Test_if_running_in_UEFI_mode
https://help.ubuntu.com/community/UEFI#Identifying_if_the_computer_boots_the_Ubuntu_DVD_in_UEFI_mode  ----》》》 我的 usb 的系统根据这个判断,是 通过 efi模式启动的

General principles

To install Ubuntu in UEFI mode:

  • Use a 64bit disk of Ubuntu. (Ubuntu32bit cannot be easily installed in UEFI mode. This is a problem if 32-bit UEFI is the only way your computer can boot, e.g. if you have a modern Intel Atom based laptop. In this case, you will need a complicated work-around.)

  • In your firmware, disable QuickBoot/FastBoot and Intel Smart Response Technology (SRT). If you have Windows 8, also disable Fast Startup.

  • You might want to use an EFI-only image to avoid troubles with mistakenly booting the image and installing Ubuntu in BIOS mode. 

  • Use a supported version of Ubuntu. Support for UEFI appeared in 11.10, but has become more reliable in next versions. Support for UEFISecureBoot appeared in 12.10 and 12.04.2.

  • Set up your firmware (BIOS) to boot the disk in UEFI mode (see the "Identifying if the computer boots the HDD in UEFI mode" paragraph below)

  • Then:
    • nothing special is required if you use the automatic installer of Ubuntu ("Install Ubuntu alongside others" or "Erase the disk and install Ubuntu"). Important: if you have a pre-installed Windows and you want to keep it, do not choose "Erase the disk and install Ubuntu". ---》 我选的是 erase,不过是另外一块盘
    • if you use the manual partitioning ("Something else"), the difference is that you will have to set the /boot/efi mount point to the UEFI partition. And if there was not any UEFI partition on your HDD, you first will have to create it (see the "Creating an UEFI partition" paragraph below).



Set up the firmware in UEFI or BIOS/CSM/Legacy mode

Some recent computers (>2011) allow you to set up the computer to boot either in UEFI mode or in BIOS/CSM/Legacy (not-EFI) mode. The way to adjust this setting depends on the computers, but generally this setting is located in the "Boot order" tab of the BIOS (to access the BIOS screens, it is generally necessary to press a key during the PC startup). It can also often be set on a per-boot basis by hitting a function key (F8 and F10 are common choices) soon after you power on the computer.

Note: Some UEFIs (e.g. American Megatrends‘ "Aptio", found on the Asus vivobook series) call Legacy mode "Compatibility Support Module" or simply "CSM".

Remark: Some UEFIs enable one to set up the boot mode for the optical drive separately from the boot mode for the HDD.

For example, below:

  • the "UEFI Hitachi" line allows to boot the HDD in UEFI mode,
  • the "P1: Hitachi" line allows to boot the HDD in Legacy (not-UEFI) mode,
  • the "P3: DVD" line allows to boot the Ubuntu CD in Legacy mode
  • the "UEFI: USB" line allows to boot the Ubuntu liveUSB in UEFI mode.

技术分享

Here is a 2nd example of UEFI boot mode setting, where the "Boot Mode" parameter enables one to choose the boot mode ("UEFI" or "Legacy") for all media (hard disk, CD, USB...) at the same time.

技术分享

Some other UEFIs propose an "UEFI/Legacy Boot:" option with the following choices: [Legacy only], [UEFI only] and [Both]. This last one boots in UEFI mode when possible, then in Legacy mode if no UEFI files are detected.



!!!!!!!!
Note that in a UEFI-mode installation, Ubuntu will not ask you where to install the boot loader. If it does, or if it complains about the lack of a BIOS Boot Partition, you‘ve probably accidentally booted in BIOS/CSM/legacy mode.





关于 ubuntu 的分区模式
NONE-GPT & GPT 分区

https://help.ubuntu.com/community/DiskSpace


Required partitions

Overview

The easiest partitioning scheme, on a non-GPT disk, is simply a root partition and a swap partition. 

Name

Size

swap

size of RAM

/

the rest of the disk

If the disk is GPT type (this can be checked via the "sudo parted -l" command), you must also add a BIOS-Boot or an EFI partition depending on the boot mode of your BIOS.

Name

Size

BIOS-boot or EFI

see below

swap

size of RAM

/

the rest of the disk

On some computers, a separate /boot partition may also be required.

See paragraphs below.

Root partition (always required)

  • Mount point: /
  • Type: Linux type (generally EXT4)
  • Description: the root partition contains by default all your system files, program settings and documents.
  • Size: minimum is 8 GB. It is recommended to make it at least 15 GB. Warning: your system will be blocked if the root partition is full.

Swap (very recommended)

  • Mount point: none
  • Type: SWAP
  • Description: see SwapFaq.

  • Size: size of your RAM.

BIOS-Boot or EFI partition (required on GPT disks)

If you want to install Ubuntu on a GPT disk (you can check it via the ‘sudo parted -l‘ command), you will need either an EFI partition (if your BIOS is set up in EFI mode) or a BIOS-Boot partition (if your BIOS is set up in Legacy mode).

BIOS-Boot partition:

  • Mount point: none
  • Type: no filesystem
  • Description: the BIOS-boot partition contains GRUB 2‘s core. It is necessary if you install Ubuntu on a GPT disk, and if the firmware (BIOS) is set up in Legacy (not EFI) mode. It must be located at the start of a GPT disk, and have a "bios_grub" flag.
  • Size: 1MB.

EFI partition:

  • Mount point: /boot/efi (no need to set up this mount point as the installer will do it automatically)
  • Type: FAT (generally FAT32)
  • Description: the EFI partition (also called ESP) contains some boot files. It is necessary if the firmware (BIOS) is set up to boot the HDD in EFI mode (which is default on more and more modern, > year 2011 computers). It must be located at the start of a GPT disk, and have a "boot" flag.

  • Size: 100~250MB





https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface
https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface#UEFI_booting

https://en.wikipedia.org/wiki/EFI_system_partition
The EFI System partition needs to be formatted with a file system whose specification is maintained as part of the UEFI specification; the file system itself is based on the FAT file system but is independent from the original FAT specification.[1] The globally unique identifier (GUID) for the EFI System partition in the GUID Partition Table (GPT) scheme is C12A7328-F81F-11D2-BA4B-00A0C93EC93B, while its ID in the MBR partition table scheme is 0xEF.Both GPT- and MBR-partitioned disks can contain an EFI System partition, as UEFI firmware is required to support both partitioning schemes. Also, El Torito bootable format for CD-ROMs and DVDs is supported.[3]

UEFI provides backward compatibility with legacy systems by reserving the first block (sector) of the partition for compatibility code, effectively creating a legacy boot sector. On legacy BIOS-based systems, the first sector of a partition is loaded into memory and execution is transferred to this code. UEFI firmware does not execute the code in the Master Boot Record (MBR), except when booting in legacy BIOS mode through the Compatibility Support Module (CSM).[3]

The UEFI specification requires MBR partition tables to be fully supported.[3] However, some UEFI implementations immediately switch to the BIOS-based CSM booting upon detecting certain types of partition table on the boot disk, effectively preventing UEFI booting to be performed from EFI System partitions contained on MBR-partitioned disks.[4]

UEFI firmware supports booting from removable storage devices such as USB flash drives. For that purpose, a removable device needs to be formatted with a FAT12FAT16 or FAT32 file system, while a boot loader needs to be stored according to the standard ESP file hierarchy, or by providing a complete path of a boot loader to the system‘s boot manager.[3]



https://wiki.archlinux.org/index.php/Boot_loaders

Both BIOS and UEFI boot loaders

GRUB

GRUB is more feature-rich and supports more complex scenarios. Its configuration file(s) is more similar to ‘sh‘ scripting language, and can be automatically generated.

Syslinux

Syslinux is (currently) limited to loading only files from the partition where it was installed. An example configuration can be found in Syslinux#Examples.

UEFI-only boot loaders

Linux Kernel EFISTUB

The Linux kernel can be booted directly using the built-in EFI stub loader. See EFISTUB.

systemd-boot

systemd includes an EFI bootloader which provides a text menu for booting EFISTUB kernels. See systemd-boot.

rEFInd

rEFInd is a UEFI Boot Manager which provides a graphical menu for booting EFISTUB kernels. See rEFInd.

Clover

Clover is a UEFI Boot Manager which provides native resolution GUI for booting EFISTUB kernels. See Clover.

ELILO

Warning: ELILO upstream has clarified that it is no longer in active development, meaning no new features will be added and only bug-fixes are released. Seehttps://sourceforge.net/mailarchive/message.php?msg_id=31524008 for more information. ELILO is not officially supported by Arch developers.

ELILO is the UEFI version of the BIOS-only LILO. Its config file elilo.conf is similar to LILO‘s config file. Upstream provided compiled binaries are available athttp://sourceforge.net/projects/elilo/ and an AUR package at elilo-efiAUR.

BIOS-only boot loaders

Warning: None of the options presented here are officialy supported in Arch Linux.

GRUB Legacy

GRUB Legacy (also known as grub-0.97), is the legacy, BIOS-only branch of GRUB. See GRUB Legacy.

LILO

See LILO.




https://wiki.archlinux.org/index.php/GUID_Partition_Table#Bootloader_Support

Bootloader Support

UEFI systems

All UEFI Bootloaders support GPT disks since GPT is a part of UEFI Specification and thus mandatory for UEFI boot. See Boot loaders for more information.

BIOS systems

While GPT support on BIOS systems is theoretically possible it sometimes isn‘t practical and other times there are complete incompatibilities. Technically the BIOS is only supposed to execute the code on the MBR, therefore leaving the possibility of differing partitioning schemes... However a BIOS may do additional checks including: checking a MBR‘s integrity, and possibly even for a MBR partition table (though usually only the first partition). If this is a case, a number of workarounds exist that may be able to repair the problem (listed below).

Warning: For Windows, there is no support for booting from a BIOS/GPT partitioning scheme. If you have already installed Windows with a BIOS/MBR partitioning scheme do not convert the drive to GPT! Windows will fail to boot if this is done - irrespective of the bootloader used to chainload Windows. One can either install Windows in UEFI mode and use an UEFI bootloader (which uses GPT), or possibly restore/install Windows on a BIOS/GPT hybrid MBR (see partitioning examples).

Bootloaders that support GPT/BIOS partitioning scheme bootloading:

Not suported: GRUB Legacy and LILO.

Workarounds

A few workarounds may help boot a BIOS/GPT partitioning scheme; however, before trying these, try booting a BIOS/GPT partitioning scheme with the bootloaders standard procedure. If it doesn‘t work, these may help boot them (read this for full reference):

  • Set the boot flag on the protective MBR partition (type 0xEE) . This can be done with parted /dev/sdX and disk_toggle pmbr_boot or using sgdisk /dev/sdX --attributes=1:set:2.
  • Be sure there is no EFI system partition
  • Create a hybrid MBR. This will be needed for a BIOS that looks for a valid MBR partition (see example below).
  • Recompute CHS (Cylinder/Head/Sector) values in the protective MBR. GPT does not use these values but the protective MBR may need to be calibrated to them to work for those BIOS that test them.
  • A second disk that has a valid MBR table may signify to the BIOS that it is alright to execute the code on the protective MBR.
  • Many computers since 2011 may have support for an EFI booting if wanting from a BIOS option.





我的安装情况
第一块硬盘安装了 windows
第二块盘 准备用来装 linux

创建了 可启动的 ubuntu  usb livecd    用的镜像是ubuntu-14.04.4-desktop-amd64.iso

开机
技术分享

以前 如果需要从 usb 引导 来安装系统,需要进入bios修改 系统启动介质的顺序,但是这次很奇怪。插上u盘重启后 直接 进入 u盘的  系统里面了

技术分享



技术分享



如果选 ERASE+ LVM  然后硬盘 选择 sdb - > install now,  进入界面

技术分享


--
如果 installation type 不选择 lvm 的话


技术分享



都会默认生成一个  EFIBOOT 盘

-----------------------------
 如果
installation type  选something else  则会进入 分区详情


技术分享


按照以前装双系统的经验是,会在  sdb 创建 root分区  /   ext4  以及  swap 分区
然后 boot loader device,  如果  选 sda, 那么 就会把 grub 装到 磁盘一, 然后启动时,可以从启动菜单选择 进入linux(默认)或者windows
如果boot loader device 选 sdb 的话, 那么默认 linux 就启动不了, 需要在 bios 把 磁盘二 的启动顺序调到 前面 ,才可以 启动linux,启动菜单里也没有windows。此时  windows 和 linux 的启动 是完全独立的

=====
但是 因为这个机器的主板好像是 支持 efi 的,我选择 了 默认的 非 lvm 安装方式后,系统就开始 自己安装,
按照自动安装模式下上图系统提示的 sdb 分区信息可以看出,自动都建立了一个 EFIboot 分区,这个就是 EFI 模式下bootloader 安装的地方???所以上文
https://help.ubuntu.com/community/UEFI#Performing_the_Installation  里面说,在 EFI模式安装 是 不会问在哪里装bootloader 的,因为只能安装在 EFI 分区里?


安装完成后,我就重启机器,很奇怪,开机画面之后 系统马上就进入 ubuntu 了,试图用 fdisk 查看分区表, 结过 sdb 的分区 看不了?  说是用了 gpt分区,只能用 parted 工具 来 查看,这才知道 这次的分区 格式 竟然也和以前不一样了。


--- 那么怎么进入 windows呢?  
我现在使用的办法是, 一闪而过的 开机节目 里 最下排 有提示
DEL  bios setup
f9 system  information
f12  boot menu

我按住 f12  然后会出现硬盘的列表,选择装了windows 的 盘一 ,就会顺利进入 windows

问题是 :
为什么 默认 会  进入 ubuntu 而不是 windows 呢, 这跟 efi 又有什么关系呢
好像 这个 efi 也可以配置成  enabled  或者 是  使用 legacy ?






下面就开始 到处搜索  关于 EFI  还有 GPT 的相关知识



===============
似乎 windows 8 以后 的windows 才会  出现 用 efi 引导的方式 来安装 ?



http://blog.163.com/kongxiangshi@126/blog/static/3571595020146192136557/
这个 是  单硬盘 win 7  安装 双系统 ubuntu
但是需要 将  uefi 设置成 legacy only, 那样的话 就变成  跟传统 用 MBR 分区表建立分区 然后通过 bios 启动的 过程是一样的了 
否则 安装的时候  ubuntu 就识别不出  windows下已经 通过 mbr 建立的分区 ???  奇怪 我安装的时候倒是可以 看到 windows 的分区的。
不过没有尝试  如果  不建立 EFIBOOT 分区 的话 能不能安成功




参考
http://os.51cto.com/art/201405/439158.htm

给了一个 详细的例子 不过是 一块硬盘  而且是 windows 8  + ubuntu 14
安装完后 还需要 在 ubuntu 和 windows 都进行 启动修复  才可以出现 多选项的启动菜单 否则直接进入 windows




支持 efi 的主板 双系统安装 ubuntu - 学习 EFI 和 gpt

标签:

原文地址:http://blog.csdn.net/icycolawater/article/details/51242999

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!