Archive

Author Archive

Grub 2 Configuration

October 14th, 2012 No comments

Grub 2 Configuration
Grub 2 的配置文件是位于 /boot/grub/ 目录下的 grub.cfg。与 Grub Legacy 不同的是,这个 grub.cfg 文件是不建议手动修改的。它是在安装或者更新 Grub 2 的时候自动生成的。如果要修改或者定制 grub.cfg 文件,则需要在两个地方进行修改,然后重新运行 grubmkconfig 的命令来生成新的 grub.cfg 文件。

两处需要修改的地方分别是: 1) /etc/default/ 目录下的 grub 文件和 2) /etc/grub.d/ 目录下的若干文件。

/etc/default/grub
先说一下 /etc/default/grub 文件。用文本编辑器打开这个文件,会看到如下相似的内容:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
 
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_LINUX_RECOVERY="true"

# Uncomment to get a beep at grub start
# GRUB_INIT_TUNE="480 440 1"

在这里解释一下该文件里几个常用的命令。

GRUB_DEFAULT=0

这个命令指定缺省的可引导的操作系统。数字“0”表示在操作系统列表中的第一个操作系统将是缺省引导的操作系统。如果你想要把列表中的第四个操作系统作为缺省引导的系统,就把“0”改成“3”。剩下的以此类推。

#GRUB_HIDDEN_TIMEOUT=0

这个命令控制是否在计算机启动时显示操作系统列表。如果把“#”号去掉的话,在计算机启动的时候就不会显示可引导操作系统的列表。

GRUB_TIMEOUT=10

这个命令设置在计算机启动时 Grub2 在引导缺省操作系统前等待的时间(以秒为单位)。在这个时间里用户可以用键盘方向键选择不同的操作系统来进行引导。

GRUB_HIDDEN_TIMEOUT_QUIET=true

这个命令控制是否在计算机启动是显示时间倒计时(即用户还有多少时间进行选择)。如果设置为“true”则不会显示时间倒计时,如果设置为“false”则会显示时间倒计时。

/etc/grub.d/ 目录下的文件
再说一下 /etc/grub.d/ 目录下的几个文件。这些文件都是可执行文件,它们的命名方式为: nn_xxxxxx,其中 nn 是两位数的整数,xxxxxx 是任意字母、数字和有效字符的组合,如下所示:

00_header
05_debian_theme
10_linux
20_memtest
30_os-prober
40_custom

在更新 Grub 2 的时候,这些文件会按照 nn 从小到大的顺序被先后执行,执行的结果被写入 grub.cfg 文件。需要说明的一点就是 grub.cfg 里的可引导操作系统是按照这些文件被执行的先后顺序来写入文件的。如果你想把自己常用的操作系统放在列表最上面的话就需要自己建一个文件,文件名和上面提到的文件名类似,不过 nn 需要介于 “05” 和 “10” 之间,比如说可以命名为 06_custom。然后我们就可以编辑这个 06_custom 文件来让 Grub 2 加入我们自己的操作系统。

下面以加入引导 Windows 7 为例来说明如何编辑 06_custom 文件。Windows 7 用的是 chainloader type boot entry。下面的代码会在更新 Grub 2 的时候在列表最上面加入一个 “Windows 7” 的引导项。

#! /bin/sh -e
echo "Adding custom boot entry(s)" >&2
cat << EOF
menuentry "Windows 7" {
    set root=(hd0,1)
    chainloader +1   
}
EOF

需要注意的是下面这个命令:

set root=(hd0,1)

(hd0,1) 指的是安装了 Windows 7 的硬盘和分区。这个信息一定要正确,不然的话 Grub 2 引导 Windows 7 的时候会出错。这个信息可以在 Linux 下面用 fdisk -l 命令找出来。

编辑完 06_custom 文件后还需要把它变成可执行文件:

chmod 755 06_custom

如果需要删除 Grub 2 引导列表中的项目,则只需要简单地把 nn_xxxxxx 文件的可执行属性去掉。例如我们不想生成 memtest 项目,用下面的命令把 20_memtest 变成不可执行就行了:

chmod -x 20_memtest

生成新的 /boot/grub/grub.cfg 文件
在修改完上面提到的 /etc/default/grub 文件和 /etc/grub.d/ 下面的文件后,可以用下面这个命令来生成新的 grub.cfg 文件:

grub-mkconfig -o /boot/grub/grub.cfg

Reference
GRUB2 Configuration.

Categories: Linux Tags:

Embed Video in PowerPoint with Relative Path

October 5th, 2012 No comments

A very useful tip that I found in this post. Here is the quote:

Seems like relative paths are supported, they are just not straightforward to implement. For example if your Powerpoint presentation is in the MyFiles folder, and the MyMovie.avi is in the Media folder inside MyFiles. The trick is to edit the xml files inside the Powerpoint file:

  • Make a copy of your presentation as Presentation.pptx (just to keep the original safe).
  • Rename your Presentation.pptx file into Presentation.pptx.zip.
  • Open the resulting zip file by clicking on it. It will open as a folder. Inside it, go to ppt, then slides, then _rels. You will see files called slide1.xml.rels etc.
  • Copy (drag and drop) all those to another place, outside the archive. Now open the file corresponding to the number of your slide with video with some editor (for example, Notepad). Look for the line that says something like: Target=”file:///C:\MyFiles\Media\MyMovie.avi”. If your Powerpoint presentation is in the MyFiles folder, and the MyMovie.avi is in the Media folder inside MyFiles, then change the above line to: Target=”Media\MyMovie.avi”.
  • Save the slide1.xml.rels file (or whatever number it was), then drag it back to that archive (that is actually a Powerpoint file), and then rename the archive back to Presentation.pptx.

This is it. Now you should be able to carry around the folder MyFiles with the presentation and with the Media folder inside it that contains your video.

Works for me on Windows 7.

Categories: Tips and Tricks Tags:

MSDN镜像

July 14th, 2012 No comments
Categories: Uncategorized Tags:

Trendnet KVM and VMWare Problem

July 7th, 2012 2 comments

I have a Trendnet TK-207K 2 port USB KVM attached to two computers, one of which has VMWare Workstation on Windows 7. When I am running the VMWare Workstation, the Trendnet kvm suddenly switches to the next machine. It is as if I hit scroll-lock twice to go to the next machine, but I didn’t. Then I have to manually press the button on the top of the kvm and wait for about 20 seconds for it to be re-recognized by the computer running VMWare. Very annoying!

I think the reason why this is happening is: when I’m using VM workstation and I set a num or caps lock status inside a VM and then leave the VM, my Num or Caps goes off and then goes on again when I enter the VM. So something is happening when the VM enters the virtual machine to set the Num and Caps lock, and I’d assume, the Scroll lock status too. If this is done by VM workstation manipulating the keyboard buffer it might literally be “as if you hit scroll lock twice”

The solution I found: first thing, make sure you have installed the VMware tools in your image. If you use the Num Lock, Caps Lock or Scroll Lock make sure they are both set the same on your host computer and your VMware image. For the VMWare image, when the virtual machine boots up, hit F2 to enter BIOS to set the key status.

Categories: Tips and Tricks Tags:

Enable or Disable Quick Launch Toolbar in Windows 7

July 1st, 2012 No comments

This post from Windows 7 Forum has good instructions on how to enable or disable the quick launch tool bar in Windows 7: Enable or Disable Windows 7 Quick Launch Toolbar.

Here is a screenshot:

Enable or Disable Quick Launch Toolbar in Windows 7

Categories: Tips and Tricks, Windows Tags:

Create a Windows 7 Installation USB Flash Drive

July 1st, 2012 No comments

This post from Windows 7 Forum has good instructions on how to manually create a Windows 7 installation USB flash drive: Create a Windows 7 Installation USB Flash Drive. I tried Option Two from the post and it worked well.

Here is a screenshot:

Create a Windows 7 Installation USB Flash Drive

Categories: Tips and Tricks, Windows Tags:

Comm Failure Error on TS40B Wall Display

June 16th, 2012 5 comments

I have got a “Comm Failure” error on my AC control panel. The control panel is a Ztech TS40B wall display panel. The symptoms and the solution were found in the following forum thread: Receiving “Comm Failure” message, no heat.

Here is the quote from that thread:

Symptoms

I have a TS40B Wall Model Thermostat from Beutler. Right now my aircondition/heating wall display is showing ‘comm failure’. Can anyone tell me what this is and how to reset? Right now, nothing is working, Heat, Fan, SmartVent…I would be thankful for any insights.

I was able to find the User manual online, and it makes reference to “Hold Settings”, which was the last button to the right. Which is now no longer there or even indicating its available. The system shows it’s off, with no option of turning it back on to “run” or “hold”.

Solution

Update: Note to all who may run into this issue with their own TS40B Wall Model Thermostat. Turn all of the power off, flip your main breakers. Initially, I tried just flipping the breakers for the HVAC, but nothing changed. I decided to flip the main breakers; everything came back online exactly as it was before.

Categories: Uncategorized Tags:

刷主板BIOS激活OEM Windows 7

November 27th, 2011 No comments

我最近新组装了一台电脑用来做工程计算,配置如下:

  • CPU: Intel i7-2600
  • Motherboard: Asus P8Z68-V Pro
  • Memory: G-Skill RipJaws DDR3-1600 4GB x 4
  • Graphics Card: Sapphire HD 6870 1GB GDDR5
  • HDD: Intel 320 Solid State Drive 120GB x 1
  • HDD: Samsung F3 HDD 1TB x 2

我在电脑上安装了Windows 7旗舰版。本来我自己有正版的Windows 7旗舰版序列号(以前买的打折的教育版),但是本着生命在于折腾的精神我决定试试用刷主板BIOS来激活OEM Windows 7的方法。

用刷主板BIOS的方法激活OEM Windows 7需要以下三个条件:

  1. 主板BIOS里面包含有效的SLIC2.1表。
  2. Windows 7里面导入了OEM厂商的认证证书。
  3. Windows 7里面导入了对应其版本的正确的序列号。

以上三个条件中,第一个条件是最基本但是也是最麻烦的一步。第二个和第三个条件反而比较好满足。网上搜索一下能够找到很多有效的OEM证书和序列号(有兴趣的朋友可以去BIOS之家论坛看看)。

我在BIOS之家论坛里学习了一段时间,然后找到网友放出的Asus P8Z68-V Pro的带SLIC2.1的BIOS(没办法,自己不会做只好用别人的了),一咬牙就刷进自己的主板。怀着忐忑的心情重启计算机,哈哈,能够启动,没有发生论坛里很多网友提到的黑屏。于是进BIOS重新设置一番,然后再重启。进入Windows后运行SLIC_ToolKit进行检测,发现读出的BIOS里面包含了有效的SLIC2.1表信息。

下一步是导入OEM证书。以管理员身份运行Command Prompt,然后输入以下命令:

slmgr.vbs -ilc C:\xxxx.XRM-MS

上述命令中的C:\xxxx.XRM-MS就是从网上下载的证书文件。这个命令执行需要一些时间,完成之后会弹出窗口告诉你OEM证书已成功导入Windows。

最后需要导入对应的Windows版本的OEM序列号。跟上一步一样,以管理员身份运行Command Prompt,然后输入以下命令:

slmgr.vbs -ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

将上述命令中的XXXXX-XXXXX-XXXXX-XXXXX-XXXXX以正确的序列号代替。这个命令执行需要一些时间,完成之后会弹出窗口告诉你序列号已成功导入Windows。

以上三步做完之后重启计算机。进入Windows后打开Windows Explorer,然后在Computer上右击选择Properties。如果一切顺利的话Windows 7就应该已经自动激活了。

需要说明一下的是,计算机OEM厂商很多,大家比较熟悉的就有Dell、HP、Asus、Acer、联想等等。在上面所说的三个条件中,SLIC2.1表、OEM证书和Windows 7序列号必须对应同一个OEM。比如如果主板BIOS里面的SLIC2.1是对应Dell的,那么你必须使用Dell的证书和用于安装Dell电脑的Windows 7序列号,不然的话Windows 7无法成功激活。

Categories: Tips and Tricks, Windows Tags:

Manually Access Dell Laptop Factory Recovery Image

October 30th, 2011 No comments

I recently purchased a new Dell XPS laptop. When I was trying installing and uninstalling some software I messed up the system. So I wanted to restore the laptop to the factory settings. The Dell XPS laptop came with a hidden partition used for recover. However, for some reason, I couldn’t find “Restore PC to Factory Settings” option in “Advanced Boot Options” during the bootup. I know the factory recovery image is still there because I didn’t mess with the hidden recovery partition. I thought there must be a way to access and use that factory recovery image to restore the laptop to the factory settings. I was right but it took me a long time doing research. And I finally figured out how to do it.

Here are the things needed for my method to work:

  • Dell factory restore partition untouched. This means the factory recovery image is still there and in a good shape. If you have deleted the restore partition then you need find other methods to restore your system.
  • A tool called ImageX. We will use this tool to deploy the Dell factory recovery image to restore the laptop. ImageX can be found in Windows Automated Installation Kit (WAIK) which can be downloaded from Microsoft website. See this O’Reilly article for more information on ImageX.
  • A bootable CD/DVD that can boot into a Win32 pre-installation environment. Note that a pure DOS bootdisk won’t work here since pure DOS cannot access NTFS partitions. I built a BartPE bootable CD for this. I also put the ImageX tool that I obtained from WAIK on this bootable CD.

Once you have the above-mentioned items, start your laptop and boot it from the BartPE CD. When you are in the BartPE environment, run Command Prompt. Locate the file name factory.wim on the recovery partition. Make a note of the drive letter and path to that file. On my XPS laptop it is located in D:\Dell\Image\Factory.wim. Now change to the directory where ImageX is and type this command:

ImageX /apply d:\dell\image\factory.wim 1 c:\

Wait for the command to finish (it takes about 25 ~ 30 minutes). Once done, reboot your laptop from its hard drive. The laptop should have been restored to its factory settings and you are good to go.

References

  1. Post by JackShack in this Dell forum thread: Want to do a recovery.
  2. Restoring from restore partition without Ctrl+F11 nor restore disks.
  3. Free, Bootable Disaster Recovery in Vista.
  4. Bart’s Preinstalled Environment (BartPE) bootable live windows CD/DVD.
Categories: Tips and Tricks Tags:

XFOIL Study Notes (3)

September 29th, 2011 No comments

Workflow

The typical workflow of airfoil analysis using XFOIL is: Run XFOIL -> Load Airfoil Shape (using LOAD command or NACA command) -> Run Analysis (using OPER command) -> Plot results (using PPLO command).

Categories: Engineering Tags: