当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 4 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : 请教个grub2的问题
帖子发表于 : 2015-11-19 15:03 

注册: 2010-02-12 19:47
帖子: 68
送出感谢: 19
接收感谢: 0 次
grub2命令引导linux

grub>set root=(hd0,7) #为什么在这是root=hd,到第二行就成了root=sd,grub2里不是不区分IDE和SATA,都用hd么?
grub>linux /boot/vmlinuz-xxx-xxx root=/dev/sda7
grub>initrd /boot/initrd.img-xxx-xxx
grub>boot


还有,第一行和第二行指定root分区有什么区别

谢谢


页首
 用户资料  
 
2 楼 
 文章标题 : Re: 请教个grub2的问题
帖子发表于 : 2015-11-19 15:08 
头像

注册: 2011-03-20 13:12
帖子: 4519
地址: 山东省寿光县
系统: Debian
送出感谢: 105
接收感谢: 997
引用:
为什么在这是root=hd,到第二行就成了root=sd
第一行和第二行指定root分区有什么区别

第一行是 GRUB2 的根文件系统,第二行是 Linux 的根文件系统
对于 GRUB2 的根文件系统,GRUB2 有自己的命名规则
参见 https://www.gnu.org/software/grub/manual/html_node/Naming-convention.html
这里的 (hd0,msdos1) 与 /dev/hdX 意义不同

值得注意的是,根文件系统未被挂载时 /dev 目录下大多数设备是不存在的。因此这里的 root=/dev/sda4 与系统启动后的 /dev/sda4 设备文件意义不同,仅仅是帮助内核寻找根文件系统的符号。
因此 Linux 的根文件系统也可不用 /dev/sdX 指定:
代码:
linux   /boot/vmlinuz-4.2.0-1-amd64 root=UUID=4a5g55b9-6dy7-4t73-acr8-y9b9a06fgf4h ro splash acpi_backlight=vendor resume=/dev/sda4

psusi 写道:
While the argument looks like a normal device node in the /dev directory, there obviously is no /dev directory before the root fs is mounted, so the kernel can not look up a dev node there. Instead, certain well known device names are hard coded into the kernel so the string can be translated to the device number. Because of this, the kernel can recognize things like /dev/sda1, but not more exotic things like /dev/mapper/vg0-root or a volume UUID.


GRUB2 的根文件系统 和 Linux 的根文件系统 意义不同:
引用:
The use of the term root file system has a different meaning in regard to GRUB. It is important to remember that GRUB's root file system has nothing to do with the Linux root file system.
1.
The GRUB root file system is the top level of the specified device. For example, the image file (hd0,0)/grub/splash.xpm.gz is located within the /grub/ directory at the top-level (or root) of the (hd0,0) partition (which is actually the /boot/ partition for the system).
2.
Next, the kernel command is executed with the location of the kernel file as an option. Once the Linux kernel boots, it sets up the root file system that Linux users are familiar with. The original GRUB root file system and its mounts are forgotten; they only existed to boot the kernel file.

引用:
Note that GRUB's root device doesn't necessarily mean your OS's root partition; if you need to specify a root partition for your OS, add the argument into the command kernel.


参考
https://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-grub-terminology.html
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/3/html/Reference_Guide/s1-grub-commands.html
http://www.dedoimedo.com/computers/grub-2.html
http://www.gnu.org/software/grub/manual/grub.html
https://www.gnu.org/software/grub/manual/html_node/GNU_002fLinux.html
http://unix.stackexchange.com/a/18055
http://unix.stackexchange.com/a/111242
https://www.gnu.org/software/grub/manual/legacy/Installing-GRUB-natively.html#fn-1


_________________
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户


最后由 vickycq 编辑于 2015-11-20 12:43,总共编辑了 1 次


_________________
评价: 3.7% sluding
 
页首
 用户资料  
 
3 楼 
 文章标题 : Re: 请教个grub2的问题
帖子发表于 : 2015-11-19 16:57 

注册: 2010-02-12 19:47
帖子: 68
送出感谢: 19
接收感谢: 0 次
是不是在 set root这一行,如果设置对了,下面一行 linux /boot/vm (tab)就会自动补上核心名称,如果set root 不对,不会自动补上。

set root 设完了,在下面一行的 root=/dev/sda7中,ls /dev 看了下,没有sda7,正常么?


页首
 用户资料  
 
4 楼 
 文章标题 : Re: 请教个grub2的问题
帖子发表于 : 2015-11-19 19:39 
头像

注册: 2011-03-20 13:12
帖子: 4519
地址: 山东省寿光县
系统: Debian
送出感谢: 105
接收感谢: 997
sluding 写道:
是不是在 set root这一行,如果设置对了,下面一行 linux /boot/vm (tab)就会自动补上核心名称,如果set root 不对,不会自动补上。
set root 设完了,在下面一行的 root=/dev/sda7中,ls /dev 看了下,没有sda7,正常么?


1. 是的。GRUB 根分区设置为包含 /boot 的分区。
2. 正常。是在 GRUB 命令行里 ls /dev 么? /dev 下多数设备在操作系统启动过程中由 devtmpfs 加载。包含根文件系统的设备 (/dev/sda7) 由 initramfs 加载。

参考
http://unix.stackexchange.com/questions/43700/does-init-or-linuxrc-script-creates-temporary-device-nodes-in-dev
http://unix.stackexchange.com/questions/52713/building-my-own-initrd-how-to-populate-dev-directory
https://wiki.gentoo.org/wiki/Custom_Initramfs#Device_nodes
https://wiki.gentoo.org/wiki/Custom_Initramfs#Dynamic_devices


_________________
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户



_________________
评价: 3.7% sluding
 
页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 4 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:Exabot [Bot] 和 1 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译