一个空格引发“no such partition”错误
今天在使用grub2
时,才发现有空格和没空格有时是不一样的。请看下面这个例子:
grub> set root="(hd0, msdos3)"
grub> chainloader +1
error: no such partition
去掉hd0
和msdos3
之间的空格,一切OK
:
grub> set root="(hd0,msdos3)"
grub> chainloader +1
grub> boot
libvirt和virt-manager简介
SLES和SLES SP的区别
今天才知道SLES(SUSE Linux Enterprise Server)
和SLES SP(SUSE Linux Enterprise Server Service Package)
是不同的版本,SLES
相当于主版本(major version
),而SLES SP
则相当于基于主版本发布的小版本(minor version
)。参见wiki
百科:
SUSE Linux Enterprise Server (SLES) is a Linux-based operating system developed by SUSE. It is designed for servers, mainframes, and workstations but can be installed on desktop computers for testing as well. Major versions are released at an interval of 3–4 years, while minor versions (called “Service Packs”) are released about every 18 months. SUSE Linux Enterprise products, including SUSE Linux Enterprise Server, receive more intense testing than the openSUSE community product, with the intention that only mature, stable versions of the included components will make it through to the released enterprise product. SLES 11 SP4 was released July 16th, 2015, which is developed from a common code base with SUSE Linux Enterprise Desktop and other SUSE Linux Enterprise products.
查看SLES
发行版信息:
linux-6fj5:/ # cat /etc/issue
Welcome to SUSE Linux Enterprise Server 11 SP4 (x86_64) - Kernel \r (\l).
Linux kernel 笔记 (33)——“debugfs“简介
以下摘自维基百科:
debugfs is a simple to use RAM-based file system specially designed for debugging purposes. It exists as a simple way for kernel developers to make information available to user space. Unlike /proc, which is only meant for information about a process, or sysfs, which has strict one-value-per-file rules, debugfs has no rules at all. Developers can put any information they want there.
debugfs
是一个用于调试目的,简单的,基于内存的文件系统。kernel
的信息可以输出到debugfs
中,这样方便user space
程序查看和使用。
为了使用debugfs
功能,编译kernel
时需要把CONFIG_DEBUG_FS
置成yes
。
典型的挂载debugfs
文件系统命令:
mount -t debugfs none /sys/kernel/debug
由于没有具体设备,所以设备的位置使用了none
(参考这个帖子)
Lua笔记(24)—— tonumber和tostring
尽管Lua
会提供数字和字符串之间的自动转换:
> print("10" + 30)
40
> print(10 .. 30)
1030
为了使程序的可读性更好,可以考虑使用显示转换:
> print(tonumber("10") + 30)
40
> print(tostring(10) .. tostring(30))
1030
tonumber
把字符串转换为数字,而tostring
则把数字转换为字符串。
另外,把数字和空字符串连接起来,也可以达到tostring
的效果:
> print(type(10 .. ""))
string
Virtualization的几种解决方案
(1)Binary writing
Binary writing has the nice benefit that it allows most of the virtual environment to run in userspace, but imposes a performance penalty.
The binary rewriting approach requires that the instruction stream be scanned by the virtualization environment and privileged instructions identified. These are then rewritten to point to their emulated versions.
Binary writing
的核心之处在于把privileged instructions
重写。
(2)Paravirtualization
Rather than dealing with problematic instructions, paravirtualization systems like Xen simply ignore them.
If a guest system executes an instruction that doesn’t trap while inside a paravirtualized environment, then the guest has to deal with the consequences. Conceptually, this is similar to the binary rewriting approach, except that the rewriting happens at compile time (or design time), rather than at runtime.
The environment presented to a Xen guest is not quite the same as that of a real x86 system. It is sufficiently similar, however, in that it is usually a fairly simple task to port an operating system to Xen.
From the perspective of an operating system, the biggest difference is that it runs in ring 1 on a Xen system, instead of ring 0. This means that it cannot perform any privileged instructions. In order to provide similar functionality, the hypervisor exposes a set of hypercalls that correspond to the instructions.
Paravirtualization
核心之处在于hypervisor
提供hypercalls
给Guest OS
,以弥补其不能使用privileged instructions
。
(3)Hardware-Assisted Virtualization
Now, both Intel and AMD have added a set of instructions that makes virtualization considerably easier for x86. AMD introduced AMD-V, formerly known as Pacifica, whereas Intel’s extensions are known simply as (Intel) Virtualization Technology (IVT or VT). The idea behind these is to extend the x86 ISA to make up for the shortcomings in the existing instruction set. Conceptually, they can be thought of as adding a “ring -1” above ring 0, allowing the OS to stay where it expects to be and catching attempts to access the hardware directly. In implementation, more than one ring is added, but the important thing is that there is an extra privilege mode where a hypervisor can trap and emulate operations that would previously have silently failed.
IVT adds a new mode to the processor, called VMX. A hypervisor can run in VMX mode and be invisible to the operating system, running in ring 0. When the CPU is in VMX mode, it looks normal from the perspective of an unmodified OS. All instructions do what they would be expected to, from the perspective of the guest, and there are no unexpected failures as long as the hypervisor correctly performs the emulation.
A set of extra instructions is added that can be used by a process in VMX root mode. These instructions do things like allocating a memory page on which to store a full copy of the CPU state, start, and stop a VM. Finally, a set of bitmaps is defined indicating whether a particular interrupt, instruction, or exception should be passed to the virtual machine’s OS running in ring 0 or by the hypervisor running in VMX root mode.
Hardware-Assisted Virtualization
(也称之为HVM
,Hardware Virtual Machine
),可以运行unmodified OS
,其核心之处在于CPU
层面提供了新的privilege mode
和指令集来支持虚拟化。
Linux kernel 笔记 (32)——“make“和”make modules“
以下摘自LKD
:
After the kernel configuration is set—however you do it—you can build it with a single command:
$ make
Unlike kernels before 2.6, you no longer need to run make dep before building the kernel—the dependency tree is maintained automatically.You also do not need to specify a specific build type, such as bzImage, or build modules separately, as you did in old versions.The default Makefile rule will handle everything.
也就是在2.6
版本以后的Linux kernel
中,执行make
或make all
命令即包含了make modules
。也可参加这个帖子。
Linux kernel 笔记 (31)——“make help”命令
make help
命令列出编译kernel
时的选项帮助信息:
linux-4cy8:/usr/src/linux/build # make help
make -C /usr/src/linux-3.0.101-63 O=/usr/src/linux-3.0.101-63/build/. help
Cleaning targets:
clean - Remove most generated files but keep the config and
enough build support to build external modules
mrproper - Remove all generated files + config + various backup files
distclean - mrproper + remove editor backup and patch files
Configuration targets:
config - Update current config utilising a line-oriented program
nconfig - Update current config utilising a ncurses menu based program
menuconfig - Update current config utilising a menu based program
xconfig - Update current config utilising a QT based front-end
gconfig - Update current config utilising a GTK based front-end
oldconfig - Update current config utilising a provided .config as base
localmodconfig - Update current config disabling modules not loaded
localyesconfig - Update current config converting local mods to core
silentoldconfig - Same as oldconfig, but quietly, additionally update deps
defconfig - New config with default from ARCH supplied defconfig
savedefconfig - Save current config as ./defconfig (minimal config)
allnoconfig - New config where all options are answered with no
allyesconfig - New config where all options are accepted with yes
allmodconfig - New config selecting modules when possible
alldefconfig - New config with all symbols set to default
randconfig - New config with random answer to all options
listnewconfig - List new options
oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)
Other generic targets:
all - Build all targets marked with [*]
* vmlinux - Build the bare kernel
* modules - Build all modules
modules_install - Install all modules to INSTALL_MOD_PATH (default: /)
firmware_install- Install all firmware to INSTALL_FW_PATH
(default: $(INSTALL_MOD_PATH)/lib/firmware)
dir/ - Build all files in dir and below
dir/file.[oisS] - Build specified target only
dir/file.lst - Build specified mixed source/assembly target only
(requires a recent binutils and recent build (System.map))
dir/file.ko - Build module including final link
modules_prepare - Set up for building external modules
tags/TAGS - Generate tags file for editors
cscope - Generate cscope index
gtags - Generate GNU GLOBAL index
kernelrelease - Output the release version string
kernelversion - Output the version stored in Makefile
headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH
(default: /usr/src/linux-3.0.101-63/build/usr)
Static analysers
checkstack - Generate a list of stack hogs
namespacecheck - Name space analysis on compiled kernel
versioncheck - Sanity check on version.h usage
includecheck - Check for duplicate included header files
export_report - List the usages of all exported symbols
headers_check - Sanity check on exported headers
headerdep - Detect inclusion cycles in headers
coccicheck - Check with Coccinelle.
Kernel packaging:
rpm-pkg - Build both source and binary RPM kernel packages
binrpm-pkg - Build only the binary kernel package
deb-pkg - Build the kernel as an deb package
tar-pkg - Build the kernel as an uncompressed tarball
targz-pkg - Build the kernel as a gzip compressed tarball
tarbz2-pkg - Build the kernel as a bzip2 compressed tarball
tarxz-pkg - Build the kernel as a xz compressed tarball
perf-tar-src-pkg - Build perf-3.0.101.tar source tarball
perf-targz-src-pkg - Build perf-3.0.101.tar.gz source tarball
perf-tarbz2-src-pkg - Build perf-3.0.101.tar.bz2 source tarball
perf-tarxz-src-pkg - Build perf-3.0.101.tar.xz source tarball
Documentation targets:
Linux kernel internal documentation in different formats:
htmldocs - HTML
pdfdocs - PDF
psdocs - Postscript
xmldocs - XML DocBook
mandocs - man pages
installmandocs - install man pages generated by mandocs
cleandocs - clean all generated DocBook files
Architecture specific targets (x86):
* bzImage - Compressed kernel image (arch/x86/boot/bzImage)
install - Install kernel using
(your) ~/bin/installkernel or
(distribution) /sbin/installkernel or
install to $(INSTALL_PATH) and run lilo
fdimage - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)
fdimage144 - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)
fdimage288 - Create 2.8MB boot floppy image (arch/x86/boot/fdimage)
isoimage - Create a boot CD-ROM image (arch/x86/boot/image.iso)
bzdisk/fdimage*/isoimage also accept:
FDARGS="..." arguments for the booted kernel
FDINITRD=file initrd for the booted kernel
i386_defconfig - Build for i386
x86_64_defconfig - Build for x86_64
make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build
make V=2 [targets] 2 => give reason for rebuild of target
make O=dir [targets] Locate all output files in "dir", including .config
make C=1 [targets] Check all c source with $CHECK (sparse by default)
make C=2 [targets] Force check of all c source with $CHECK
make W=n [targets] Enable extra gcc checks, n=1,2,3 where
1: warnings which may be relevant and do not occur too often
2: warnings which occur quite often but may still be relevant
3: more obscure warnings, can most likely be ignored
Multiple levels can be combined with W=12 or W=123
make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections
Execute "make" or "make all" to build all targets marked with [*]
For further info see the ./README file
很有用!!
Xen结构简介
Xen
的虚拟化环境结构如下图所示:
Xen hypervisor
:直接运行在硬件上,它负责CPU
调度和为虚拟机划分内存。 Xen hypervisor
不光为运行之上的虚拟机抽象出硬件,还会控制虚拟机的运行。
Domain 0
:Xen hypervisor
启动的第一个,拥有特权的虚拟机:比如可以直接访问硬件,启动其它虚拟机等。
Domain U
:其它无特权的虚拟机,可以为PV
或HM Guest
。
以支持Xen
的Suse
为例,/boot/grub/menu.lst
文件如下:
title Xen -- SUSE Linux Enterprise Server 11 SP4 - 3.0.101-63
root (hd0,1)
kernel /boot/xen.gz vga=mode-0x314
module /boot/vmlinuz-3.0.101-63-xen root=/dev/disk/by-id/ata-VBOX_HARDDISK_VBe358a50a-9595120d-part2 resume=/dev/disk/by-id/ata-VBOX_HARDDISK_VBe358a50a-9595120d-part1 splash=silent showopts vga=0x314
module /boot/initrd-3.0.101-63-xen
可以看到,实际运行的kernel
是/boot/xen.gz
,修改过的kernel
(有-xen
后缀)和initial ramdisk
都是/boot/xen.gz
的模块。
参考资料:
How does Xen work?;