mirror of
https://github.com/beyondx/Notes.git
synced 2026-11-29 07:15:54 +08:00
Add New Notes
This commit is contained in:
369
Zim/Linux/dig_to_linux/Grub.txt
Normal file
369
Zim/Linux/dig_to_linux/Grub.txt
Normal file
@@ -0,0 +1,369 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2011-03-27T19:38:28+08:00
|
||||
|
||||
====== Grub ======
|
||||
Created Sunday 27 March 2011
|
||||
|
||||
Author:geekard (geekard@gmail.com)
|
||||
Update: 2010.7.31
|
||||
Version : 1.2
|
||||
|
||||
**1.查看系统安装的相关软件包**
|
||||
geekard@geekard-laptop:~$ dpkg -l grub*
|
||||
Desired=Unknown/Install/Remove/Purge/Hold
|
||||
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|
||||
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
|
||||
||/ Name Version Description
|
||||
+++-=================================-=================================-==================================================================================
|
||||
un grub <none> (no description available)
|
||||
ii grub-common 1.98-1ubuntu6 GRand Unified Bootloader, version 2 (common files)
|
||||
un grub-coreboot <none> (no description available)
|
||||
un grub-doc <none> (no description available)
|
||||
un grub-efi <none> (no description available)
|
||||
un grub-efi-amd64 <none> (no description available)
|
||||
un grub-efi-ia32 <none> (no description available)
|
||||
un grub-emu <none> (no description available)
|
||||
un grub-ieee1275 <none> (no description available)
|
||||
un grub-legacy <none> (no description available)
|
||||
un grub-legacy-doc <none> (no description available)
|
||||
un grub-linuxbios <none> (no description available)
|
||||
ii grub-pc 1.98-1ubuntu6 GRand Unified Bootloader, version 2 (PC/BIOS version)
|
||||
un grub2 <none> (no description available)
|
||||
**2、查看安装的软件包信息**
|
||||
geekard@geekard-laptop:~$ dpkg -s grub-common
|
||||
Package: grub-common
|
||||
Status: install ok installed
|
||||
Priority: optional
|
||||
Section: admin
|
||||
Installed-Size: 4220
|
||||
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
|
||||
Architecture: i386
|
||||
Source: grub2
|
||||
Version: 1.98-1ubuntu6
|
||||
Replaces: grub-coreboot (<< 1.97+20091114-1), grub-efi (<< 1.96+20080831-1), grub-ieee1275 (<< 1.96+20080831-1), grub-linuxbios (<< 1.96+20080831-1), grub-pc (<< 1.97+20091114-1)
|
||||
Depends: base-files (>= 4.0.1~), dpkg (>= 1.15.4) | install-info | dpkg (<= 1.14.25), lsb-base (>= 3.0-6), libc6 (>= 2.8), libdevmapper1.02.1 (>= 2:1.02.20), libfreetype6 (>= 2.2.1), zlib1g (>= 1:1.1.4), gettext-base
|
||||
Recommends: os-prober (>= 1.33)
|
||||
Suggests: multiboot-doc, grub-emu
|
||||
Conflicts: grub-doc (<< 0.97-29ubuntu60), grub-legacy-doc (<< 0.97-29ubuntu60), mdadm (<< 2.6.7-2)
|
||||
Conffiles:
|
||||
/etc/pm/sleep.d/10_grub-common bc63b0c6613e95979446d17a88875d6a
|
||||
/etc/grub.d/00_header db2fbce0c4b11001e4fbdb23aee57647
|
||||
/etc/grub.d/30_os-prober 235cb43f280c29557f0f24a1e8163457
|
||||
/etc/grub.d/40_custom babe7de352fe18de5a238569cf4b8a11
|
||||
/etc/grub.d/10_linux 937e21c78def99a9cf22d2c95280ef88
|
||||
/etc/grub.d/README be58f42dfe74feb6eeb98c6a843c743f
|
||||
/etc/init.d/grub-common f5078cf9df66751dec9ae8f7baf4a0c2
|
||||
Description: GRand Unified Bootloader, version 2 (common files)
|
||||
This package contains common files shared by the distinct flavours of GRUB.
|
||||
Homepage: http://www.gnu.org/software/grub/grub-2.en.html
|
||||
Original-Maintainer: GRUB Maintainers <pkg-grub-devel@lists.alioth.debian.org>
|
||||
|
||||
geekard@geekard-laptop:~$ dpkg -s grub-pc
|
||||
Package: grub-pc
|
||||
Status: install ok installed
|
||||
Priority: optional
|
||||
Section: admin
|
||||
Installed-Size: 2228
|
||||
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
|
||||
Architecture: i386
|
||||
Source: grub2
|
||||
Version: 1.98-1ubuntu6
|
||||
Replaces: grub, grub-common (<< 1.97~beta1-1ubuntu4), grub-coreboot, grub-efi-amd64, grub-efi-ia32, grub-ieee1275, grub-legacy, grub2 (<< 1.98-1ubuntu6)
|
||||
Depends: libc6 (>= 2.8), libdevmapper1.02.1 (>= 2:1.02.20), debconf (>= 0.5) | debconf-2.0, grub-common (= 1.98-1ubuntu6), ucf
|
||||
Suggests: desktop-base (>= 4.0.6)
|
||||
Conflicts: desktop-base (= 4.0.5), grub (<< 0.97-54), grub-coreboot, grub-efi-amd64, grub-efi-ia32, grub-ieee1275, grub-legacy
|
||||
Conffiles:
|
||||
/etc/grub.d/05_debian_theme cceb548bef9d5c2123c40c5e643c2cdd
|
||||
Description: GRand Unified Bootloader, version 2 (PC/BIOS version)
|
||||
GRUB is a portable, powerful bootloader. This version of GRUB is based on a
|
||||
cleaner design than its predecessors, and provides the following new features:
|
||||
.
|
||||
- Scripting in grub.cfg using BASH-like syntax.
|
||||
- Support for modern partition maps such as GPT.
|
||||
- Modular generation of grub.cfg via update-grub. Packages providing GRUB
|
||||
add-ons can plug in their own script rules and trigger updates by invoking
|
||||
update-grub2.
|
||||
- VESA-based graphical mode with background image support and complete 24-bit
|
||||
color set.
|
||||
- Support for extended charsets. Users can write UTF-8 text to their menu
|
||||
entries.
|
||||
.
|
||||
This package contains a version of GRUB that has been built for use with
|
||||
traditional PC/BIOS architecture.
|
||||
Homepage: http://www.gnu.org/software/grub/grub-2.en.html
|
||||
Original-Maintainer: GRUB Maintainers <pkg-grub-devel@lists.alioth.debian.org
|
||||
**3.查看安装的文件**
|
||||
geekard@geekard-laptop:~$ dpkg -L grub-common
|
||||
/.
|
||||
/usr
|
||||
/usr/sbin
|
||||
/usr/sbin/grub-mkdevicemap
|
||||
/usr/sbin/grub-probe
|
||||
/usr/sbin/grub-mkconfig
|
||||
/usr/lib
|
||||
/usr/lib/grub
|
||||
/usr/lib/grub/grub-mkconfig_lib
|
||||
/usr/lib/grub/update-grub_lib
|
||||
/usr/share
|
||||
/usr/share/grub
|
||||
/usr/share/grub/unicode.pf2
|
||||
/usr/share/grub/ascii.pf2
|
||||
/usr/share/grub/ascii.h
|
||||
/usr/share/man
|
||||
/usr/share/man/man1
|
||||
/usr/share/man/man1/grub-mkisofs.1.gz
|
||||
/usr/share/man/man1/grub-mkfont.1.gz
|
||||
/usr/share/man/man1/grub-mkrelpath.1.gz
|
||||
/usr/share/man/man1/grub-bin2h.1.gz
|
||||
/usr/share/man/man1/grub-script-check.1.gz
|
||||
/usr/share/man/man1/grub-editenv.1.gz
|
||||
/usr/share/man/man1/grub-mkrescue.1.gz
|
||||
/usr/share/man/man1/grub-mkelfimage.1.gz
|
||||
/usr/share/man/man1/grub-mkpasswd-pbkdf2.1.gz
|
||||
/usr/share/man/man8
|
||||
/usr/share/man/man8/grub-probe.8.gz
|
||||
/usr/share/man/man8/grub-mkconfig.8.gz
|
||||
/usr/share/man/man8/grub-mkdevicemap.8.gz
|
||||
/usr/share/info
|
||||
/usr/share/info/grub.info.gz
|
||||
/usr/share/doc
|
||||
/usr/share/doc/grub-common
|
||||
/usr/share/doc/grub-common/README
|
||||
/usr/share/doc/grub-common/TODO
|
||||
/usr/share/doc/grub-common/AUTHORS
|
||||
/usr/share/doc/grub-common/THANKS
|
||||
/usr/share/doc/grub-common/copyright
|
||||
/usr/share/doc/grub-common/examples
|
||||
/usr/share/doc/grub-common/examples/grub.cfg
|
||||
/usr/share/doc/grub-common/NEWS.Debian.gz
|
||||
/usr/share/doc/grub-common/changelog.gz
|
||||
/usr/share/doc/grub-common/NEWS.gz
|
||||
/usr/share/doc/grub-common/changelog.Debian.gz
|
||||
/usr/share/bug
|
||||
/usr/share/bug/grub-common
|
||||
/usr/share/bug/grub-common/presubj
|
||||
/usr/bin
|
||||
/usr/bin/grub-mkelfimage
|
||||
/usr/bin/grub-mkisofs
|
||||
/usr/bin/grub-mkfont
|
||||
/usr/bin/grub-mkrelpath
|
||||
/usr/bin/grub-bin2h
|
||||
/usr/bin/grub-script-check
|
||||
/usr/bin/grub-editenv
|
||||
/usr/bin/grub-mkpasswd-pbkdf2
|
||||
/usr/bin/grub-mkrescue
|
||||
/etc
|
||||
/etc/pm
|
||||
/etc/pm/sleep.d
|
||||
/etc/pm/sleep.d/10_grub-common
|
||||
/etc/grub.d
|
||||
/etc/grub.d/00_header
|
||||
/etc/grub.d/30_os-prober
|
||||
/etc/grub.d/40_custom
|
||||
/etc/grub.d/10_linux
|
||||
/etc/grub.d/README
|
||||
/etc/init.d
|
||||
/etc/init.d/grub-common
|
||||
|
||||
geekard@geekard-laptop:~$ dpkg -L grub-pc
|
||||
/.
|
||||
/usr
|
||||
/usr/lib
|
||||
/usr/lib/grub
|
||||
/usr/lib/grub/i386-pc
|
||||
/usr/lib/grub/i386-pc/boot.img
|
||||
/usr/lib/grub/i386-pc/cdboot.img
|
||||
/usr/lib/grub/i386-pc/diskboot.img
|
||||
/usr/lib/grub/i386-pc/kernel.img
|
||||
/usr/lib/grub/i386-pc/lnxboot.img
|
||||
/usr/lib/grub/i386-pc/pxeboot.img
|
||||
......
|
||||
/usr/lib/grub/i386-pc/grub_script.tab.h
|
||||
/usr/lib/grub-legacy
|
||||
/usr/lib/grub-legacy/update-grub
|
||||
/usr/share
|
||||
/usr/share/doc
|
||||
/usr/share/doc/grub-pc
|
||||
/usr/share/doc/grub-pc/copyright
|
||||
/usr/share/doc/grub-pc/examples
|
||||
/usr/share/man
|
||||
/usr/share/man/man1
|
||||
/usr/share/man/man1/grub-mkimage.1.gz
|
||||
/usr/share/man/man8
|
||||
/usr/share/man/man8/update-grub2.8.gz
|
||||
/usr/share/man/man8/grub-install.8.gz
|
||||
/usr/share/man/man8/grub-set-default.8.gz
|
||||
/usr/share/man/man8/grub-setup.8.gz
|
||||
/usr/share/man/man8/grub-reboot.8.gz
|
||||
/usr/share/man/man8/update-grub.8.gz
|
||||
/usr/share/lintian
|
||||
/usr/share/lintian/overrides
|
||||
/usr/share/lintian/overrides/grub-pc
|
||||
/usr/share/bug
|
||||
/usr/share/bug/grub-pc
|
||||
/usr/share/bug/grub-pc/presubj
|
||||
/usr/share/bug/grub-pc/script
|
||||
/usr/share/grub
|
||||
/usr/share/grub/default
|
||||
/usr/share/grub/default/grub.md5sum
|
||||
/usr/share/grub/default/grub
|
||||
/usr/bin
|
||||
/usr/bin/grub-mkimage
|
||||
/usr/sbin
|
||||
/usr/sbin/grub-setup
|
||||
/usr/sbin/update-grub2
|
||||
/usr/sbin/update-grub
|
||||
/usr/sbin/grub-install
|
||||
/usr/sbin/grub-set-default
|
||||
/usr/sbin/grub-reboot
|
||||
/usr/sbin/upgrade-from-grub-legacy
|
||||
/etc
|
||||
/etc/grub.d
|
||||
/etc/grub.d/05_debian_theme
|
||||
/usr/share/doc/grub-pc/README
|
||||
/usr/share/doc/grub-pc/TODO
|
||||
/usr/share/doc/grub-pc/AUTHORS
|
||||
/usr/share/doc/grub-pc/THANKS
|
||||
/usr/share/doc/grub-pc/examples/grub.cfg
|
||||
/usr/share/doc/grub-pc/NEWS.Debian.gz
|
||||
/usr/share/doc/grub-pc/changelog.gz
|
||||
/usr/share/doc/grub-pc/NEWS.gz
|
||||
/usr/share/doc/grub-pc/changelog.Debian.gz
|
||||
**4、/boot/grub目录中的文件**
|
||||
|
||||
*.mod 为驱动模块
|
||||
command.lst grub命令
|
||||
fs.lst grub支持的文件系统
|
||||
handler.lst grub命令运行环境:sh
|
||||
moddep.lst 模块间的依赖关系
|
||||
grub.conf grub配置文件
|
||||
|
||||
此目录中的文件相当于stage2(引导扇区记录着该目录的位置),若开机时GRUB不能读取该目录,则会提示:grub rescue >
|
||||
这时只能重新安装GRUB。若能读取该目录但配置文件丢失时,会显示GRUB SHELL 可以手动指定相关文件位置。
|
||||
|
||||
**5、grub.conf 解析**
|
||||
grub.conf 是由/usr/sbin/grub-mkconfig using templates from /etc/grub.d and settings from /etc/default/grub 生成的。当然也可以手动编辑。
|
||||
#
|
||||
# DO NOT EDIT THIS FILE
|
||||
#
|
||||
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
|
||||
# from /etc/grub.d and settings from /etc/default/grub
|
||||
#
|
||||
其中/etc/grub.d 目录中存放的是一些编号的脚本文件,用以产生grub.conf的内容,you can add an entry to boot another OS as 01_otheros, 11_otheros, etc, depending on the position you want it to occupy in the menu; and then adjust the default setting via /etc/default/grub.而 /etc/default/grub控制grub的设置。If you change /etc/default/grub, run 'update-grub' afterwards to update /boot/grub/grub.cfg. 也可以用 /usr/sbin/grub-mkconfig 。
|
||||
/etc/grub.d/目录中的文件有:
|
||||
00_header 10_linux 30_os-prober 05_debian_theme 20_memtest86+ 40_custom
|
||||
其中00_header 30_os-prober 05_debian_theme 是安装系统时自动生成的设置脚本可有可无。
|
||||
10_linux记录了安装的系统,用户可以在40_custom 中添加自己要指定的系统具体格式可以参考:
|
||||
/usr/shard/doc/grub-common/example/grub.conf 的示例:
|
||||
#
|
||||
# Sample GRUB configuration file
|
||||
#
|
||||
|
||||
# Boot automatically after 30 secs.
|
||||
set timeout=30
|
||||
|
||||
# By default, boot the first entry.
|
||||
set default=0
|
||||
|
||||
# Fallback to the second entry.
|
||||
set fallback=1
|
||||
|
||||
# For booting GNU/Linux
|
||||
menuentry "GNU/Linux" {
|
||||
set root=(hd0,1)
|
||||
linux /vmlinuz root=/dev/sda1
|
||||
initrd /initrd.img
|
||||
}
|
||||
|
||||
# For booting Microsoft Windows
|
||||
menuentry "Microsoft Windows" {
|
||||
set root=(hd0,1)
|
||||
chainloader +1
|
||||
}
|
||||
|
||||
# For booting Memtest86+
|
||||
menuentry "Memtest86+" {
|
||||
set root=(hd0,1)
|
||||
linux16 /memtest86+.bin
|
||||
}
|
||||
|
||||
# Change the colors.
|
||||
menuentry "Change the colors" {
|
||||
set menu_color_normal=light-green/brown
|
||||
set menu_color_highlight=red/blue
|
||||
}
|
||||
注意:linux 命令行参数中的root=/dev/[sh]d[a-z][0-9]的形式是不变的,=/间不能有空格,因为这个参数这是传给kernel的参数,此时的设备文件其实是由initrd提供的。根目录是内存中由内核产生的rootfs.
|
||||
**6、GRUB的安装**
|
||||
第一步:In order to install GRUB as your boot loader, you need to first install the GRUB system and utilities under your UNIX-like operating system You can do this either from the source tarball, or as a package for your OS.
|
||||
常用的软件包为:grub-pc及grub-common
|
||||
第二步:After you have done that, you need to install the boot loader on a
|
||||
drive (floppy or hard disk). There are two ways of doing that - either using the utility `grub-install' (*note Invoking grub-install::) on a UNIX-like OS, or by running GRUB itself from a floppy. These are quite similar, however the utility might probe a wrong BIOS drive, so you should be careful.
|
||||
警告:most operating systems don't tell GRUB how to map BIOS drives to OS devices correctly--GRUB merely "guesses" the mapping. This will succeed in most cases, but not always. Therefore, GRUB provides you with a map file called the "device map", which you must fix if it is wrong. If the output is wrong, it is unlikely that your computer will be able to boot with no problem.
|
||||
device.map位于/boot/grub/,内容为BIOS drives 与 OS devices的对应关系:
|
||||
如:(hd0) /dev/sda
|
||||
geekard@geekard-laptop:~$ grub-install --help
|
||||
Usage: grub-install [OPTION] install_device
|
||||
Install GRUB on your drive.
|
||||
|
||||
-h, --help print this message and exit
|
||||
-v, --version print the version information and exit
|
||||
--modules=MODULES pre-load specified modules MODULES
|
||||
--root-directory=DIR install GRUB images under the directory DIR instead of the root directory
|
||||
grub 在DIR目录下建立boot/grub/*目录和文件(这些文件来自安装GRUB套件时产生的文件 /usr/lib/grub/i386-pc),但不会生成grub.cfg 文件,可用grub-mkconfig 命令生成这个文件,也可以手动编辑。默认的root-directory为根目录。在用rescue mode 没有chroot安装grub时常用这个选项。
|
||||
--grub-setup=FILE use FILE as grub-setup
|
||||
--grub-mkimage=FILE use FILE as grub-mkimage
|
||||
--grub-probe=FILE use FILE as grub-probe
|
||||
--no-floppy do not probe any floppy drive
|
||||
--recheck Recheck the device map, even if `/boot/grub/device.map' already exists.
|
||||
--force install even if problems are detected
|
||||
--disk-module=MODULE disk module to use
|
||||
|
||||
INSTALL_DEVICE can be a GRUB device name or a system device filename.
|
||||
system device filename : /dev/sda 或/dev/sda* 等
|
||||
GRUB device name : '(hd0,1)'等
|
||||
|
||||
|
||||
grub-install copies GRUB images into /boot/grub (or /grub on NetBSD and OpenBSD), and uses grub-setup to install grub into the boot sector. If the --root-directory option is used, then grub-install will copy images into the operating system installation rooted at that directory.
|
||||
**7、当建立单独的/boot分区时,手动安装和配置grub的方法:**
|
||||
# grub-install /dev/sda 默然安装到根目录中,并根据需要建立/boot/grub目录结构。
|
||||
配置方式:
|
||||
menuentry "GNU/Linux" {
|
||||
set root=(hd0,1) 指定含有 vmlinuz、initrd.img 的设备或分区,可以与grub的目录不在一个分区。
|
||||
linux /vmlinuz root=/dev/sda1
|
||||
initrd /initrd.img }
|
||||
因为/dev/sda1 被挂载到/boot目录中故上述的 /vmlinuz 和/initrd.img 的/等价于/boot目录.
|
||||
**8、GRUB的讨论**
|
||||
#grub-install –root-directory=DIR install_device
|
||||
--root-directory 用于指定grub文件安装目录,而install_device用于指定安装的设备,通常为MBR或分区.
|
||||
安装grub时的DIR和install_device可以不在同一个分区,但grub安装完成后,这种对应关系是确定的。也就是说stage1,stage1.5都写入到install_device上了,其中stage1.5中记录了stage2即—root-directory的位置信息,在stage1.5的文件中有这样一个参数:(hd*,*)/DIR/记录了这种对应关系。当DIR被移走或目录名修改如将DIR/boot改为DIR/boot2时,将会出现不能引导并显示grub rescue >,这是因为GRUB不能读取以前安装时定义的DIR/boot/grub中的文件信息(相当于stage2)。但DIR/boot/grub/grub.cfg丢失时,由于可以读去DIR/boot/grub中的文件故会出现grub shell提示符,这时可以手动配置。
|
||||
另外vmlinuz和initrd可位于任何位置,不一定位于DIR/boot中,这体现了GRUB的灵活性,即不管vmlinuz和initrd位于哪儿都可以引导。
|
||||
在grub.cfg文件中root用于指定vmlinuz和initrd所在的分区,这和grub的安装目录无关。
|
||||
**9、GRUB文件和设备的命名**
|
||||
First of all, GRUB requires that the device name be enclosed with `(' and `)'.
|
||||
(hd0,2) Here, `hd' means it is a hard disk drive. The first integer `0' indicates the drive number, that is, the first hard disk, while the second integer, `2', indicates the partition number (or the PC slice number in the BSD terminology).The partition numbers are counted from _one_, not from zero (as was the case in previous versions of GRUB).
|
||||
(hd0,5) This specifies the first "extended partition" of the first hard disk drive. Note that the partition numbers for extended partitions are counted from `5', regardless of the actual number of primary partitions on your hard disk.
|
||||
Of course, to actually access the disks or partitions with GRUB, you need to use the device specification in a command, like `root (fd0)' or `unhide (hd0,3)'. To help you find out which number specifies a partition you want, the GRUB command-line (*note Command-line
|
||||
interface::) options have argument completion. This means that, for example, you only need to type
|
||||
root ( followed by a <TAB>, and GRUB will display the list of drives, partitions, or file names. So it should be quite easy to determine the name of your target partition, even with minimal knowledge of the syntax.
|
||||
Note that GRUB does _not_ distinguish IDE from SCSI - it simply counts the drive numbers from zero, regardless of their type(因此都为hd*而非sd*). Normally, any IDE drive number is less than any SCSI drive number, although that is not true if you change the boot sequence by swapping IDE and SCSI drives in your BIOS.
|
||||
|
||||
Now the question is, how to specify a file? Again, consider an example:
|
||||
(hd0,1)/vmlinuz This specifies the file named `vmlinuz', found on the first partition of the first hard disk drive. Note that the argument completion works with file names, too.
|
||||
If you omit the device name in an absolute file name, GRUB uses GRUB's "root device"
|
||||
implicitly. So if you set the root device to, say, `(hd1,1)' by the command `root' (*note root::), then `/boot/kernel' is the same as `(hd1,1)/boot/kernel'. 也就是说在用绝对路径指定文件时若路径最前面没有device,则GRUB就默认由root device 指定的device,如root (hd0,2).但像root=/dev/sda1,由于绝对路径和=号之间没有空格,故没有这种关系。实际上linux命令行上的root参数一直是root=/dev/[sh]d[a-z][0-9]的格式,并不用在/dev前加空格和指定设备分区,因为这是传给kernel的参数,此时的设备文件其实是由initrd提供的。根目录是内存中由内核产生的rootfs.
|
||||
**10、常用GRUB命令**
|
||||
geekard@geekard-laptop:~$ grub-
|
||||
grub-mkdevicemap 生成device.map文件
|
||||
grub-probe 获取给定路径或设备的信息如fs|fs_uuid|drive|device|partmap|abstraction
|
||||
|
||||
grub-setup 将grub写入boot sector
|
||||
grub-install 安装grub到指定设备和目录,调用grub-setup
|
||||
|
||||
grub-script-check 检查/etc/grub.d目录中脚本的正确性
|
||||
grub-mkconfig 根据/etc/grub.d和/etc/defaults/grub中的文件生成配置文件
|
||||
|
||||
grub-set-default 设置default的 menuentry
|
||||
grub-reboot 设置下次启动时的menuentry
|
||||
|
||||
grub-mkrescue 生成rescue盘
|
||||
16
Zim/Linux/dig_to_linux/Grub/Grub-info/1.1_Overview.txt
Normal file
16
Zim/Linux/dig_to_linux/Grub/Grub-info/1.1_Overview.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2010-08-03T21:26:51.232285
|
||||
|
||||
====== 1.1 Overview ======
|
||||
Created Tuesday 03 August 2010
|
||||
|
||||
Briefly, a "boot loader" is the first software program that runs when a computer starts. It is responsible for loading and transferring control to an operating system "kernel" software (such as Linux or GNU Mach). The kernel, in turn, initializes the rest of the operating system (e.g. a GNU system).
|
||||
|
||||
GNU GRUB is a very powerful boot loader, which can load a wide variety of free operating systems, as well as proprietary operating systems with chain-loading(1) (*note Overview-Footnote-1::). GRUB is designed to address the complexity of booting a personal computer; both the program and this manual are tightly bound to that computer platform,although porting to other platforms may be addressed in the future.
|
||||
|
||||
One of the important features in GRUB is flexibility; GRUB understands filesystems and kernel executable formats, so you can load an arbitrary operating system the way you like, without recording the physical position of your kernel on the disk. Thus you can load the kernel just by specifying its file name and the drive and partition where the kernel resides.
|
||||
|
||||
When booting with GRUB, you can use either a command-line interface (*note Command-line interface::), or a menu interface (*note Menu
|
||||
interface::). Using the command-line interface, you type the drive specification and file name of the kernel manually. In the menu interface, you just select an OS using the arrow keys. The menu is based on a configuration file which you prepare beforehand (*note Configuration::). While in the menu, you can switch to the command-line mode, and vice-versa. You can even edit menu entries before using them.
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2010-08-03T21:28:21.577655
|
||||
|
||||
====== 1.2 History of GRUB ======
|
||||
Created Tuesday 03 August 2010
|
||||
|
||||
GRUB originated in 1995 when Erich Boleyn was trying to boot the GNU Hurd with the University of Utah's Mach 4 microkernel (now known as GNU Mach). Erich and Brian Ford designed the Multiboot Specification(*note Multiboot Specification: (multiboot)Top.), because they were determined not to add to the large number of mutually-incompatible PC
|
||||
boot methods.
|
||||
|
||||
Erich then began modifying the FreeBSD boot loader so that it would understand Multiboot. He soon realized that it would be a lot easier to
|
||||
write his own boot loader from scratch than to keep working on the FreeBSD boot loader, and so GRUB was born.
|
||||
|
||||
Erich added many features to GRUB, but other priorities prevented him from keeping up with the demands of its quickly-expanding user base. In
|
||||
1999, Gordon Matzigkeit and Yoshinori K. Okuji adopted GRUB as an official GNU package, and opened its development by making the latest
|
||||
sources available via anonymous CVS. *Note Obtaining and Building GRUB::, for more information.
|
||||
65
Zim/Linux/dig_to_linux/Grub/Grub-info/1.3_GRUB_features.txt
Normal file
65
Zim/Linux/dig_to_linux/Grub/Grub-info/1.3_GRUB_features.txt
Normal file
@@ -0,0 +1,65 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2010-08-03T21:29:00.363459
|
||||
|
||||
====== 1.3 GRUB features ======
|
||||
Created Tuesday 03 August 2010
|
||||
|
||||
The primary requirement for GRUB is that it be compliant with the "Multiboot Specification", which is described in *note Multiboot Specification: (multiboot)Top.
|
||||
The other goals, listed in approximate order of importance, are:
|
||||
* Basic functions must be straightforward for end-users.
|
||||
* Rich functionality to support kernel experts and designers.
|
||||
* Backward compatibility for booting FreeBSD, NetBSD, OpenBSD, and
|
||||
Linux. Proprietary kernels (such as DOS, Windows NT, and OS/2) are
|
||||
supported via a chain-loading function.
|
||||
|
||||
Except for specific compatibility modes (chain-loading and the Linux "piggyback" format), all kernels will be started in much the same state as in the Multiboot Specification. Only kernels loaded at 1 megabyte or above are presently supported. Any attempt to load below that boundary will simply result in immediate failure and an error message reporting the problem.
|
||||
|
||||
In addition to the requirements above, GRUB has the following features (note that the Multiboot Specification doesn't require all the features that GRUB supports):
|
||||
|
||||
**Recognize multiple executable formats**
|
||||
Support many of the "a.out" variants plus "ELF". Symbol tables are
|
||||
also loaded.
|
||||
|
||||
**Support non-Multiboot kernels**
|
||||
Support many of the various free 32-bit kernels that lack Multiboot compliance (primarily FreeBSD, NetBSD, OpenBSD, and Linux). Chain-loading of other boot loaders is also supported.
|
||||
|
||||
**Load multiples modules**
|
||||
Fully support the Multiboot feature of loading multiple modules.
|
||||
|
||||
**Load a configuration file**
|
||||
Support a human-readable text configuration file with preset boot commands. You can also load another configuration file dynamically and embed a preset configuration file in a GRUB image file. The list of commands (*note Commands::) are a superset of those supported on the command-line. An example configuration file is provided in *note Configuration::.
|
||||
|
||||
**Provide a menu interface**
|
||||
A menu interface listing preset boot commands, with a programmable timeout, is available. There is no fixed limit on the number of boot entries, and the current implementation has space for several hundred.
|
||||
|
||||
**Have a flexible command-line interface**
|
||||
A fairly flexible command-line interface, accessible from the menu, is available to edit any preset commands, or write a new boot command set from scratch. If no configuration file is present, GRUB drops to the command-line.
|
||||
|
||||
The list of commands (*note Commands::) are a subset of those supported for configuration files. Editing commands closely resembles the Bash command-line (*note Bash: (features)Command Line Editing.), with <TAB>-completion of commands, devices, partitions, and files in a directory depending on context.
|
||||
|
||||
**Support multiple filesystem types**
|
||||
Support multiple filesystem types transparently, plus a useful explicit blocklist notation. The currently supported filesystem types are "BSD FFS", "DOS FAT16 and FAT32", "Minix fs", "Linux ext2fs", "ReiserFS", "JFS", "XFS", and "VSTa fs". *Note Filesystem::, for more information.
|
||||
|
||||
**Support automatic decompression**
|
||||
Can decompress files which were compressed by `gzip'. This function is both automatic and transparent to the user (i.e. all functions operate upon the uncompressed contents of the specified files). This greatly reduces a file size and loading time, a particularly great benefit for floppies.(1) (*note Features-Footnote-1::)
|
||||
|
||||
It is conceivable that some kernel modules should be loaded in a compressed state, so a different module-loading command can be specified to avoid uncompressing the modules.
|
||||
|
||||
**Access data on any installed device**
|
||||
Support reading data from any or all floppies or hard disk(s) recognized by the BIOS, independent of the setting of the root device.
|
||||
|
||||
**Be independent of drive geometry translations**
|
||||
Unlike many other boot loaders, GRUB makes the particular drive translation irrelevant. A drive installed and running with one translation may be converted to another translation without any adverse effects or changes in GRUB's configuration.
|
||||
|
||||
**Detect all installed RAM**
|
||||
GRUB can generally find all the installed RAM on a PC-compatible machine. It uses an advanced BIOS query technique for finding all memory regions. As described on the Multiboot Specification (*note Multiboot Specification: (multiboot)Top.), not all kernels make use of this information, but GRUB provides it for those who do.
|
||||
|
||||
**Support Logical Block Address mode**
|
||||
In traditional disk calls (called "CHS mode"), there is a geometry translation problem, that is, the BIOS cannot access over 1024 cylinders, so the accessible space is limited to at least 508 MB and to at most 8GB. GRUB can't universally solve this problem, as there is no standard interface used in all machines. However, several newer machines have the new interface, Logical Block Address ("LBA") mode. GRUB automatically detects if LBA mode is available and uses it if available. In LBA mode, GRUB can access the entire disk.
|
||||
|
||||
**Support network booting**
|
||||
GRUB is basically a disk-based boot loader but also has network support. You can load OS images from a network by using the "TFTP" protocol.
|
||||
|
||||
**Support remote terminals**
|
||||
To support computers with no console, GRUB provides remote terminal support, so that you can control GRUB from a remote host. Only serial terminal support is implemented at the moment.
|
||||
@@ -0,0 +1,66 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2010-08-03T21:37:58.731922
|
||||
|
||||
====== 2 Naming convention ======
|
||||
Created Tuesday 03 August 2010
|
||||
|
||||
The device syntax used in GRUB is a wee bit different from what you may have seen before in your operating system(s), and you need to know it so
|
||||
that you can specify a drive/partition.
|
||||
|
||||
Look at the following examples and explanations:
|
||||
|
||||
(fd0)
|
||||
|
||||
First of all, GRUB requires that the device name be enclosed with`(' and `)'. The `fd' part means that it is a floppy disk. The number`0' is the drive number, which is counted from _zero_. This expression means that GRUB will use the whole floppy disk.
|
||||
|
||||
(hd0,2)
|
||||
|
||||
Here, `hd' means it is a hard disk drive. The first integer `0' indicates the drive number, that is, the first hard disk, while the second integer, `1', indicates the partition number (or the PC slice
|
||||
number in the BSD terminology). The partition numbers are counted from
|
||||
_one_, not from zero (as was the case in previous versions of GRUB).
|
||||
This expression means the second partition of the first hard disk
|
||||
drive. In this case, GRUB uses one partition of the disk, instead of
|
||||
the whole disk.
|
||||
|
||||
(hd0,5)
|
||||
|
||||
This specifies the first "extended partition" of the first hard disk
|
||||
drive. Note that the partition numbers for extended partitions are
|
||||
counted from `5', regardless of the actual number of primary partitions
|
||||
on your hard disk.
|
||||
(hd1,a)
|
||||
|
||||
This means the BSD `a' partition of the second hard disk. If you
|
||||
need to specify which PC slice number should be used, use something
|
||||
like this: `(hd1,1,a)'. If the PC slice number is omitted, GRUB
|
||||
searches for the first PC slice which has a BSD `a' partition.
|
||||
|
||||
Of course, to actually access the disks or partitions with GRUB, you
|
||||
need to use the device specification in a command, like `root (fd0)' or
|
||||
`unhide (hd0,3)'. To help you find out which number specifies a
|
||||
partition you want, the GRUB command-line (*note Command-line
|
||||
interface::) options have argument completion. This means that, for
|
||||
example, you only need to type
|
||||
|
||||
root (
|
||||
|
||||
followed by a <TAB>, and GRUB will display the list of drives,
|
||||
partitions, or file names. So it should be quite easy to determine the
|
||||
name of your target partition, even with minimal knowledge of the
|
||||
syntax.
|
||||
|
||||
Note that GRUB does _not_ distinguish IDE from SCSI - it simply
|
||||
counts the drive numbers from zero, regardless of their type. Normally,
|
||||
any IDE drive number is less than any SCSI drive number, although that
|
||||
is not true if you change the boot sequence by swapping IDE and SCSI
|
||||
drives in your BIOS.
|
||||
|
||||
Now the question is, how to specify a file? Again, consider an
|
||||
example:
|
||||
|
||||
(hd0,1)/vmlinuz
|
||||
|
||||
This specifies the file named `vmlinuz', found on the first
|
||||
partition of the first hard disk drive. Note that the argument
|
||||
completion works with file names, too.
|
||||
29
Zim/Linux/dig_to_linux/Grub/Grub-info/3_Installation.txt
Normal file
29
Zim/Linux/dig_to_linux/Grub/Grub-info/3_Installation.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2010-08-03T21:41:04.717552
|
||||
|
||||
====== 3 Installation ======
|
||||
Created Tuesday 03 August 2010
|
||||
|
||||
In order to install GRUB as your boot loader, you need to first install
|
||||
the GRUB system and utilities under your UNIX-like operating system
|
||||
(*note Obtaining and Building GRUB::). You can do this either from the
|
||||
source tarball, or as a package for your OS.
|
||||
|
||||
After you have done that, you need to install the boot loader on a
|
||||
drive (floppy or hard disk). There are two ways of doing that - either
|
||||
using the utility `grub-install' (*note Invoking grub-install::) on a
|
||||
UNIX-like OS, or by running GRUB itself from a floppy. These are quite
|
||||
similar, however the utility might probe a wrong BIOS drive, so you
|
||||
should be careful.
|
||||
|
||||
Also, if you install GRUB on a UNIX-like OS, please make sure that
|
||||
you have an emergency boot disk ready, so that you can rescue your
|
||||
computer if, by any chance, your hard drive becomes unusable
|
||||
(unbootable).
|
||||
|
||||
GRUB comes with boot images, which are normally put in the directory
|
||||
`/usr/lib/grub/i386-pc'. Hereafter, the directory where GRUB images are
|
||||
initially placed (normally `/usr/lib/grub/i386-pc') will be called the
|
||||
"image directory", and the directory where the boot loader needs to
|
||||
find them (usually `/boot/grub') will be called the "boot directory".
|
||||
@@ -0,0 +1,70 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2010-08-03T21:41:33.862866
|
||||
|
||||
====== 3.1 Installing GRUB using grub-install ======
|
||||
Created Tuesday 03 August 2010
|
||||
|
||||
*Caution:* This procedure is definitely less safe, because there are
|
||||
several ways in which your computer can become unbootable. For example,
|
||||
most operating systems don't tell GRUB how to map BIOS drives to OS
|
||||
devices correctly--GRUB merely "guesses" the mapping. This will succeed
|
||||
in most cases, but not always. Therefore, GRUB provides you with a map
|
||||
file called the "device map", which you must fix if it is wrong. *Note
|
||||
Device map::, for more details.
|
||||
|
||||
If you still do want to install GRUB under a UNIX-like OS (such as
|
||||
GNU), invoke the program `grub-install' (*note Invoking grub-install::)
|
||||
as the superuser ("root").
|
||||
|
||||
The usage is basically very simple. You only need to specify one
|
||||
argument to the program, namely, where to install the boot loader. The
|
||||
argument can be either a device file (like `/dev/hda') or a partition
|
||||
specified in GRUB's notation. For example, under Linux the following
|
||||
will install GRUB into the MBR of the first IDE disk:
|
||||
|
||||
# grub-install /dev/hda
|
||||
|
||||
Likewise, under GNU/Hurd, this has the same effect:
|
||||
|
||||
# grub-install /dev/hd0
|
||||
|
||||
If it is the first BIOS drive, this is the same as well:
|
||||
|
||||
# grub-install '(hd0)'
|
||||
|
||||
Or you can omit the parentheses:
|
||||
|
||||
# grub-install hd0
|
||||
But all the above examples assume that GRUB should use images under
|
||||
the root directory. If you want GRUB to use images under a directory
|
||||
other than the root directory, you need to specify the option
|
||||
`--root-directory'. The typical usage is that you create a GRUB boot
|
||||
floppy with a filesystem. Here is an example:
|
||||
|
||||
# mke2fs /dev/fd0
|
||||
# mount -t ext2 /dev/fd0 /mnt
|
||||
# grub-install --root-directory=/mnt fd0
|
||||
# umount /mnt
|
||||
|
||||
Another example is when you have a separate boot partition which is
|
||||
mounted at `/boot'. Since GRUB is a boot loader, it doesn't know
|
||||
anything about mountpoints at all. Thus, you need to run `grub-install'
|
||||
like this:
|
||||
|
||||
# grub-install --root-directory=/boot /dev/hda
|
||||
|
||||
By the way, as noted above, it is quite difficult to guess BIOS
|
||||
drives correctly under a UNIX-like OS. Thus, `grub-install' will prompt
|
||||
you to check if it could really guess the correct mappings, after the
|
||||
installation. The format is defined in *note Device map::. Please be
|
||||
quite careful. If the output is wrong, it is unlikely that your
|
||||
computer will be able to boot with no problem.
|
||||
|
||||
Note that `grub-install' is actually just a shell script and the
|
||||
real task is done by the grub shell `grub' (*note Invoking the grub
|
||||
shell::). Therefore, you may run `grub' directly to install GRUB,
|
||||
without using `grub-install'. Don't do that, however, unless you are
|
||||
very familiar with the internals of GRUB. Installing a boot loader on a
|
||||
running OS may be extremely dangerous.
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2010-08-03T21:44:54.043221
|
||||
|
||||
====== 4 How To Boot Operating Systems ======
|
||||
Created Tuesday 03 August 2010
|
||||
|
||||
GRUB has two distinct boot methods. One of the two is to load an
|
||||
operating system directly, and the other is to chain-load another boot
|
||||
loader which then will load an operating system actually. Generally
|
||||
speaking, the former is more desirable, because you don't need to
|
||||
install or maintain other boot loaders and GRUB is flexible enough to
|
||||
load an operating system from an arbitrary disk/partition. However, the
|
||||
latter is sometimes required, since GRUB doesn't support all the
|
||||
existing operating systems natively.
|
||||
@@ -0,0 +1,13 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2010-08-03T21:47:46.310290
|
||||
|
||||
====== 5 Filesystem syntax and semantics ======
|
||||
Created Tuesday 03 August 2010
|
||||
|
||||
GRUB uses a special syntax for specifying disk drives which can be
|
||||
accessed by BIOS. Because of BIOS limitations, GRUB cannot distinguish
|
||||
between IDE, ESDI, SCSI, or others. You must know yourself which BIOS
|
||||
device is equivalent to which OS device. Normally, that will be clear if
|
||||
you see the files in a device or use the command `find' (*note find::).
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2010-08-03T21:48:43.110870
|
||||
|
||||
====== 5.1 How to specify devices ======
|
||||
Created Tuesday 03 August 2010
|
||||
|
||||
The device syntax is like this:
|
||||
|
||||
`(DEVICE[,PART-NUM][,BSD-SUBPART-LETTER])'
|
||||
|
||||
`[]' means the parameter is optional. DEVICE should be either `fd'
|
||||
or `hd' followed by a digit, like `fd0'. But you can also set DEVICE
|
||||
to a hexadecimal or a decimal number which is a BIOS drive number, so
|
||||
the following are equivalent:
|
||||
|
||||
(hd0)
|
||||
(0x80)
|
||||
(128)
|
||||
|
||||
PART-NUM represents the partition number of DEVICE, starting from
|
||||
one for primary partitions and from five for extended partitions, and
|
||||
BSD-SUBPART-LETTER represents the BSD disklabel subpartition, such as
|
||||
`a' or `e'.
|
||||
|
||||
A shortcut for specifying BSD subpartitions is
|
||||
`(DEVICE,BSD-SUBPART-LETTER)', in this case, GRUB searches for the
|
||||
first PC partition containing a BSD disklabel, then finds the
|
||||
subpartition BSD-SUBPART-LETTER. Here is an example:
|
||||
|
||||
(hd0,a)
|
||||
|
||||
The syntax `(hd0)' represents using the entire disk (or the MBR when
|
||||
installing GRUB), while the syntax `(hd0,1)' represents using the first
|
||||
partition of the disk (or the boot sector of the partition when
|
||||
installing GRUB).
|
||||
|
||||
If you enabled the network support, the special drive, `(nd)', is
|
||||
also available. Before using the network drive, you must initialize the
|
||||
network. *Note Network::, for more information.
|
||||
@@ -0,0 +1,19 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2010-08-03T21:49:39.938628
|
||||
|
||||
====== 5.2 How to specify files ======
|
||||
Created Tuesday 03 August 2010
|
||||
|
||||
There are two ways to specify files, by "absolute file name" and by
|
||||
"block list".
|
||||
|
||||
An absolute file name resembles a Unix absolute file name, using `/'
|
||||
for the directory separator (not `\' as in DOS). One example is
|
||||
`(hd0,1)/boot/grub/grub.cfg'. This means the file `/boot/grub/grub.cfg'
|
||||
in the first partition of the first hard disk. If you omit the device
|
||||
name in an absolute file name, GRUB uses GRUB's "root device"
|
||||
implicitly. So if you set the root device to, say, `(hd1,1)' by the
|
||||
command `root' (*note root::), then `/boot/kernel' is the same as
|
||||
`(hd1,1)/boot/kernel'.
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2010-08-03T21:51:08.588023
|
||||
|
||||
====== 5.3 How to specify block lists ======
|
||||
Created Tuesday 03 August 2010
|
||||
|
||||
A block list is used for specifying a file that doesn't appear in the
|
||||
filesystem, like a chainloader. The syntax is
|
||||
`[OFFSET]+LENGTH[,[OFFSET]+LENGTH]...'. Here is an example:
|
||||
|
||||
`0+100,200+1,300+300'
|
||||
|
||||
This represents that GRUB should read blocks 0 through 99, block 200,
|
||||
and blocks 300 through 599. If you omit an offset, then GRUB assumes
|
||||
the offset is zero.
|
||||
|
||||
Like the file name syntax (*note File name syntax::), if a blocklist
|
||||
does not contain a device name, then GRUB uses GRUB's "root device". So
|
||||
`(hd0,2)+1' is the same as `+1' when the root device is `(hd0,2)'.
|
||||
204
Zim/Linux/dig_to_linux/Grub/grub探秘.txt
Normal file
204
Zim/Linux/dig_to_linux/Grub/grub探秘.txt
Normal file
@@ -0,0 +1,204 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2011-03-27T20:00:36+08:00
|
||||
|
||||
====== grub探秘 ======
|
||||
Created Sunday 27 March 2011
|
||||
|
||||
这一次探秘的是进入linux世界的大门---开机引导程序Grub(GRand Unfied Bootloader).
|
||||
|
||||
GRUB是GNU下的FSF开发的一套多重开机引导程序,在其主页上已经声明旧的版本将不在开发,以后的重点放在GRUB2上,所以这一次探秘将以GRUB2为例介绍,当然在阐述一些原理时会使用GRUB0.97的一些文件作类比。
|
||||
|
||||
一、为何说Grub是进入linux世界的大门呢?
|
||||
在Ubuntu探秘之一:BIOS到底干啥用?中我提到过“BIOS最后一步的工作就是协助加载位于硬盘上的OS”,这是通过将程序指针指向硬盘的MBR中的bootloader程序完成的,而现在linux系统的bootloader就是由Grub提供的。通常MBR占用一个扇区即512字节,共分成以下三个部分:bootloader占用446字节,partition table即分区表64字节,Magic number 即标识MBR结束的字符占两字节其内容固定为"55aa"。简单地说,grub就是Computer启动时执行的第一个程序(BIOS除外,因其为固件程序不是由用户安装的)。它的主要任务是加载和传递参数给OS的kernle(如linux系统),kernel负责初始化并控制此后的整个系统。
|
||||
|
||||
另外再提下占64字节的分区表,通常大容量硬盘是要分区使用的,这便于数据的分类存储同时也提高了其安全性。分区时由于历史原因(主要是BIOS寻找的问题)被限定为最多只能建立4个主分区,其中每个主分区的开始地址、结束地址、分区类型(以固定数字表示用fdisk命令可以查看,如88表示linux分区,1表示FAT12分区)都存在MBR的分区表中,每个分区占16字节。需要注意的是各主分区建立后即使硬盘还有空闲空间,这时也不能使用,因为MBR能容纳的4个分区表已经全用了。解决的方法是拿出一个主分区的分区表用于建立扩展分区,在扩展分区的空间里可建立建立多个逻辑分区。所以常见的硬盘分区方案是三个主分区一个扩展分区,在扩展分区里建立多个逻辑分区。
|
||||
|
||||
|
||||
二、GRUB的主要特点如下:
|
||||
1.支持多种文件系统 这可以从/boot/grub下的许多mod文件看出来
|
||||
2.支持不可多重开机的OS如XP 这是通过链式(chainloader)加载完成的
|
||||
3.支持自动解压缩 kernel和initrd就是以压缩文件的形式被GRUB加载到内存中的
|
||||
3.配置文件及交互接口较人性化
|
||||
4.支持GRUB SHELL 在系统不能引导时,grub 的shell就显得非常重要!
|
||||
5.支持远程终端模式和无磁盘系统
|
||||
|
||||
GRUB较其它bootloader的重要优点是其灵活性。它理解文件系统和kernel的可执行文件格式,所以你可以引导你喜欢的任意OS而不管它的kernel位于物理硬盘上的位置。在加载kernel时你只只需指明kernel的文件名以及所在设备和分区即可。用GRUB引导OS时你有两者选择(但在系统出现问题如grub.cfg文件丢失时你实际上只有一种选择即GRUB CLI)即command-line interface , or a menu interface。在使用command-line interface 时你需要手动指定kernel的名称及位于硬盘上的位置,在使用menu interface时,你只需要移动光标选择你要引导的OS即可,在menu interface时也可以切换到command-line interface。
|
||||
|
||||
三、下面让我们看一下系统上安装了哪些和GRUB相关的软件包:
|
||||
geekard@geekard-laptop:~$ dpkg -l \*grub* |grep ii
|
||||
ii grub-common 1.98-1ubuntu7 GRand Unified Bootloader, version 2 (common
|
||||
ii grub-pc 1.98-1ubuntu7 GRand Unified Bootloader, version 2 (PC/BIOS
|
||||
geekard@geekard-laptop:~$
|
||||
其中grub-pc软件包就是系统安装的GRUB套件,是我们探秘的重点,下面看一下它的功能和安装到系统中的文件
|
||||
geekard@geekard-laptop:~$ dpkg -s grub-pc
|
||||
Package: grub-pc
|
||||
。。。。
|
||||
Description: GRand Unified Bootloader, version 2 (PC/BIOS version)
|
||||
GRUB is a portable, powerful bootloader. This version of GRUB is based on a
|
||||
cleaner design than its predecessors, and provides the following new features:
|
||||
.
|
||||
- Scripting in grub.cfg using BASH-like syntax. #注意配置文件是BASH-LIKE语法
|
||||
- Support for modern partition maps such as GPT.
|
||||
- Modular generation of grub.cfg via update-grub. Packages providing GRUB
|
||||
add-ons can plug in their own script rules and trigger updates by invoking
|
||||
update-grub2. #gru.cfg文件需要的模块(modular)是由update-grub工具生成的
|
||||
- VESA-based graphical mode with background image support and complete 24-bit
|
||||
color set.
|
||||
- Support for extended charsets. Users can write UTF-8 text to their menu
|
||||
entries.
|
||||
。。。。。
|
||||
|
||||
geekard@geekard-laptop:~$ dpkg -L grub-pc
|
||||
/.
|
||||
/usr
|
||||
/usr/lib
|
||||
/usr/lib/grub
|
||||
/usr/lib/grub/i386-pc #这个目录很重要,在安装GRUB时(用grub-install命令),/boot/grub目录下的大部分文件就是从这里copy过去的
|
||||
/usr/lib/grub/i386-pc/boot.img
|
||||
/usr/lib/grub/i386-pc/cdboot.img
|
||||
/usr/lib/grub/i386-pc/diskboot.img
|
||||
/usr/lib/grub/i386-pc/kernel.img
|
||||
/usr/lib/grub/i386-pc/lnxboot.img
|
||||
/usr/lib/grub/i386-pc/pxeboot.img
|
||||
......
|
||||
/usr/bin
|
||||
/usr/bin/grub-mkimage #这是生成recure的命令
|
||||
/usr/sbin
|
||||
/usr/sbin/grub-setup #这个是由grub-install调用的底层命令,用于将grub安装到指定位置
|
||||
/usr/sbin/update-grub2
|
||||
/usr/sbin/update-grub
|
||||
/usr/sbin/grub-install #这个命令经常用到,即为grub安装命令
|
||||
/usr/sbin/grub-set-default
|
||||
/usr/sbin/grub-reboot
|
||||
/usr/sbin/upgrade-from-grub-legacy
|
||||
/etc
|
||||
/etc/grub.d
|
||||
。。。。
|
||||
|
||||
四、让我们再看看系统安装GRUB后生成的目录和文件
|
||||
|
||||
/boot/grub目录中的文件
|
||||
|
||||
*.mod 驱动模块,用于识别各种文件系统等
|
||||
command.lst grub支持的命令列表
|
||||
fs.lst grub支持的文件系统列表
|
||||
handler.lst grub命令运行环境:sh
|
||||
moddep.lst 模块间的依赖关系
|
||||
grub.conf grub配置文件
|
||||
|
||||
/etc/grub.d/目录中的文件有: 00_header 10_linux 30_os-prober 05_debian_theme 20_memtest86+ 40_custom,它们都是一些有编号的脚本文件,起到模板作用,用以产生grub.cfg的内容。/etc/default/grub控制grub.cfg文件的设置如timeout,hidden,default等。其中00_header 30_os-prober 05_debian_theme 是安装系统时自动生成的设置脚本,它们可有可无。10_linux记录了安装的系统,用户可以在40_custom 中添加自己要指定的系统具体格式可以参考:
|
||||
/usr/shard/doc/grub-common/example/grub.cfg
|
||||
|
||||
|
||||
五、GRUB引导程序的安装步骤:
|
||||
第一步:安装GRUB套件如grub-pc 及grub-common(可选,因为可用LIVECD或其它可引导且安装了该套件的磁盘)
|
||||
第二步:将bootloader安装到磁盘的bootloader上,有两种方法 可以达到此目的,一种是在linux系统上执行grub-install 另一种是从已经安装grub的引导盘或安装光盘上执行grub-install命令。
|
||||
|
||||
警告:most operating systems don't tell GRUB how to map BIOS drives to OS devices correctly--GRUB merely "guesses" the mapping. This will succeed in most cases, but not always. Therefore, GRUB provides you with a map file called the "device map", which you must fix if it is wrong. If the output is wrong, it is unlikely that your computer will be able to boot with no problem.
|
||||
device.map位于/boot/grub/,内容为BIOS drives 与 OS devices的对应关系:
|
||||
如:(hd0) /dev/sda
|
||||
|
||||
grub-install的语法为:
|
||||
#grub-install –root-directory=DIR INSTALL_DEVICE --root-directory 用于指定grub文件安装目录(默认为根目录),而INSTALL_DEVICE用于指定安装的设备,通常为MBR或分区.
|
||||
|
||||
grub 在DIR目录下建立boot/grub/*目录和文件(这些文件来自安装GRUB套件时产生的文件 /usr/lib/grub/i386-pc),但不会生成grub.cfg 文件,可用grub-mkconfig 命令生成这个文件,也可以手动编辑。默认的root-directory为根目录。在用rescue mode 没有chroot安装grub时常用这个选项。
|
||||
|
||||
第三步:手动编辑grub.conf文件
|
||||
|
||||
(1)在讨论grub.cfg的格式之前,让我们看一下GRUB设备命名的注意事项:
|
||||
|
||||
1、GRUB要求所有的设备名称要包含在括号中如:(hd0,3)。hd0中的0表示系统第一块磁盘,其它依次为1,2.。。。,第二个数字3表示第三个分区,分区号从1开始。
|
||||
注意第二个参数即分区好可以省略,这时表示整个磁盘。
|
||||
2、为了获得磁盘或分区中的文件,你需要在路径的开始指定设备或分区如(hd0,3)/boot/vmlinuz,可以用“root (hd0,3)”指定当文件的开始没有指定设备或分区时的默认值。
|
||||
在用绝对路径指定文件时若路径最前面没有device,则GRUB就默认由root device 指定的device,如root (hd0,2).但像root=/dev/sda1,由于绝对路径和=号之间没有空格,故没有这种关系。实际上linux命令行上的root参数一直是root=/dev/[sh]d[a-z][0-9]的格式,并不用在/dev前加空格和指定设备分区,因为这是传给kernel的参数,此时的设备文件其实是由initrd提供的。根目录是内存中由内核产生的rootfs.
|
||||
3、为了帮助你找到正确的分区号,GRUB的命令行支持自动补全,这意味着你只需输入root (然后按TAB键就会看到GRUB列出的所有设备、分区或文件。所以在GRUB的命令行操作时要善用TAB键。
|
||||
4、GRUB不区分IDE和SCSI接口,因此设备都是hd*的形式而没有sd*形式
|
||||
|
||||
(2)下面让我看一下grub.cfg的简单示例:
|
||||
|
||||
grub.cfg 是由/usr/sbin/grub-mkconfig 工具根据/etc/grub.d 目录中的文件和/etc/default/grub中的配置生成的。当然也可以手动编辑。
|
||||
|
||||
#
|
||||
# Sample GRUB configuration file
|
||||
#
|
||||
|
||||
# Boot automatically after 30 secs.
|
||||
set timeout=30
|
||||
|
||||
# By default, boot the first entry.
|
||||
set default=0
|
||||
|
||||
# Fallback to the second entry.
|
||||
set fallback=1
|
||||
|
||||
# For booting GNU/Linux
|
||||
menuentry "GNU/Linux" {
|
||||
set root=(hd0,1)
|
||||
linux /vmlinuz root=/dev/sda1
|
||||
initrd /initrd.img
|
||||
}
|
||||
|
||||
# For booting Microsoft Windows
|
||||
menuentry "Microsoft Windows" {
|
||||
set root=(hd0,1)
|
||||
chainloader +1
|
||||
}
|
||||
|
||||
# For booting Memtest86+
|
||||
menuentry "Memtest86+" {
|
||||
set root=(hd0,1)
|
||||
linux16 /memtest86+.bin
|
||||
}
|
||||
|
||||
# Change the colors.
|
||||
menuentry "Change the colors" {
|
||||
set menu_color_normal=light-green/brown
|
||||
set menu_color_highlight=red/blue
|
||||
}
|
||||
注意:linux 命令行参数中的root=/dev/[s,h]d[a-z][0-9]的形式是不变的,"=/"间不能有空格,因为这个参数这是传给kernel,此时的设备文件(即/dev/sda等)其实是由initrd提供的。根目录是内存中由内核产生的rootfs.
|
||||
|
||||
六、GRUB引导OS的过程(以GRUB0.97为例)
|
||||
|
||||
GRUB运行时其实分为三个阶段:第一个阶段执行MBR中bootloader中的内容(446字节),第二阶段执行MBR后大约30KB的内容(其实就是*.mod中的一个文件的copy,用来识别kernel文件所在的文件系统),第三阶段执行/boot/grub目录中的内容。若开机时GRUB不能读取该目录,则会提示:grub rescue > 这时只能重新安装GRUB。若能读取该目录但配置文件丢失时,会显示GRUB SHELL ,这时可以手动指定相关文件位置。之所以会分阶段进行是由于bootloader容纳的代码有限,不可能把全部功能(如识别文件系统、提供SHELL和菜单选项、加载kernel)都集中与此,解决方法就是将功能分解为三部分:bootloader主要负责引导、MBR后的30KB负责识别文件系统、其它的功能都是由文件系统中的/boot/grub目录中的文件提供,而这时程序大小是不受限制的同时kernle的在文件系统中的位置也是不受限制的(只要其位于GRUB第二阶段可识别的文件系统中即可)。
|
||||
|
||||
|
||||
七、关于grub-install命令的讨论(以GRUB0.97为例)
|
||||
|
||||
grub-install命令用于将GRUB安装到磁盘的MBR或分区的bootloader上,在系统不能正常引导时经常使用。其语法为:
|
||||
|
||||
#grub-install –root-directory=DIR install_device --root-directory 用于指定grub文件安装目录,而install_device用于指定安装的设备,通常为MBR或分区.
|
||||
|
||||
讨论一:安装grub时的DIR和install_device可以不在同一个分区,但grub安装完成后,这种对应关系是确定的。也就是说stage1,stage1.5都写入到install_device上了,其中stage1.5中记录了stage2即—root-directory的位置信息,在stage1.5的文件中有这样一个参数:(hd*,*)/DIR/,它记录了这种对应关系。当DIR被移走或目录名修改如将DIR/boot改为DIR/boot2时,将会出现不能引导并显示grub rescue >,这是因为GRUB不能读取以前安装时定义的DIR/boot/grub中的文件信息(相当于stage2)。但DIR/boot/grub/grub.cfg丢失时,由于可以读去DIR/boot/grub中的文件故会出现grub shell提示符,这时可以手动配置。另外vmlinuz和initrd可位于任何位置,不一定位于DIR/boot中,这体现了GRUB的灵活性,即不管vmlinuz和initrd位于哪儿都可以引导。在grub.cfg文件中root用于指定vmlinuz和initrd所在的分区,这和grub的安装目录无关。
|
||||
|
||||
讨论二:当建立单独的/boot分区时,手动安装和配置grub的方法:
|
||||
# grub-install /dev/sda 默然安装到根目录中,并根据需要建立/boot/grub目录结构。
|
||||
配置方式:
|
||||
menuentry "GNU/Linux" {
|
||||
set root=(hd0,1) 指定含有 vmlinuz、initrd.img 的设备或分区,可以与grub的目录不在一个分区。
|
||||
linux /vmlinuz root=/dev/sda1
|
||||
initrd /initrd.img }
|
||||
因为/dev/sda1 被挂载到/boot目录中故上述的 /vmlinuz 和/initrd.img 的/等价于/boot目录.
|
||||
|
||||
讨论三:用LIVECD恢复GRUB受破坏而不能正常引导的主机其步骤为:
|
||||
1.开机时从光盘启动,插入LIVECD,选择“试用而不安装”进入GNOME桌面。
|
||||
2.打开终端,将硬盘上有rootfs的分区挂载到/mnt目录下。
|
||||
3.用root身份执行:grub-install --root-directory=/mnt/ /dev/sda(安装到MBR),重启即可
|
||||
|
||||
|
||||
八、常用GRUB命令
|
||||
geekard@geekard-laptop:~$ grub-
|
||||
grub-mkdevicemap 生成device.map文件
|
||||
grub-probe 获取给定路径或设备的信息如fs|fs_uuid|drive|device|partmap|abstraction
|
||||
|
||||
grub-setup 将grub写入boot sector
|
||||
grub-install 安装grub到指定设备和目录,调用grub-setup
|
||||
|
||||
grub-script-check 检查/etc/grub.d目录中脚本的正确性
|
||||
grub-mkconfig 根据/etc/grub.d和/etc/defaults/grub中的文件生成配置文件
|
||||
|
||||
grub-set-default 设置default的 menuentry
|
||||
grub-reboot 设置下次启动时的menuentry
|
||||
|
||||
grub-mkrescue 生成rescue盘
|
||||
|
||||
45
Zim/Linux/dig_to_linux/Reference/HP520/biosdecode.txt
Normal file
45
Zim/Linux/dig_to_linux/Reference/HP520/biosdecode.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2011-03-27T19:40:51+08:00
|
||||
|
||||
====== biosdecode ======
|
||||
Created Sunday 27 March 2011
|
||||
|
||||
# biosdecode 2.9
|
||||
ACPI 2.0 present.
|
||||
OEM Identifier: HP
|
||||
RSD Table 32-bit Address: 0x5F7E5778
|
||||
XSD Table 64-bit Address: 0x000000005F7E57C8
|
||||
SMBIOS 2.4 present.
|
||||
Structure Table Length: 1032 bytes
|
||||
Structure Table Address: 0x000F3ABF
|
||||
Number Of Structures: 23
|
||||
Maximum Structure Size: 336 bytes
|
||||
SYSID present.
|
||||
Revision: 0
|
||||
Structure Table Address: 0x000F9971
|
||||
Number Of Structures: 1
|
||||
BIOS32 Service Directory present.
|
||||
Revision: 0
|
||||
Calling Interface Address: 0x000F0000
|
||||
PNP BIOS 1.0 present.
|
||||
Event Notification: Polling
|
||||
Event Notification Flag Address: 0x000FF676
|
||||
Real Mode 16-bit Code Address: F000:F697
|
||||
Real Mode 16-bit Data Address: F000:0000
|
||||
16-bit Protected Mode Code Address: 0x000FF67E
|
||||
16-bit Protected Mode Data Address: 0x000F0000
|
||||
OEM Device Identifier: DA\3000
|
||||
PCI Interrupt Routing 1.0 present.
|
||||
Router ID: 00:1f.0
|
||||
Exclusive IRQs: 5 10 11
|
||||
Compatible Router: 8086:2641
|
||||
Slot Entry 1: ID 00:03, on-board
|
||||
Slot Entry 2: ID 00:1e, on-board
|
||||
Slot Entry 3: ID 00:02, on-board
|
||||
Slot Entry 4: ID 00:1f, on-board
|
||||
Slot Entry 5: ID 00:1c, on-board
|
||||
Slot Entry 6: ID 02:01, on-board
|
||||
Slot Entry 7: ID 10:00, on-board
|
||||
Slot Entry 8: ID 02:06, on-board
|
||||
Slot Entry 9: ID 00:1d, on-board
|
||||
286
Zim/Linux/dig_to_linux/Reference/HP520/dmidecode.txt
Normal file
286
Zim/Linux/dig_to_linux/Reference/HP520/dmidecode.txt
Normal file
@@ -0,0 +1,286 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2011-03-27T19:41:06+08:00
|
||||
|
||||
====== dmidecode ======
|
||||
Created Sunday 27 March 2011
|
||||
|
||||
# dmidecode 2.9
|
||||
SMBIOS 2.4 present.
|
||||
23 structures occupying 1032 bytes.
|
||||
Table at 0x000F3ABF.
|
||||
|
||||
Handle 0x0000, DMI type 0, 24 bytes
|
||||
BIOS Information
|
||||
Vendor: Hewlett-Packard
|
||||
Version: 68MVU Ver. F.07
|
||||
Release Date: 03/18/2008
|
||||
Address: 0xE0000
|
||||
Runtime Size: 128 kB
|
||||
ROM Size: 1024 kB
|
||||
Characteristics:
|
||||
PCI is supported
|
||||
PC Card (PCMCIA) is supported
|
||||
PNP is supported
|
||||
BIOS is upgradeable
|
||||
BIOS shadowing is allowed
|
||||
Boot from CD is supported
|
||||
Selectable boot is supported
|
||||
EDD is supported
|
||||
3.5"/720 KB floppy services are supported (int 13h)
|
||||
Print screen service is supported (int 5h)
|
||||
8042 keyboard services are supported (int 9h)
|
||||
Serial services are supported (int 14h)
|
||||
Printer services are supported (int 17h)
|
||||
ACPI is supported
|
||||
USB legacy is supported
|
||||
LS-120 boot is supported
|
||||
Smart battery is supported
|
||||
BIOS boot specification is supported
|
||||
Function key-initiated network boot is supported
|
||||
Targeted content distribution is supported
|
||||
BIOS Revision: 15.7
|
||||
Firmware Revision: 130.21
|
||||
|
||||
Handle 0x0001, DMI type 1, 27 bytes
|
||||
System Information
|
||||
Manufacturer: Hewlett-Packard
|
||||
Product Name: HP 520 Notebook PC(GN815AA#AB2)
|
||||
Version: F.07
|
||||
Serial Number: CND7250TZ6
|
||||
UUID: 555EE592-9E1F-DC11-1A94-66990E2F9929
|
||||
Wake-up Type: Power Switch
|
||||
SKU Number: GN815AA#AB2
|
||||
Family: 103C_5336AN
|
||||
|
||||
Handle 0x0040, DMI type 126, 32 bytes
|
||||
Inactive
|
||||
|
||||
Handle 0x0002, DMI type 2, 8 bytes
|
||||
Base Board Information
|
||||
Manufacturer: Hewlett-Packard
|
||||
Product Name: 30D5
|
||||
Version: KBC Version 82.15
|
||||
Serial Number: Not Specified
|
||||
|
||||
Handle 0x0003, DMI type 3, 13 bytes
|
||||
Chassis Information
|
||||
Manufacturer: Hewlett-Packard
|
||||
Type: Notebook
|
||||
Lock: Not Present
|
||||
Version: Not Specified
|
||||
Serial Number: CND7250TZ6
|
||||
Asset Tag:
|
||||
Boot-up State: Safe
|
||||
Power Supply State: Safe
|
||||
Thermal State: Safe
|
||||
Security Status: External Interface Enabled
|
||||
|
||||
Handle 0x0041, DMI type 126, 4 bytes
|
||||
Inactive
|
||||
|
||||
Handle 0x0004, DMI type 4, 35 bytes
|
||||
Processor Information
|
||||
Socket Designation: U10
|
||||
Type: Central Processor
|
||||
Family: Pentium M
|
||||
Manufacturer: Intel(R)
|
||||
ID: E8 06 00 00 FF FB E9 BF
|
||||
Signature: Type 0, Family 6, Model 14, Stepping 8
|
||||
Flags:
|
||||
FPU (Floating-point unit on-chip)
|
||||
VME (Virtual mode extension)
|
||||
DE (Debugging extension)
|
||||
PSE (Page size extension)
|
||||
TSC (Time stamp counter)
|
||||
MSR (Model specific registers)
|
||||
PAE (Physical address extension)
|
||||
MCE (Machine check exception)
|
||||
CX8 (CMPXCHG8 instruction supported)
|
||||
APIC (On-chip APIC hardware supported)
|
||||
SEP (Fast system call)
|
||||
MTRR (Memory type range registers)
|
||||
PGE (Page global enable)
|
||||
MCA (Machine check architecture)
|
||||
CMOV (Conditional move instruction supported)
|
||||
PAT (Page attribute table)
|
||||
CLFSH (CLFLUSH instruction supported)
|
||||
DS (Debug store)
|
||||
ACPI (ACPI supported)
|
||||
MMX (MMX technology supported)
|
||||
FXSR (Fast floating-point save and restore)
|
||||
SSE (Streaming SIMD extensions)
|
||||
SSE2 (Streaming SIMD extensions 2)
|
||||
SS (Self-snoop)
|
||||
HTT (Hyper-threading technology)
|
||||
TM (Thermal monitor supported)
|
||||
PBE (Pending break enabled)
|
||||
Version: Genuine Intel(R) CPU T2300 @ 1.66GHz
|
||||
Voltage: 1.1 V
|
||||
External Clock: 166 MHz
|
||||
Max Speed: 1667 MHz
|
||||
Current Speed: 1667 MHz
|
||||
Status: Populated, Enabled
|
||||
Upgrade: None
|
||||
L1 Cache Handle: 0x0005
|
||||
L2 Cache Handle: 0x0006
|
||||
L3 Cache Handle: Not Provided
|
||||
Serial Number: Not Specified
|
||||
Asset Tag: Not Specified
|
||||
Part Number: Not Specified
|
||||
|
||||
Handle 0x0005, DMI type 7, 19 bytes
|
||||
Cache Information
|
||||
Socket Designation: Internal L1 Cache
|
||||
Configuration: Enabled, Not Socketed, Level 1
|
||||
Operational Mode: Write Back
|
||||
Location: Internal
|
||||
Installed Size: 64 KB
|
||||
Maximum Size: 64 KB
|
||||
Supported SRAM Types:
|
||||
Burst
|
||||
Installed SRAM Type: Burst
|
||||
Speed: Unknown
|
||||
Error Correction Type: Unknown
|
||||
System Type: Unified
|
||||
Associativity: 4-way Set-associative
|
||||
|
||||
Handle 0x0006, DMI type 7, 19 bytes
|
||||
Cache Information
|
||||
Socket Designation: Internal L2 Cache
|
||||
Configuration: Enabled, Not Socketed, Level 2
|
||||
Operational Mode: Write Back
|
||||
Location: External
|
||||
Installed Size: 2048 KB
|
||||
Maximum Size: 2048 KB
|
||||
Supported SRAM Types:
|
||||
Burst
|
||||
Installed SRAM Type: Burst
|
||||
Speed: Unknown
|
||||
Error Correction Type: None
|
||||
System Type: Unified
|
||||
Associativity: 4-way Set-associative
|
||||
|
||||
Handle 0x0007, DMI type 9, 13 bytes
|
||||
System Slot Information
|
||||
Designation: PC CARD-Slot 0
|
||||
Type: 32-bit PC Card (PCMCIA)
|
||||
Current Usage: Available
|
||||
Length: Short
|
||||
ID: Adapter 0, Socket 0
|
||||
Characteristics:
|
||||
5.0 V is provided
|
||||
3.3 V is provided
|
||||
PC Card-16 is supported
|
||||
Cardbus is supported
|
||||
PME signal is supported
|
||||
|
||||
Handle 0x0008, DMI type 10, 6 bytes
|
||||
On Board Device Information
|
||||
Type: Video
|
||||
Status: Enabled
|
||||
Description: 8
|
||||
|
||||
Handle 0x0009, DMI type 11, 5 bytes
|
||||
OEM Strings
|
||||
String 1: www.hp.com
|
||||
String 2: ABS 70/71 79 7A 7B 7C 7D
|
||||
|
||||
Handle 0x000A, DMI type 16, 15 bytes
|
||||
Physical Memory Array
|
||||
Location: System Board Or Motherboard
|
||||
Use: System Memory
|
||||
Error Correction Type: None
|
||||
Maximum Capacity: 4 GB
|
||||
Error Information Handle: No Error
|
||||
Number Of Devices: 2
|
||||
|
||||
Handle 0x000B, DMI type 17, 27 bytes
|
||||
Memory Device
|
||||
Array Handle: 0x000A
|
||||
Error Information Handle: No Error
|
||||
Total Width: 64 bits
|
||||
Data Width: 64 bits
|
||||
Size: 512 MB
|
||||
Form Factor: SODIMM
|
||||
Set: None
|
||||
Locator: DIMM #1
|
||||
Bank Locator: Not Specified
|
||||
Type: DDR2
|
||||
Type Detail: Synchronous
|
||||
Speed: 667 MHz (1.5 ns)
|
||||
Manufacturer: CE00000000000000
|
||||
Serial Number: F41C2AE9
|
||||
Asset Tag: Not Specified
|
||||
Part Number: M4 70T6554EZ3-CE6
|
||||
|
||||
Handle 0x000C, DMI type 17, 27 bytes
|
||||
Memory Device
|
||||
Array Handle: 0x000A
|
||||
Error Information Handle: No Error
|
||||
Total Width: 64 bits
|
||||
Data Width: 64 bits
|
||||
Size: 1024 MB
|
||||
Form Factor: SODIMM
|
||||
Set: None
|
||||
Locator: DIMM #2
|
||||
Bank Locator: Not Specified
|
||||
Type: DDR2
|
||||
Type Detail: Synchronous
|
||||
Speed: 975 MHz (1.0 ns)
|
||||
Manufacturer: AD00000000000000
|
||||
Serial Number: 04008103
|
||||
Asset Tag: Not Specified
|
||||
Part Number: HYMP112S64CR6-S6
|
||||
|
||||
Handle 0x000D, DMI type 19, 15 bytes
|
||||
Memory Array Mapped Address
|
||||
Starting Address: 0x00000000000
|
||||
Ending Address: 0x0005FFFFFFF
|
||||
Range Size: 1536 MB
|
||||
Physical Array Handle: 0x000A
|
||||
Partition Width: 0
|
||||
|
||||
Handle 0x000E, DMI type 20, 19 bytes
|
||||
Memory Device Mapped Address
|
||||
Starting Address: 0x00000000000
|
||||
Ending Address: 0x0001FFFFFFF
|
||||
Range Size: 512 MB
|
||||
Physical Device Handle: 0x000B
|
||||
Memory Array Mapped Address Handle: 0x000D
|
||||
Partition Row Position: 1
|
||||
|
||||
Handle 0x000F, DMI type 20, 19 bytes
|
||||
Memory Device Mapped Address
|
||||
Starting Address: 0x00020000000
|
||||
Ending Address: 0x0005FFFFFFF
|
||||
Range Size: 1 GB
|
||||
Physical Device Handle: 0x000C
|
||||
Memory Array Mapped Address Handle: 0x000D
|
||||
Partition Row Position: 2
|
||||
|
||||
Handle 0x0010, DMI type 32, 11 bytes
|
||||
System Boot Information
|
||||
Status: No errors detected
|
||||
|
||||
Handle 0x0085, DMI type 133, 34 bytes
|
||||
OEM-specific Type
|
||||
Header and Data:
|
||||
85 22 85 00 01 98 08 D0 07 14 00 08 00 90 00 1F
|
||||
00 5B 40 00 00 D0 39 02 D0 00 0A 10 08 10 40 10
|
||||
09 10
|
||||
Strings:
|
||||
36571 06/09/2007
|
||||
HP
|
||||
|
||||
Handle 0x0086, DMI type 126, 34 bytes
|
||||
Inactive
|
||||
|
||||
Handle 0x0011, DMI type 144, 26 bytes
|
||||
OEM-specific Type
|
||||
Header and Data:
|
||||
90 1A 11 00 FF FF FF FF FF FF FF FF FF FF FF FF
|
||||
FF FF FF FF FF FF FF FF 00 00
|
||||
|
||||
Handle 0x0012, DMI type 127, 4 bytes
|
||||
End Of Table
|
||||
87
Zim/Linux/dig_to_linux/Ubuntu_软件包管理详解.txt
Normal file
87
Zim/Linux/dig_to_linux/Ubuntu_软件包管理详解.txt
Normal file
@@ -0,0 +1,87 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2011-11-27T19:44:11+08:00
|
||||
|
||||
====== Ubuntu 软件包管理详解 ======
|
||||
Created Sunday 27 November 2011
|
||||
http://www.cppblog.com/jb8164/archive/2009/01/09/71583.html
|
||||
|
||||
Ubuntu 方便宜用,最值得让人称道的便是其安装软件的方式, 一条命令: sudo apt-get install xxx 就几乎能帮你搞定所有的软件安装难题。但是有时你可能有这样的需求,查看某个软件包是否安装、安装在哪..., 那我们就来介绍一下 Ubuntu 的软件包管理方式。
|
||||
|
||||
一、Ubuntu 采用 Debian 的软件包管理器 dpkg 来管理软件包, 类似 RPM. 系统中所有 packages 的信息都在** /var/lib/dpkg/**
|
||||
目录下, 其子目录 **/var/lib/dpkg/info **用于保存各个软件包的配置文件列表:
|
||||
(1).conffiles 记录了软件包的配置文件列表
|
||||
(2).list 保存软件包中的**文件列表**, 用户可以从 .list 的信息中找到软件包中文件的具体安装位置.
|
||||
(3).md5sums 记录了软件包的md5信息, 这个信息是用来进行包验证的.
|
||||
(4).prerm 脚本在 Debian 包解包之前运行, 主要作用是停止作用于即将升级的软件包的服务, 直到软件包安装或升级完成.
|
||||
(5).postinst 脚本是完成 Debian 包解开之后的配置工作, 通常用于执行所安装软件包相关命令和服务重新启动.
|
||||
|
||||
/var/lib/dpkg/available 文件的内容是软件包的描述信息, 该软件包括当前系统所使用的 Debian 安装源中的所有软件包,
|
||||
其中包括当前系统中已安装的和未安装的软件包.
|
||||
|
||||
/var/cache/apt/archives 目录是在用 apt-get install 安装软件时,软件包的临时存放路径
|
||||
|
||||
/etc/apt/sources.list 存放的是软件源站点, 当你执行 sudo apt-get install xxx 时,Ubuntu 就去这些站点下载软件包到本地并执行安装
|
||||
|
||||
二、相关命令使用示例:
|
||||
(1)查看某软件包的安装内容
|
||||
dpkg __-L __xxx
|
||||
|
||||
(2)查找软件库中的软件包
|
||||
apt-cache__ search__ 正则表达式
|
||||
|
||||
(3)显示系统安装包的统计信息
|
||||
apt-cache **stats**
|
||||
|
||||
(4)显示系统全部可用软件包的名称
|
||||
apt-cache pkgnames
|
||||
|
||||
(5)显示某软件包的详细信息
|
||||
apt-cache **show** xxx
|
||||
|
||||
(6)查找某文件属于哪个包
|
||||
apt-file search xxx
|
||||
|
||||
(7)查看已经安装了哪些软件包
|
||||
dpkg -l
|
||||
|
||||
(8)查询某软件依赖哪些软件包
|
||||
apt-cache depends xxx
|
||||
|
||||
(9)查询某软件被哪些软件包依赖
|
||||
apt-cache rdepends xxx
|
||||
|
||||
(10)增加一个光盘源
|
||||
sudo apt-cdrom add
|
||||
注: 顾名思义, 就是安装更新软件包时让其优先从Ubuntu 光盘上找(如果你不能上网安装/更新, 但有 Ubuntu 的 DVD ISO, 这会对你非常有用)
|
||||
|
||||
(11)系统升级
|
||||
sudo apt-get update
|
||||
|
||||
(12)清除所有已删除软件包的残馀配置文件
|
||||
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
|
||||
|
||||
(13)编译时缺少h文件的自动处理
|
||||
sudo **auto-apt run ./configure**
|
||||
|
||||
(14)查看安装软件时下载软件包的临时存放目录
|
||||
ls /var/cache/apt/archives
|
||||
|
||||
(15)备份当前系统安装的所有软件包的列表
|
||||
dpkg --get-selections | grep -v deinstall > ~/somefile
|
||||
|
||||
(16)从上面备份的安装包的列表文件恢复所有包
|
||||
dpkg --set-selections < ~/somefile
|
||||
sudo dselect
|
||||
|
||||
(17)清理旧版本的软件缓存
|
||||
sudo apt-get **autoclean**
|
||||
|
||||
(18)清理所有软件缓存
|
||||
sudo apt-get **clean**
|
||||
|
||||
(19)删除系统不再使用的孤立软件
|
||||
sudo apt-get **autoremove**
|
||||
|
||||
(20)查看软件包在服务器上面的地址
|
||||
apt-get -qq --print-uris install ssh | cut -d\' -f2
|
||||
269
Zim/Linux/dig_to_linux/包管理系统.txt
Normal file
269
Zim/Linux/dig_to_linux/包管理系统.txt
Normal file
@@ -0,0 +1,269 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2011-03-27T20:01:36+08:00
|
||||
|
||||
====== 包管理系统 ======
|
||||
Created Sunday 27 March 2011
|
||||
|
||||
在我们探秘之旅开始之前,了解自己系统上安装了哪些软件包、各个软件包的作用以及该软件包安装了哪些文件及目录是非常有用和重要的。以后的每一次探秘我都会用到这些命令以列出我的ubuntu 10.04系统上安装的相关软件包,这与你在自己的系统上实验时的结果可能不同。
|
||||
|
||||
现在的系统为何要用软件包管理系统呢?
|
||||
要回答这些问题,需要了解现在的软件开发都非常讲究可重用性,也就是说一个人写的功能代码可能会以库函数的形式发布供别人使用。
|
||||
最常用的就是glic函数库,它提供了常见的C语言标准库函数。由于这种代码的共享性,就造成成了软件之间的依赖关系即安装本软件前需要安装
|
||||
为其提供部分功能代码的其它软件。对于现在的很多软件这种依赖关系非常复杂,因为这种关系存在递归性和版本差别。为了解决这种复杂的依赖
|
||||
关系,现代的linux系统都提供了各种软件包管理机制,如REDHAT系列的基于RPM包管理,Debian的deb包管理等。
|
||||
|
||||
|
||||
这次探秘的是基于debian的包管理机制 ,对于RPM包管理机制,可以参考附件。Ubunt用到的软件包管理工具主要有两个:dpkg和apt
|
||||
|
||||
一、首先介绍DPKG
|
||||
|
||||
DPKG --- dpkg is a tool to install, build, remove and manage Debian packages.
|
||||
功能:
|
||||
1.安装、移除已下载到本地的软件包。
|
||||
2.查询、解包已经下载到本地的软件包。
|
||||
3.维护和保存已经安装到本地的软件包信息。
|
||||
总之,dpkg是一个底层的软件包管理系统,主要用于对已下载到本地和已安装的软件包进行管理.
|
||||
|
||||
(1)、最常用选项:
|
||||
|
||||
以下五个选项用于软件包的安装与移除
|
||||
-i package_file #安装软件包,必须是deb包的完整名称
|
||||
-r package #移除软件包,但保留其配置文件
|
||||
-P package #移除软件包的所有文件
|
||||
--unpack package_file #解开软件包到系统目录但不配置
|
||||
--configure package #配置软件包
|
||||
|
||||
以下四个选项用于查询已经安装到系统的软件包信息
|
||||
-l package-name-pattern #查看系统中软件包名符合pattern模式的软件包
|
||||
-L package-name #查看package-name对应的软件包安装的文件及目录
|
||||
-s package-name #查看package-name对应的软件包信息
|
||||
-S filename-search-pattern #从已经安装的软件包中查找包含filename的软件包名称
|
||||
|
||||
(2)、让我们做一些实验:
|
||||
|
||||
1、首先列出我的系统(ubuntu 10.04)上安装的与dpkg相关的软件包
|
||||
geekard@geekard-laptop:~$ dpkg -l \*dpkg*
|
||||
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|
||||
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
|
||||
||/ Name Version Description
|
||||
+++-=================================-=================================-==================================================================================
|
||||
ii dpkg 1.15.5.6ubuntu4.1 Debian package management system
|
||||
un dpkg-dev <none> (no description available)
|
||||
un dpkg-iasearch <none> (no description available)
|
||||
|
||||
以ii(install ok installed )开头表示Name对应的软件包已安装, 以un(unknown ok not-installed)开头表示没有安装 ,以rc开头的表示deinstall ok config-files即要重新安装。
|
||||
那些没有安装的软件包(以un开头)的信息是从已经安装的软件包的Recommends,Suggests 字段获得的。
|
||||
|
||||
2、查看已安装的dpkg软件包信息:
|
||||
geekard@geekard-laptop:~$ dpkg -s dpkg
|
||||
Package: dpkg
|
||||
Essential: yes
|
||||
Status: install ok installed #该软件包已经安装
|
||||
Priority: required
|
||||
Section: admin
|
||||
Installed-Size: 6608
|
||||
Origin: debian
|
||||
Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
|
||||
Bugs: debbugs://bugs.debian.org
|
||||
Architecture: i386
|
||||
Version: 1.15.5.6ubuntu4.1
|
||||
Replaces: manpages-de (<= 0.4-3), manpages-pl (<= 20051117-1) #该软件包将要替换的文件
|
||||
Pre-Depends: libc6 (>= 2.11), coreutils (>= 5.93-1), lzma #该软件包依赖的其它软件包及版本
|
||||
Suggests: apt #安装该软件包时建议同时安装的其它软件包
|
||||
Breaks: emacs21 (<< 21.4a+1-5.7), emacs21-nox (<< 21.4a+1-5.7), emacs22 (<= 22.2-0ubuntu2), emacs22-gtk (<= 22.2-0ubuntu2), emacs22-nox (<= 22.2-0ubuntu2), jed (<< 1:0.99.18+dfsg.1-13), jed-extra (<= 2.5.3-2), konqueror (<= 4:4.2.96-1), pinfo (<< 0.6.9-3.1), tkinfo (<< 2.8-3.1), xemacs21-support (<< 21.4.22-2), xjed (<< 1:0.99.18+dfsg.1-13)
|
||||
Conflicts: apt (<< 0.7.7), aptitude (<< 0.4.7-1), dpkg-dev (<< 1.14.16), dpkg-iasearch (<< 0.11), sysvinit (<< 2.82-1) #与该软件包相冲突的其它软件包
|
||||
Conffiles: #该软件包提供的配置文件(config files)及校验信息
|
||||
/etc/dpkg/dpkg.cfg f4413ffb515f8f753624ae3bb365b81b
|
||||
/etc/alternatives/README 69c4ba7f08363e998e0f2e244a04f881
|
||||
/etc/cron.daily/dpkg b6b8dc21210ea50db7cc4636f521758f
|
||||
/etc/logrotate.d/dpkg 9e25c8505966b5829785f34a548ae11f
|
||||
Description: Debian package management system #该软件包功能描述,从中可以看出为用于安装与卸载debian软件包的低级工具
|
||||
This package provides the low-level infrastructure for handling the
|
||||
installation and removal of Debian software packages.
|
||||
.
|
||||
For Debian package development tools, install dpkg-dev.
|
||||
Homepage: http://wiki.debian.org/Teams/Dpkg
|
||||
Original-Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
|
||||
geekard@geekard-laptop:~$
|
||||
|
||||
3、查看dpkg软件包安装到系统中的文件:
|
||||
geekard@geekard-laptop:~$ dpkg -L dpkg
|
||||
/.
|
||||
/etc
|
||||
/etc/dpkg #dpkg的配置目录
|
||||
/etc/dpkg/dpkg.cfg
|
||||
/etc/dpkg/dpkg.cfg.d
|
||||
/etc/alternatives
|
||||
/etc/alternatives/README
|
||||
。。。
|
||||
/usr/bin #dpkg相关命令
|
||||
/usr/bin/dpkg
|
||||
/usr/bin/dpkg-deb
|
||||
/usr/bin/dpkg-divert
|
||||
/usr/bin/dpkg-query
|
||||
/usr/bin/dpkg-split
|
||||
/usr/bin/dpkg-statoverride
|
||||
/usr/bin/dpkg-trigger
|
||||
/usr/bin/update-alternatives
|
||||
。。。
|
||||
/var
|
||||
/var/lib
|
||||
/var/lib/dpkg #dpkg用于存储已安装到本地的软件包信息的目录
|
||||
/var/lib/dpkg/alternatives
|
||||
/var/lib/dpkg/info
|
||||
/var/lib/dpkg/parts
|
||||
/var/lib/dpkg/updates
|
||||
。。。
|
||||
geekard@geekard-laptop:~$
|
||||
|
||||
4、dpkg软件包相关文件介绍(重点!):
|
||||
/etc/dpkg/dpkg.cfg #Configuration file with default options.
|
||||
/var/log/dpkg.log #Default log file (see /etc/dpkg/dpkg.cfg(5) and option --log).
|
||||
|
||||
/var/lib/dpkg/available 文件 #存放系统上曾经安装(包括现在)过的软件包信息。即使以后该软件包被卸载,这些信息仍然保留。这些信息就是dpkg -l pattern列出的内容。
|
||||
/var/lib/dpkg/status 文件 #存放系统上已经安装的软件的状态信息如标记为安装、卸载、重新安装等。
|
||||
/var/lib/dpkg/info 目录 #__非常重要__! 记录安装的软件包**控制目录中**的控制信息文件如 control 、. Conffiles , .preinst , .postinst , .prerm , .postrm , .list , .md5suns 等,用于后期软件包的**查询和移除**。
|
||||
例如:dpkg -r package-name 就是根据info目录中该软件包对应的控制信息文件来对其进行移除的。
|
||||
|
||||
available与status文件的差别就是前者记录所有安装过的(不管现在是否已经卸载)的信息而后者只记录已安装但没卸载的软件包信息。这也可以从两者记录的软件包数量上看出来,命令如下:
|
||||
geekard@geekard-laptop:~$ for file in /var/lib/dpkg/{available,status}
|
||||
> do
|
||||
> echo " packages in "${file}" file are : $(grep -w Package "${file}" | wc -l ) "
|
||||
> done
|
||||
输出为:
|
||||
packages in /var/lib/dpkg/available file are : 1597
|
||||
packages in /var/lib/dpkg/status file are : 1531
|
||||
|
||||
5、另外再提一下debian软件包中包含的内容及用途:
|
||||
debian软件包其实是以.deb为后缀的__归档文件__,其内容主要包括两方面:Package control data 和Upstream data,前者为软件包控制数据,dpkg就是根据这些文件来安装该软件包的,主要是一些脚本文件如:
|
||||
control 文本文件,提供该软件包的metadate也称“__元数据__”,通常为软件包的名称、版本、作者、依赖关系、架构、功能描述等内容
|
||||
conffiles 文本文件,即configure files的缩写,主要记录该软件包包含的**配置文件完整路径**
|
||||
preinst 脚本文件,pre install 即安装软件包前要做的工作,通常为**建立相关目录、检测系统环境**等
|
||||
postinst 脚本文件,post install即安装软件包后要做的工作,通常为**开启daemon,建立菜单项和快捷方式**等。
|
||||
prerm 脚本文件,pre remove,即在移除或重新安装该软件包前要做的工作
|
||||
postrm 脚本文件,post remove即在移除该软件包后要做的工作
|
||||
其它的就是Upstream data,即要安装到系统中的所有文件。这些文件可以通过双击deb软件包用package installer工具看到。
|
||||
|
||||
二、下面我们再来探秘一下ATP工具
|
||||
|
||||
APT --- a simple command line interface for downloading and installing packages.
|
||||
功能:
|
||||
1.从网络的软件源下载最新的软件包metadate(也就是各软件包的索引和摘要信息文件)和binary or source package .
|
||||
2.利用下载到本地的metadate,完成软件包的搜索、系统的更新。
|
||||
3.安装和移除软件包时自动寻找最新版本并自动解决依赖关系。
|
||||
总之,APT工具主要利用从网络软件源下载到的metadate完成软件包的搜索、下载、安装和移除,后两种功能是通过调用底层的dpkg完成的。
|
||||
|
||||
|
||||
(1)让我们看一下安装到系统上的相关软件包
|
||||
geekard@geekard-laptop:~$ dpkg -l \*apt* |grep ii
|
||||
ii apt 0.7.25.3ubuntu9.1 Advanced front-end for dpkg
|
||||
ii apt-utils 0.7.25.3ubuntu9.1 APT utility programs
|
||||
ii __aptitude __ 0.4.11.11-1ubuntu10 terminal-based package manager
|
||||
geekard@geekard-laptop:~$
|
||||
最重要的就是apt软件包,从描述信息:Advanced front-end for dpkg中可以看出其依赖于dpkg,是其前端工具.
|
||||
|
||||
(2)查看apt软件包的信息
|
||||
geekard@geekard-laptop:~$ dpkg -s apt
|
||||
Package: apt
|
||||
Status: install ok installed
|
||||
Priority: important
|
||||
Section: admin
|
||||
Installed-Size: 5460
|
||||
Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
|
||||
Architecture: i386
|
||||
Version: 0.7.25.3ubuntu9.1
|
||||
Replaces: libapt-pkg-dev (<< 0.3.7), libapt-pkg-doc (<< 0.3.7)
|
||||
Provides: libapt-pkg-libc6.10-6-4.8
|
||||
。。。。
|
||||
|
||||
让我们重点看一下相关目录及文件
|
||||
geekard@geekard-laptop:~$ dpkg -L apt
|
||||
/.
|
||||
/usr
|
||||
/usr/bin
|
||||
/usr/bin/**apt-cache**
|
||||
/usr/bin/apt-cdrom
|
||||
/usr/bin/apt-config
|
||||
/usr/bin/**apt-get ** #这个是搜索、安装、卸载软件包最常用到的命令
|
||||
/usr/bin/apt-key
|
||||
/usr/bin/apt-mark
|
||||
。。。。
|
||||
/etc/apt/preferences.d
|
||||
/etc/apt/sources #这个文件很重要,记录的是软件源的地址
|
||||
/etc/apt/sources.list.d
|
||||
/etc/apt/trusted.gpg.d
|
||||
。。。
|
||||
/var
|
||||
/var/cache
|
||||
/var/cache/apt
|
||||
/var/cache/apt/**archives ** #已经下载到的软件包都放在这里(用的是apt-get upgrade 命令),要定期清理否则会占用很大空间并有可能带来版本冲突问题。
|
||||
/var/cache/apt/archives/partial #这个是没有完全下载的软件包存放目录
|
||||
|
||||
/var/lib
|
||||
/var/lib/apt
|
||||
/var/lib/apt/__lists __ #这个目录很重要,里面存放的都是软件源的metadate,也就是用apt-get update 时下载的文件
|
||||
/var/lib/apt/lists/partial
|
||||
/var/lib/apt/mirrors
|
||||
/var/lib/apt/mirrors/partial
|
||||
/var/lib/apt/periodic
|
||||
|
||||
(3)下面谈一下我对系统更新和用新立得工具查找软件包原理的理解:
|
||||
/var/lib/apt/lists目录存放的是已经下载的各软件源的metadata,这些数据是系统更新和软件包查找工具的基础。
|
||||
Ubuntu Software Center 、Snaptic SoftwaresManager 和Update Manager等工具就是利用这些信息来更新和安装软件的。
|
||||
Ubuntu Software Center主要用于软件的安装、卸载和查询。其安装和卸载软件的信息来源是/var/lib/dpkg/states,查询软件的信息来源是/var/lib/apt/lists/ 。
|
||||
Snaptic Softwares Manager 的工作方式类似。
|
||||
Update Manager是系统更新工具,它是将系统已经安装的软件版本信息(存储在/var/lib/dpkg/states)与/var/lib/apt/lists/中同名的软件版本进行比较(比较Version字段),从而判断更新与否,然后将所有需要更新的软件在窗口中列出。
|
||||
|
||||
(4)让我们看一下向/etc/apt/source.list文件中添加软件源的方法,以我的配置为例:
|
||||
geekard@geekard-laptop:~$ sudo cat /etc/apt/sources.list |tail
|
||||
deb http://debian.ustc.edu.cn/ubuntu/ lucid main multiverse restricted universe
|
||||
deb http://debian.ustc.edu.cn/ubuntu/ lucid-backports main multiverse restricted universe
|
||||
deb http://debian.ustc.edu.cn/ubuntu/ lucid-proposed main multiverse restricted universe
|
||||
deb http://debian.ustc.edu.cn/ubuntu/ lucid-security main multiverse restricted universe
|
||||
deb http://debian.ustc.edu.cn/ubuntu/ lucid-updates main multiverse restricted universe
|
||||
deb-src http://debian.ustc.edu.cn/ubuntu/ lucid main multiverse restricted universe
|
||||
deb-src http://debian.ustc.edu.cn/ubuntu/ lucid-backports main multiverse restricted universe
|
||||
deb-src http://debian.ustc.edu.cn/ubuntu/ lucid-proposed main multiverse restricted universe
|
||||
deb-src http://debian.ustc.edu.cn/ubuntu/ lucid-security main multiverse restricted universe
|
||||
deb-src http://debian.ustc.edu.cn/ubuntu/ lucid-updates main multiverse restricted universe
|
||||
geekard@geekard-laptop:~$
|
||||
|
||||
ubuntu的软件源类型有4种分别为:
|
||||
main Canonical-support open source softs 即canoniacl公司(ubuntu幕后的开发团队)支持的开源软件
|
||||
multiverse 各开源社区支持的开源软件
|
||||
restricted 有专利限制的设备驱动软件(主要是显卡驱动)
|
||||
universe 有版权限制的软件(但个人在一定条件下可以自由使用)
|
||||
|
||||
ubuntu用于更新的软件源类型有4种分别为:
|
||||
security 重要的安全更新
|
||||
updates 建议的更新
|
||||
proposed pre-release updates
|
||||
backports unsupported updates
|
||||
|
||||
向source.list文件添加源的格式为:
|
||||
deb|deb-src http://path/to/ubuntu/ ubuntu发行版名称 | 发行版名称-更新的类型 软件源类型 ...
|
||||
|
||||
如 deb http://debian.ustc.edu.cn/ubuntu/ lucid-backports main multiverse restricted universe
|
||||
|
||||
当要下载源码包时需要添加源码源(以deb-src开头)。
|
||||
|
||||
(5)最后介绍一下apt常用的命令及选项:
|
||||
|
||||
Usage: apt-get [options] command
|
||||
apt-get [options] install|remove pkg1 [pkg2 ...]
|
||||
apt-get [options] source pkg1 [pkg2 ...]
|
||||
Commands:
|
||||
update - Retrieve new lists of packages #从源服务器上下载metadate到/var/lib/apt/lists目录中
|
||||
upgrade - Perform an upgrade #更新系统,下载的软件包放在/var/cache/apt/archives 目录中
|
||||
install - Install new packages (pkg is libc6 not libc6.deb) #安装软件包并自动解决依赖关系
|
||||
remove - Remove packages #卸载软件包
|
||||
purge - Remove packages and config files
|
||||
source - Download source archives #下载软件包的源代码,前提是source.lst文件中由deb-src开头的源
|
||||
clean - Erase downloaded archive files #清理软件包缓存即/var/cache/apt/archives 目录中的内容
|
||||
|
||||
好了,Ubuntu的包管理机制就是这些,相信你看了后会有些收获,有问题或不完善的地方希望大家跟贴!
|
||||
|
||||
另外,为了方便熟悉RPM包管理机制的童鞋向deb包管理机制转变,我将两者作了对比,限于篇幅故放在附件中,有兴趣的童鞋可以下载看看。
|
||||
|
||||
让我们挖掘linux的奥秘,享受技术带来的快乐!记住unix的哲学就是在探索中just have fun !
|
||||
Reference in New Issue
Block a user