感觉到将grub装到mbr影响了我的电脑的启动速度,主要是主板自检吧! 出现logo好慢。
今天将mbr拷贝了出来,然后fdisk /mbr(M$ dos)按照M$的标准修复了mbr
启动快了, 然后用会nt的引导,又没破坏linux的引导! 重装系统也好恢复了!
下面的操作步骤!
首先起确认你的grub正常,并能启动linux, 然后启动到linux (Ubuntu)
如果你的是IDE硬盘
代码:
sudo dd if=/dev/hda of=/media/linux.lnx bs=512 count=1
如果你硬盘的被识别为SATA
代码:
sudo dd if=/dev/sda of=/media/linux.lnx bs=512 count=1
题外话:如果没有bs=512 count=1的话,dd好像跟ghost一样,不知道是不是哦,高手赐教
然后你可以到/media找到linux.lnx这个文件
将它cp到你的win根目录,例如是C:\,而且我建议你对这个文件做多个备份!
然后重启到win
进入后确认你的系统根目有linux.lnx这个文件
然后修改boot.ini
boot.ini请在win 下修改,因为编码不同! 大侠除外
它可能隐藏和只读,然后在后面加入
如果有 代码:
time=0
请将0更改!如time=5
代码:
C:\linux.lnx="linux"
保存
然后你就可以reboot看效果了
nt的引导菜单会出现linux这一项,选择后好像又会到grub的菜单了
事实上它只是读了linux.lnx
上面这个确认能进入linux后你就可以选者性的对mbr做M$的恢复了
win9x的引导盘是
代码:
fdisk /mbr
而nt就是用安装光盘或别的方法进入修复控制台
然后 代码:
fixmbr
这样你的mbr 就跟只装win的一样了!
如果你对win重装了只要做
拷尼备份的linux.lnx到win的根目录
并修改boot.ini (修改在前面已经有了)
这是dd的用法!
dd
1.作用
dd命令用来复制文件,并根据参数将数据转换和格式化。
2.格式
dd [options]
3.[opitions]主要参数
bs=字节:强迫 ibs=<字节>及obs=<字节>。
cbs=字节:每次转换指定的<字节>。
conv=关键字:根据以逗号分隔的关键字表示的方式来转换文件。
count=块数目:只复制指定<块数目>的输入数据。
ibs=字节:每次读取指定的<字节>。
if=文件:读取<文件>内容,而非标准输入的数据。
obs=字节:每次写入指定的<字节>。
of=文件:将数据写入<文件>,而不在标准输出显示。
seek=块数目:先略过以obs为单位的指定<块数目>的输出数据。
skip=块数目:先略过以ibs为单位的指定<块数目>的输入数据。
星期三, 五月 16, 2007
星期四, 五月 10, 2007
Configuring the GRUB Bootloader
GRUB is configured through the file /boot/grub/grub.conf; typical contents of this file look like this:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/main/root
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=5
splashimage=(hd0,1)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.31-1.3420_fc6)
root (hd0,1)
kernel /vmlinuz-2.6.31-1.3420_fc6 ro root=/dev/main/root rhgb quiet
initrd /initrd-2.6.31-1.3420_fc6.img
title Other
rootnoverify (hd0,0)
chainloader +1
--------------------------------------------------------------------------
This configuration file specifies two menu options, identified by the title keywords: Fedora Core and Windows (which Anaconda labels Other by default). Lines that start with a pound sign are comments. The first lines after the initial comments set up the appearance of the bootloader at startup time:
default= 0
Configures the first title enTRy as the default entry (they are numbered starting at 0)in this case, Fedora Core.
timeout= 5
Sets the delay in seconds before the default entry is booted.
splashimage=( hd0,1)/grub/splash.xpm.gz
Loads a graphical background for the boot display.
hiddenmenu
Does not display the boot menu unless the user presses a key during the timeout period, in which case all of the available operating system entries are shown.
The filename given in the splashimage line is in a special, GRUB-specific form: (hd0,1) specifies the first hard disk, second partition (/dev/hda2 in Linux terminology), and /grub/splash.xpm.gz identifies the pathname on that drive. Because /dev/hda1 is normally mounted on /boot, the full pathname within the Fedora system is /boot/grub/splash.xpm.gz.
*GRUB numbers partitions starting at 0, while Linux numbers them starting at 1.
--------------------------------------------------------------------------------
The remainder of this file configures the two menu options. The first one consists of these four lines:
title Fedora Core (2.6.31-1.3420_fc6 )
root (hd0,1)
kernel /vmlinuz-2.6.31-1.3420_fc6 ro root=/dev/main/root rhgb quiet
initrd /initrd-2.6.31-1.3420_fc6.img
Each line provides specific information:
title Fedora Core (2.6.31-1.3420_fc6)
The title displayed on the menu. The number in parentheses is the kernel version number; since it's standard practice to keep the second-most-recent kernel installed when the kernel is updated, just in case the new kernel does not boot properly, this information enables you to identify which kernel is newer.
root (hd0,1)
The root filesystem for the boot process, written using GRUB notation. Note that this may not be the root directory of the Fedora Core installation; it's usually the filesystem mounted at /boot when the system is running.
kernel /vmlinuz-2.6.31-1.3420_fc6 ro root=/dev/main/root rhgb quiet
The kernel location within the root filesystem, plus boot options. These boot options specify that the root filesystem for Linux is /dev/main/root (logical volume root in volume group main), and the root filesystem will be mounted read-only (ro), that the Red Hat Graphical Boot (rhgb) display is enabled, and that noncritical kernel boot messages will be suppressed (quiet).
initrd /initrd-2.6.31-1.3420_fc6.img
The location of the initrd ramdisk file. This file contains a compressed filesystem image that contains all of the files other than the kernel necessary for the initial phases of the Fedora system startup, including device drivers, programs, and scripts.
The other title entry is simpler:
title Other
rootnoverify (hd0,0)
chainloader +1
The lines in this entry invoke the Windows Stage 2 bootloader, found at the start of the Windows partition:
rootnoverify (hd0,0)
Similar to the root option in the Fedora Core entry, except that this partition will not be mounted, and therefore files cannot be accessed within the partition by GRUB.
chainloader +1
Specifies that the boot process should be turned over to the bootloader found in sector 1 of the partition.
The Grub manual: http://www.gnu.org/software/grub/manual/
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/main/root
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=5
splashimage=(hd0,1)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.31-1.3420_fc6)
root (hd0,1)
kernel /vmlinuz-2.6.31-1.3420_fc6 ro root=/dev/main/root rhgb quiet
initrd /initrd-2.6.31-1.3420_fc6.img
title Other
rootnoverify (hd0,0)
chainloader +1
--------------------------------------------------------------------------
This configuration file specifies two menu options, identified by the title keywords: Fedora Core and Windows (which Anaconda labels Other by default). Lines that start with a pound sign are comments. The first lines after the initial comments set up the appearance of the bootloader at startup time:
default= 0
Configures the first title enTRy as the default entry (they are numbered starting at 0)in this case, Fedora Core.
timeout= 5
Sets the delay in seconds before the default entry is booted.
splashimage=( hd0,1)/grub/splash.xpm.gz
Loads a graphical background for the boot display.
hiddenmenu
Does not display the boot menu unless the user presses a key during the timeout period, in which case all of the available operating system entries are shown.
The filename given in the splashimage line is in a special, GRUB-specific form: (hd0,1) specifies the first hard disk, second partition (/dev/hda2 in Linux terminology), and /grub/splash.xpm.gz identifies the pathname on that drive. Because /dev/hda1 is normally mounted on /boot, the full pathname within the Fedora system is /boot/grub/splash.xpm.gz.
*GRUB numbers partitions starting at 0, while Linux numbers them starting at 1.
--------------------------------------------------------------------------------
The remainder of this file configures the two menu options. The first one consists of these four lines:
title Fedora Core (2.6.31-1.3420_fc6 )
root (hd0,1)
kernel /vmlinuz-2.6.31-1.3420_fc6 ro root=/dev/main/root rhgb quiet
initrd /initrd-2.6.31-1.3420_fc6.img
Each line provides specific information:
title Fedora Core (2.6.31-1.3420_fc6)
The title displayed on the menu. The number in parentheses is the kernel version number; since it's standard practice to keep the second-most-recent kernel installed when the kernel is updated, just in case the new kernel does not boot properly, this information enables you to identify which kernel is newer.
root (hd0,1)
The root filesystem for the boot process, written using GRUB notation. Note that this may not be the root directory of the Fedora Core installation; it's usually the filesystem mounted at /boot when the system is running.
kernel /vmlinuz-2.6.31-1.3420_fc6 ro root=/dev/main/root rhgb quiet
The kernel location within the root filesystem, plus boot options. These boot options specify that the root filesystem for Linux is /dev/main/root (logical volume root in volume group main), and the root filesystem will be mounted read-only (ro), that the Red Hat Graphical Boot (rhgb) display is enabled, and that noncritical kernel boot messages will be suppressed (quiet).
initrd /initrd-2.6.31-1.3420_fc6.img
The location of the initrd ramdisk file. This file contains a compressed filesystem image that contains all of the files other than the kernel necessary for the initial phases of the Fedora system startup, including device drivers, programs, and scripts.
The other title entry is simpler:
title Other
rootnoverify (hd0,0)
chainloader +1
The lines in this entry invoke the Windows Stage 2 bootloader, found at the start of the Windows partition:
rootnoverify (hd0,0)
Similar to the root option in the Fedora Core entry, except that this partition will not be mounted, and therefore files cannot be accessed within the partition by GRUB.
chainloader +1
Specifies that the boot process should be turned over to the bootloader found in sector 1 of the partition.
The Grub manual: http://www.gnu.org/software/grub/manual/
星期三, 五月 02, 2007
PHP与MySQL开发中页面乱码的产生与解决
一般来说,乱码的出现有2种原因,首先是由于编码(charset)设置错误,导致浏览器以错误的编码来解析,从而出现了满屏乱七八糟的“天书”,其次是文件被以错误的编码打开,然后保存,比如一个文本文件原先是GB2312编码的,却以UTF-8编码打开再保存。要解决上述乱码问题,首先需要知道开发中哪些环节涉及到了编码:
1、文件编码:指的是页面文件(.html,.php等)本身是以何种编码来保存的。记事本和Dreamweaver在打开页面时候会自动识别文件编码因而不太会出问题。而ZendStudio却不会自动识别编码,它只会根据首选项的配置固定以某种编码打开文件,如果工作时候一不注意,用错误编码打开文件,做了修改之后一保存,乱码就出现了(我深有体会)。
2、页面申明编码:在HTML代码HEAD里面,可以用 <meta http-equiv="Content-Type" content="text/html; charset="XXX" />来告诉浏览器网页采用了什么编码,目前中文网站开发中XXX主要用的是GB2312和UTF-8两种编码。
3、数据库连接编码:指的是进行数据库操作时候以哪种编码与数据库传输数据,这里需要注意的是不要与数据库本身的编码混淆,比如MySQL内部默认是latin1编码,也就是说Mysql是以latin1编码来存储数据,以其他编码传输给Mysql的数据会被转换成latin1编码。
知道了WEB开发中哪些地方涉及到了编码,也就知道了乱码产生的原因:上述3项编码设置不一致,由于各种编码绝大部分是兼容ASCII的,所以英文符号不会出现,中文就倒霉了。下面是一些常见的错误情况与解决:
1、数据库采用UTF8编码,而页面申明编码是GB2312,这是最常见的产生乱码的原因。这时候在PHP脚本里面直接SELECT数据出来的就是乱码,需要在查询前先使用:
mysql_query("SET NAMES GBK");
来设定MYSQL连接编码,保证页面申明编码与这里设定的连接编码一致(GBK是GB2312的扩展)。如果页面是UTF-8编码的话,可以用:
mysql_query("SET NAMES UTF8");
注意是UTF8而不是一般用的UTF-8。假如页面申明的编码与数据库内部编码一致可以不设定连接编码。
注:事实上MYSQL的数据输入输出比上面讲的更复杂一些,MYSQL配置文件my.ini中定义了2个默认编码,分别是[client]里的default-character-set和[mysqld]里的default-character-set来分别设定默认时候客户端连接和数据库内部所采用的编码。我们上面指定的编码其实是MYSQL客户端连接服务器时候的命令行参数character_set_client,来告诉MYSQL服务器接受到的客户端数据是什么编码的,而不是采用默认编码。
2、页面申明编码与文件本身编码不一致,这种情况很少发生,因为如果编码不一致美工做页面时候在浏览器看到的就是乱码了。更多时候是发布以后修改一些小BUG,以错误编码打开页面然后保存导致的。或者是用某些FTP软件直接在线修改文件,比如CuteFTP,由于软件编码配置错误而导致转换错了编码。
3、一些租用虚拟主机的朋友,明明上述3项编码都设置正确了还是有乱码。比方说网页是GB2312编码的,IE等浏览器打开却总是识别成UTF-8,网页HEAD里面已经申明是GB2312了,手动修改浏览器编码为GB2312后页面显示正常。产生原因是服务器Apache设定了服务器全局的默认编码,在httpd.conf里面加了AddDefaultCharset UTF-8。这时候服务器会首先发送HTTP头给浏览器,其优先级比页面里申明编码高,自然浏览器就识别错了。解决办法有2个,请管理员在配置文件自己的虚机里加上一条AddDefaultCharset GB2312来覆盖全局配置,或者在自己目录的.htaccess里配置。
1、文件编码:指的是页面文件(.html,.php等)本身是以何种编码来保存的。记事本和Dreamweaver在打开页面时候会自动识别文件编码因而不太会出问题。而ZendStudio却不会自动识别编码,它只会根据首选项的配置固定以某种编码打开文件,如果工作时候一不注意,用错误编码打开文件,做了修改之后一保存,乱码就出现了(我深有体会)。
2、页面申明编码:在HTML代码HEAD里面,可以用 <meta http-equiv="Content-Type" content="text/html; charset="XXX" />来告诉浏览器网页采用了什么编码,目前中文网站开发中XXX主要用的是GB2312和UTF-8两种编码。
3、数据库连接编码:指的是进行数据库操作时候以哪种编码与数据库传输数据,这里需要注意的是不要与数据库本身的编码混淆,比如MySQL内部默认是latin1编码,也就是说Mysql是以latin1编码来存储数据,以其他编码传输给Mysql的数据会被转换成latin1编码。
知道了WEB开发中哪些地方涉及到了编码,也就知道了乱码产生的原因:上述3项编码设置不一致,由于各种编码绝大部分是兼容ASCII的,所以英文符号不会出现,中文就倒霉了。下面是一些常见的错误情况与解决:
1、数据库采用UTF8编码,而页面申明编码是GB2312,这是最常见的产生乱码的原因。这时候在PHP脚本里面直接SELECT数据出来的就是乱码,需要在查询前先使用:
mysql_query("SET NAMES GBK");
来设定MYSQL连接编码,保证页面申明编码与这里设定的连接编码一致(GBK是GB2312的扩展)。如果页面是UTF-8编码的话,可以用:
mysql_query("SET NAMES UTF8");
注意是UTF8而不是一般用的UTF-8。假如页面申明的编码与数据库内部编码一致可以不设定连接编码。
注:事实上MYSQL的数据输入输出比上面讲的更复杂一些,MYSQL配置文件my.ini中定义了2个默认编码,分别是[client]里的default-character-set和[mysqld]里的default-character-set来分别设定默认时候客户端连接和数据库内部所采用的编码。我们上面指定的编码其实是MYSQL客户端连接服务器时候的命令行参数character_set_client,来告诉MYSQL服务器接受到的客户端数据是什么编码的,而不是采用默认编码。
2、页面申明编码与文件本身编码不一致,这种情况很少发生,因为如果编码不一致美工做页面时候在浏览器看到的就是乱码了。更多时候是发布以后修改一些小BUG,以错误编码打开页面然后保存导致的。或者是用某些FTP软件直接在线修改文件,比如CuteFTP,由于软件编码配置错误而导致转换错了编码。
3、一些租用虚拟主机的朋友,明明上述3项编码都设置正确了还是有乱码。比方说网页是GB2312编码的,IE等浏览器打开却总是识别成UTF-8,网页HEAD里面已经申明是GB2312了,手动修改浏览器编码为GB2312后页面显示正常。产生原因是服务器Apache设定了服务器全局的默认编码,在httpd.conf里面加了AddDefaultCharset UTF-8。这时候服务器会首先发送HTTP头给浏览器,其优先级比页面里申明编码高,自然浏览器就识别错了。解决办法有2个,请管理员在配置文件自己的虚机里加上一条AddDefaultCharset GB2312来覆盖全局配置,或者在自己目录的.htaccess里配置。