2010年4月9日 星期五

使用 ping 指令,出現錯誤訊息:bad option specified

今天在使用 PING 127.0.0.1 或 any IP address 都出現「bad option specified」的錯誤訊息


一般來說會出現這個問題是因為相關網路設備或軟體的 TTL 設定值錯誤所造成的,被設定成 > 255,此時是否針對 ping 的對象(目的地)進行檢查,以上面的例子來說,是 ping 本機,因此就從本機的 Windows 設定著手。

Windows 95/98/Me
找到:HKEY_LOCAL_MACHINESystemCurrentControlSetServicesVxDMSTCP
修改:DefaultTTL
資料型態:REG_SZ (字串)(1-255 十進位,預設值:64)

Windows 2000/XP/2003
找到:HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters
修改:DefaultTTL
資料型態:REG_DWORD (1-255 十進位,預設值:128)

How to add your own splashimage to GRUB2 (4)

There's nothing much to it really, you can use just about any photo, drawing or digital artwork.
You can use a picture of your favorite girl / boy / dog / cat / horse / car / motorbike / truck / boat / airplane, the biggest fish you ever caught, your company's logo, almost anything you like.

  1) First, right-click on the image file and click 'properties', or open the image with Image Viewer and find out how many pixels it has.  

  2) For best results you should try to choose an image file that will match the shape of your monitor.
For example, if your monitor is 1050x780 pixels, that's about 3/4 as high as it is wide.
If you want your image to fill the whole screen and you don't want part of it cut off, you need to use an image that's about 3/4 as high as it is wide, so it will fit your monitor properly.

 3) Also see How To Change Boot Menu Resolution 

 TIP: If you really want to use an image that doesn't fit, first make a copy of it.
 Never alter your original image because you won't be able to reverse the changes ones they've been saved.
 Open the copy of your image with GIMP image editor in Ubuntu. 
 Crop and/or resize the copy of your image to make it fit your monitor if you need to.

  4) Currently GRUB 2 supports three image formats, they are: .png, .tga and .jpg.
 Everyone should be able to use the .png and .tge images without any problems. If you want to use a .jpg image you can, but you probably need to use the insmod command to insert the module for that first.
The module for that is called jpeg.mod, see the insmod command.
You'll need to add the insmod command to your grub.cfg by editing /etc/grub.d/05_debian_theme.
While you have that file open you'll probably need to add '.jpg' as an image format in line 16 or 17 too.
 If you don't want to do it that way, the alternative is to convert the image to .png or .tga. You can do that by opening your image in GIMP and clicking 'save as', and type a file name of your choice with a .png or .tga filename extension after it. That will make a copy of your image in the format you want.

  5) Copy your image file to your /boot/grub/ directory,

sudo cp myimage.png /boot/grub/
Where: 'myimage' is replaced with the file name of your own image file.

  6) To get your new splashimage to appear, you need to edit a file called /etc/grub/ 05_debian_theme.
gksudo gedit /etc/grub.d/05_debian_theme

  7) scroll down in the file until you find line 16 or 17

  8) change the following code from:
 for i in {/boot/grub,/usr/share/images/desktop-base}/moreblue-orbit-grub.{png,tga} ; do

 to replace 'moreblue-orbit-grub' with the name of your own splashimage)
 for i in {/boot/grub,/usr/share/images/desktop-base}/myimage.{png,tga} ; do
       NOTE: Be careful to keep the dot in the filename! eg: 'myimage.'

  Save and close the file.

  9) Run grub-mkconfig (Karmic Koala), or update-grub (in earlier versions of Ubuntu), to write the changes to grub-conf,
sudo grub-mkconfig -o /boot/grub/grub.cfg

10) That's it! All done! Now you can reboot and see how it looks!

How To Change Boot Menu Resolution in GRUB2 (3)

If you want to use a splashimage with more pixels than 640x480,  you can set the display resolution higher in GRUB 2.

That will give you a better quality picture and  your fonts will appear smaller so you'll be able to see a lot more of your boot entries on the screen without scrolling so much.

 1. If you don't already know what resolutions your video hardware can support, you can boot GRUB2 and press 'C' fro your GRUB Menu to go into into CLI Mode GRUB . Then you can run the vbeinfo command for a list of resolutions your hardware can support. Press your pause key if you need more time to read the text.

 2. Write the numbers down on a piece of scrap paper if you need to.

 3. Open your  /etc/default/grub file with a text editor and change your settings there

gksudo gedit /etc/default/grub

 4. Alter the numbers after where it says"GRUB_GFXMODE=" with a suitable resolution for your hardware,
# 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=1280x1024

# 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 entrys
#GRUB_DISABLE_LINUX_RECOVERY="true"

 4. Save the file before closing it.

 5. Run sudo grub-mkconfig to write the changes to your grub.cfg,
sudo grub-mkconfig -o /boot/grub/grub.cfg

 6. reboot and see if it worked.

Changing your Splashimage Font Colors in GRUB2 (2)

When you have a beautiful splashimage, the next thing to do is choose a suitable font color to go with it. Changing the font color can make a big improvement to the appearance of your GRUB Menu and splashimage.
Changing the font color would be very important if you have chosen a splashimage which contains a lot of dark shades and you're still using a black font. You might have trouble reading the titles in your GRUB menu. Changing your font color to white or a light color would be a real necessity in that situation.

We can change the font colors by editing /etc/grub.d/05_debian_theme and running 'sudo grub-mkconfig' (Karmic Koala), or 'sudo update-grub', (earlier versions of Ubuntu).

To alter the grub menu font colors, you need to edit the same file you edited to set your GRUB menu background,  /etc/grub/ 05_debian_theme.
gksudo gedit /etc/grub.d/05_debian_theme

Scroll down to about lines numbered around 33 to 43 and find this section of the file,
### BEGIN /etc/grub.d/05_debian_theme ###
insmod tga
if background_image (hd0,2)/usr/share/images/grub/Windbuchencom.tga ; then
  set color_normal=black/black
  set color_highlight=magenta/black

else
  set menu_color_normal=cyan/blue
  set menu_color_highlight=white/blue
fi
### END /etc/grub.d/05_debian_theme ###
You may change the colors you see here highlighted in yellow.
NOTE: If you're displaying a splashimage (background), you will probably want to leave 'black' for your second normal color, that's why I didn't highlight it yellow. In GRUB2, 'black' really means transparent. If you try to set any color here, that color will hide most of your background, (splashimage).

Colors we can choose from include, black (or transparent), dark-gray, light-gray, white, brown, yellow, red, light-red, blue, light-blue, green, light-green, cyan, light-cyan,   magenta, light-magenta.
 white blue magenta cyan
 light-gray yellow red light-magenta
 dark-gray green light-blue light-red
 black light-cyan light-green brown

For example, just for demonstration purposes, pretend I have a plain lemon colored background image without anything else on it,

GNU GRUB version 1.96

Ubuntu 9.10, linux 2.6.30-8-generic                            
Ubuntu 9.10, linux 2.6.30-8-generic (single-user mode)
Ubuntu 9.10, memtest86+
Other operating systems:




Use the up or down arrow keys to select which entry is highlighted. Press enter to boot the selected OS, 'e' to edit the commands before booting, or 'c' for a command-line.

Changes to 'set color_normal=foreground/background' color settings will affect most of the text in your GRUB menu, and your background color.
As you can see in the above example, using set color_normal=green/black gives me the green font on a 'black' (transparent) background. Because of the transparent background, my  lemon colored background image shows through.

Changes to 'set color_highlight=foreground/background' color settings will only affect your highlight text, and the highlight selection bar.
Using set color_highlight=yellow/light-red gives me the yellow highlight text on the light-red highlight or selection bar.

When you're finished, remember to run update-grub or grub-mkconfig for the changes to take effect.
sudo grub-mkconfig -o /boot/grub/grub.cfg

TIP
To save yourself a lot of time, you may want to experiment with the font colors and see how they look over your new GRUB Menu background (splashimage)'on the fly', without needing to reboot.
Press your 'c' key from your GRUB Menu for GRUB2's Command Line Interface and use the set command to try out different color combinations, pressing your 'esc' key after each change to go back to your GRUB Menu to see how it looks.
See GRUB2 CLI Mode Commands for more.





LINKS

gfxterm - GRUB Wiki

Care to play with grub2-graphical? - Arch Linux Forums

GRUB 2 Graphical Menu Theme File Format - GRUB Wiki - Theme Format

How to add a splashmage in GRUB2 (1)

 1) Download the free, already-made splashimages from the Ubuntu repositories
sudo apt-get install grub2-splashimages

 2) You'll find your new splashimages in /usr/share/images/grub/
Copy the images to /boot/grub, that way if someone has an installation with a separate /boot with an encrypted file system for / , they can still use the images. (GRUB can't 'see' inside an encrypted file system).
sudo cp /usr/share/images/grub/*.tga /boot/grub/

 3) Here are the thumbnails,
2006-02-15_Piping.tga
050817-N-3488C-028.tga
2006-02-15_Piping.tga
2006-02-15_Piping.tga
Aesculus_hippocastanum_fruit.tga
Aesculus_hippocastanum
_fruit.tga
Apollo_17_The_Last_Moon_Shot_Edit1.tga
Apollo_17_The_Last_
Moon_Shot_Edit1.tga
B-1B_over_the_pacific_ocean.tga
B-1B_over_the_pacific
_ocean.tga
BonsaiTridentMaple.tga
BonsaiTridentMaple.tga
Flower_jtca001.tga
Flower_jtca001.tga
Fly-Angel.tga
Fly-Angel.tga
Glasses_800_edit.tga
Glasses_800_edit.tga
Hortensia-1.tga
Hortensia-1.tga
Lake_mapourika_NZ.tga
Lake_mapourika_NZ.tga
Moraine_Lake_17092005.tga
Moraine_Lake_17092005
.tga
Plasma-lamp.tga
Plasma-lamp.tga
Sparkler.tga
Sparkler.tga
TulipStair_QueensHouse_Greenwich.tga
TulipStair_QueensHouse
_Greenwich.tga
Windbuchencom.tga
Windbuchencom.tga

 
4)
To get your new splashimage to appear, you need to edit a file called /etc/grub/ 05_debian_theme.
gksudo gedit /etc/grub.d/05_debian_theme

 5) scroll down in the file and find line 16 or 17

 6) change the following code in line 16 or 17 from:
 for i in {/boot/grub,/usr/share/images/desktop-base}/moreblue-orbit-grub.{png,tga} ; do

 to replace 'moreblue-orbit-grub' with the name of the splashimage of your choice)
 for i in {/boot/grub,/usr/share/images/desktop-base}/Windbuchencom.{png,tga} ; do
  NOTE: Be careful to keep the dot in the filename! eg: 'Windbuchencom.'

  Save and close the file.

  7) Run grub-mkconfig (Karmic Koala), or update-grub (in earlier versions of Ubuntu),
sudo grub-mkconfig -o /boot/grub/grub.cfg
The grub-mkconfig or update-grub command is to write the changes to your grub-conf file.

The expected feedback should look something like this,
[sudo] password for username:
Updating /boot/grub/grub.cfg …
Found Debian background: Windbuchencom.tga
Found linux image: /boot/vmlinuz-2.6.27-7-generic
Found initrd image: /boot/initrd.img-2.6.27-7-generic
Found memtest86+ image: /boot/memtest86+.bin
done
 

8) That's it! All done! Now you can reboot and see how it looks!

復原 Windows MBR 的各種方式

玩 Linux 最常見的方式就是切 Partition 做多重開機, 讓 GRUB 寫入 MBR 做開機選單. 但是若不小心把 Linux Partition 刪掉了, 或是哪天不想玩 Linux 了, 想恢復為 Windows 單一作業環境的時候, 就得把 Windows Pre-Boot 程式寫回 MBR 的前 446 Bytes 喔!
方法一:使用 DOS / Win9x / ME 開機片開機
開機後在 MS-DOS 模式下執行 fdisk /mbr
重新啟動電腦即可

方法二:使用 Windows 2000 / XP 光碟片開機 (過程中需要 Administrator 密碼)
在 Welcome to Setup (歡迎使用安裝程式) 畫面中按 R 或 F10 進入「Windows 修復主控台」
進入主控台後, 輸入 fixmbr
重新啟動電腦即可
詳細操作過程請參考微軟官方網頁 - Windows XP 修復主控台的說明

方法三:使用 Linux 光碟片開機, 進入 Rescue 模式; 或用 KNOPPIX 之類的 Linux 作業系統開機 (過程中請啟用網路)
依序輸入以下指令恢復 Windows MBR
wget http://cha.homeip.net/downloads/ms.mbr -O /tmp/ms.mbr
dd if=/tmp/ms.mbr of=/dev/hda
exit (重開機時請移除光碟片)
  • 以上操作結果同 fdisk /mbr
  • 網路上流傳 dd if=/dev/zero of=/dev/hda bs=446 count=1 效果等同 fdisk /mbr 是錯誤的, 這樣只會清掉 MBR 的 Pre-Boot 內容而已.
  • 警告: 請勿於頭腦混沌、神智不清時使用 dd 指令; 使用時請特別注意數字是否正確!

方法四:什麼開機片都沒有, 但開機後還有 GRUB> 提示符號
依序輸入以下指令啟動 Windows
rootnoverify (hd0,0)
makeactive
chainloader +1
boot
  • (hd0,0) 其中 hd0 表示 Primary IDE Master HDD, 0 表示第一個分割區, 請依實際狀況套用.
  • 注意: 這只是解決 Windows 的啟動問題而已, 仍要靠前三種方法的其中一種才能讓 MBR 恢復正常喔! 當然, Windows 開機後您也可以上網尋找其他的解決方案 :)

-------------------------------------------------------------------------------
最後使用方法四,成功進入XP,之後利用 TestDisk 救回XP MBR.

How to use simple speedtest in RaspberryPi CLI

  pi@ChunchaiRPI2:/tmp $  wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py --2023-06-26 10:4...