Ads 468x60px

วันอังคารที่ 27 ธันวาคม พ.ศ. 2554

การถ่ายทอดสดด้วย ทั้งภาพและเสียง SchoutCast Server ด้วย FreeBSD 6.2

 การถ่ายทอดสดด้วย  ทั้งภาพและเสียง  SchoutCast Server  ด้วย  FreeBSD 6.2 
http://www.ms.ac.th/block-dyns/block-elearning.html
        ก่อนอื่นผมต้องขออภัยด้วยถ้าไม่สามารถจัดการได้  เนื่องจากวันที่ 16-17  สิงหาคม 2550  นี้ทางโรงเรียนกระผมจะมีการจัดงานฉลองครบรอบ  25 ปี  ทางผู้บริหารเลยให้  โปรเจคผมมาว่า  น่าจะมีการถ่ายทอดกิจกรรมทางเว็บไซค์  เพราะว่างานนี้ได้นิมนต์หลวงพ่อพะยอม  กัลยาโน  เจ้าอาวาสวัดสวนแก้ว  มากบรรยายธรรมให้แก่ผู้ปกครอง  นักเรียน  บุคลากร  ศิษย์เก่า  และผู้ที่สนใจด้วย  เลยลองทำดูวันนี้วันที่ 28 กรกฏาคม  2550
            ผมจึงได้ลองศึกษาและลองบันทึกผลการดำเนินการไว้เผื่อเป็นประโยชน์ในการดำเนินการครั้งต่อไปและผู้ที่สนใจ  เข้าเรื่องเลยนะครับ

กาเตรียมอุปกรณ์กันที่ต้องใช้  ลองดูก็แล้วกันว่า  จะเวิร์กหรือเปล่า  มาลองกันเลยเดองับ
     1. เครื่องคอมพิวเตอร์ 1 เครื่อง สำหรับ Encode ผมใช้ Windows XP น่ะครับ
     2. เครื่อง Server ที่ลง Shoutcast Server ไว้   ผมเลือก  FreeBSD
นะครับ
            เรามาดูการติดตั้ง  Shoutcast Server  ฝั่งเครื่อง  Server  นะครับ
                2.1  ให้เราไปดาว์นโหลดไฟล์ที่จะติดตั้งกับ  FreeBSD  เสียก่อนครับ
                    www# cd  /tmp
                    www#fetce http://msbr.dyndns.org/download/shoutcast-1-9-5-freebsd5-elf.tar.gz
               2.2  หลังจากดาว์นโหลดมาแล้ว  ให้เราแตกไฟล์
                    www#gzip -cd shoutcast-1-9-5-freebsd5-elf.tar.gz | tar xvf -
                2.3  ใช้คำสั่ง cd  เพื่อเข้าไปยังไดเรคเทอรี ที่แตกไฟล์ออกมาครับ
                    www#cd shoutcast-1-9-5-freebsd5-elf
                2.4  หลังจากนั้นให้เราไปแก้ไขไฟล์  sc_serv.conf
                    www# cp sc_serv.conf sc_serv.bak   (เพื่อสำรองไฟล์ไว้ก่อนกรณีมีการผิดพลาดเราจะได้กู้กลับมาแก้ไขใหม่ได้ครับ)
                    www# pico sc_serv.conf
                2.5  ให้ค้นหาบรรทัดข้างล่างนี้โดยการกด  Ctrl+W 
                    ;AdminPassword=adminpass    ให้เอาเครื่องหมาย (;)  หน้าบรรทัดออก  
                                         (คำว่า  adminpass   เป็นรหัสผ่านของ  Admin  ที่จะเข้าไปบริหาร  ShoutCast  เพื่อถ่ายทอดเสียง  หรือภาพ หรือทั้งเสียง
                และภาพ  และในที่นี้ผมเปลี่ยนเป็น  spcom  ซึ่งถ้ามีเวลาจะนำเสนอในเรื่องของการถ่ายทอดเสียง  หรือวิทยุออนไลน์ด้วยนะครับ)
                2.6  ต่อไปเราก็สั่งให้  Shoutcast Server  ทำงาน
                        www#cd /tmp
                        www#cd shoutcast-1-9-5-freebsd5-elf
                        www#./sc_serv
                      หรือถ้าต้องการให้  Shoutcast Server  ทำงานทุกครั้งที่  Boot เครื่อง ในไฟล์ /etc/rc.local ให้เขียนคำสั่งเพือ start shoutcast ตาม path ที่เรา   
                                ได้ติดตั้งโปรแกรมครับ เช่น
                                    www# pico /etc/rc.local
                                    /tmp/xxxxxx/sc_serv

                ก็เป็นอันว่าสำเร็จฝั่งเครื่อง  Server ครับ 
     3. การ์ด TV-Tuner  1  ตัว  (ในที่นี้ผมใช้  Snazzi  ครับ)
     4.  Software NSV (Nullsoft Video) มีหลายตัวเหมือนกันน่ะครับ download และลงตามลำดับเลย
           
4.1 NSV Tools
            4.2 NSV Tools updated version
            4.3 NSVtools_repack
            4.4 On2VP3VideoForWindows3250
            4.5 vp361DTe
            4.6 slavas_nsv_VP3_encoder

     เมื่อดาว์นโหลดเสร็จแล้วให้ติดตั้งตามลำดับเลยนะครับ  (คิดว่าท่านที่ได้อ่านคงจะสามารถติดตั้งเป็นนะครับ)  ส่วนข้อที่ 4.2-4.6  เป็นตัว  Upadate
  นะครั้ง  งัยก็ลองติดตั้งดูนะครับ
      พอติดตั้งเสร็จแล้วเราก็จะได้ NSV Live Capture มาอยู่ที่ Start Menu

                               

มาดูหน้าตาเจ้า NSV Live Capture กัน

                                NSV interface

รู้จักหน้าตากันไปแล้วมาเริ่มการ Settings ค่าต่างๆของมันกันดีกว่า
1. เริ่มด้วยคลิกที่เมนู File แล้วเลือก Set Capture Destination... ดังรูป

                                Capconf

มันจะเปิดหน้าต่างขึ้นมา ดังรูป
                               
ให้เรากำหนดค่าต่าง ๆ ที่ Device Output  เพื่อแสดงภาพและเสียงในการติดต่อ  Server
1. Output                         : เลือกเป็น Shoutcast server.
2. Shoutcast server            : ใส่หมายเลข ip หรือ Domain ของ Shoutcast Server
                                         ( ถ้าเกิดเครื่อง Server เป็นเครื่องเดี่ยวกันกับเครื่องที่ Capture ก็สามารถใส่ 127.0.0.1 หรือ localhost ได้เลย)
3. Port                             : ใส่หมายเลขพอร์ตตามที่เราได้ตั้งไว้
4. Password                      : กรอกพาสเวิดส์ที่ได้ตั้งไว้  ในที่นี่ผมเป็น  spcom
5. The headers :
  • icy-name:MS LIVE  : ใส่ชื่อสถานีที่นี่
  • icy-genre:none      : ใส่ประเภทของสถาน
  • icy-pub:0              : ต้องการให้แสดงชื่อสถานีบน Winamp TV directory หรือไม่ 0=ไม่แสดง 1=แสดง
  • icy-br:60               : บิตเรตที่ stream หรือส่งภาพและเสียง   (ในที่นี้  60  เพราะว่าเบรนบิดร์ผมค่า  128/64 Kbs
  •                              (แต่วันที่  16-17  สิงหาคม 2550  ผมก็จะปรับเป็น  300  เพราะตอนนี้อยู่ในช่วงทำเรื่องเพิ่ม Speed อยู่ครับ)
  • icy-url:http://www.ms.ac.th   : ชื่อเว็ปไซน์โรงเรียนผมนะครับ  (โรงเรียนมารีย์อนุสรณ์ บุรีรัมย์)
  • icy-reset:1             : ไม่ต้องเปลี่ยน
เปลี่ยนค่าต่างๆ แล้วก็ OK ได้เลยครับ
จากนั้นก็มาดูเมนู Devices กันบ้าง  เพื่อกำหนด อุปกรณ์ในการส่งภาพ  และเสียง

                        
ตรงส่วนนี้เอาไว้เลือกอุปกรณ์สำหรับ Capture ครับจะเห็นไว้ว่าแยกออกเป็น 2 ส่วน คือ ส่วนบนเป็นอุปกรณ์ Input ภาพ  สำหรับ Capture Video และส่วนล่างจะเป็นส่วนของ Soundcard เอาไว้สำหรับ capture เสียง  ให้เราคลิกเลือกทั้งสองอุปกรณ์  เลยนะครับ

มาดูเมนู Options กันบ้าง

                             
ให้เลือก Preview เพื่อจะได้จัดตำแหน่งหรือตั้งค่าเกี่ยวกับแสงของกล้องได้สะดวกขึ้น  แต่ผมเลือกแล้วภาพไม่มาครับ  เป็นเพราะว่าตอนนี้การ์ด  Pinnacle  ของผมมันเลือกภาพจาก  Svideo  แต่ผมนำภาพเข้าจาก  AV ผมจึงจำเป็นต้องเลือกเมนู  Video Input  ด้วยครับ
                       
สังเกตุว่าตอนนี้ภาพมาแล้วครับ   จากนั้นคลิกเลือก Video Capture Filter..  เพื่อปรับแต่การ์ด Input Video 
             

ลองปรับดูนะครับ  การเพิ่มแสง  เพิ่มสีของวีดีโอ   จะขึ้นอยู่กับการ์ด  Capture Video  แต่ละตัวด้วยนะครับ
จากนั้นก็มาเลือกที่ Video Capture Pin...
                       
    ในที่นี่เป็นการเลือกรูปภาพของ  Stream เช่นขนาดของภาพส่งออก  ให้เลือกเป็น  แล้วแต่ความเหมาะสมหรือความต้องการของท่าน  แล่ผมเลือก  352x288  และผมไม่ปรับอะไรอีกเลยเอาตามค่าเดิมครับ ลังจากนั้น  คลิกเลือกที่เมนู Capture จากนั้นคลิกเลือกที่ Capture Audio เพื่อทำให้ภาพที่ส่งออกไปมีเสียงด้วยครับ
                       

เมื่อเลือก Capture Audio แล้วกลับไปที่เมูน Options กันอีกครั้ง   คลิกเลือกที่ Audio Capture Filter...
    เพื่อปรับรูปแบบของเสียงที่เข้า  และเสียงออก 
                          
ในตรงส่วนข่อง  Pin Line Input Mix    ให้เลือก เครื่องหมายถูก  Enable  และ  Pin Line  ให้เลือก  Stereo Mix  และสามารถปรับเสียงความดัง  เสียงเบส  เสียงแหลมได้วด้วยนะครับ  จากนั้นให้คลิก  OK
ต่อจากนั้นเรามาดูที่เมนู NSV กันบ้างน่ะครับ คลิกที่ NSV แล้วเลือก Config...
                     
ตั้งค่าตามนี้เลยครับ Deinterlace video กับ High quality deinterlace ให้ติ๊กถูกด้วยน่ะครับ
เพื่อให้ video ที่ส่งออกไปจะได้คมชัด ส่วนเสียงจะตั้งให้เป็น Stereo หรือ Mono ก็แล้วแต่ชอบน่ะครับ

จากนั้นที่คลิก Encoder Config...จะได้หน้าต่าง ดังรูป

                   
ให้เลือก Audio format : เป็น PCM Audio  น่ะครับ Bitrate: เลือกตามต้องการ แต่ต้องคำนึงถึงอัตรา upstream ของอินเตอร์เน็ตที่เราใช้ด้วยน่ะครับ
ส่วน Video ให้เลือกเป็น VP31/VFW อย่างรูปด้านบน   จากนั้นก็คลิกที่ Configure
                    \

ถึงตอนนี้ผมไม่ปรับอะไรนะครับ  (เพราะผมอ่านแล้วไม่เข้าใจ  และในขณะที่ผมทำอยู่นี้ผมยังไม่รู้เลยว่าภาพมันจะออกไปที่  Server  หรือเปล่า) 555+
จากนั้นให้คลิก 
OK  และ  OK  ไปเรื่อย ๆ  และก็จะกลับมาที่หน้าจอเดิมครับ  NSV Live Capture

                   
เมื่ออยู่ตรงหน้าหลักของโปรแกรมแล้ว คลิกที่เมนู Capture แล้วคลิกเลือกที่ Start Capture ได้เลย
               
สังเกตที่ Status bar จะมีตัวเลขวิ่ง   เป็นอันเสร็จครับ  สำหรับการส่งภาพเข้า  SERVER  FreeBSD


มาดูผลกัน
เข้าไปที่ http://www.ms.ac.th:8000
จากนั้นคลิกที่ Listen
หรือเปิดโดยตรงจาก winamp เลยก็ได้ โดยการเปิดโปรแกรม winamp แล้ว add url (กด Crtl +L) แล้วใส่ http://www.ms.ac.th:8000/listen.pls

เช่น http://www.ms.ac.th:8000/listen.pls
ถ้าหากผ่านมันจะ buffer แล้วก็แสดง video พร้อมเสียงเลยครับ
ข้อสังเกตนิดนึงน่ะครับ คลิกขวาที่ชื่อสถานีใน winamp ดูแล้ว View file info...
เราจะเห็นว่า url จะเปลี่ยนไปเป็น http://www.ms.ac.th:8000/;stream.nsv

เช่น http://www.ms.ac.th:8000/;stream.nsv

เป็นวิธีง่ายๆ ลองเอาไปทำกันดูน่ะครับ
        ทำเสร็จยังไม่ได้ลองเลยครับ  ไฟดับ  เครื่อง  Server  ที่โรงเรียนผมดับไปด้วยครับ  เลยยังไม่ได้ทดสอบ
หลังจากขับรถเข้าไปโรงเรียน ประมาณ  10  กิโลเมตร  เปิด  Server  (เพราะไม่มีเครื่องสำรองไฟครับ )
กลับมาบ้านอีกครั้ง  ลองดูใหม่ผลสรุปว่า  ผ่านครับ
                       
แต่ผมไม่สามารถให้มันแสดงผ่านเว็บได้เลยครับ   ท่านใดมี  โค้ดแสดงด้วย  WinAmp  ขอด้วยครับ
เพราะว่าต้องเปิดผ่าน  วินแอมป์เท่านั้น  เดี่ยวผมจะลองดูที่  Windows Media  ดูว่าจะผ่านหรือเปล่า ผลปรากฎว่า "ไม่ผ่านครับ"  เปิดดูไม่ได้
                       

วันที่ 28 กรกฎาคม  2550  เวลา 11.50 น.  sombut45@hotmail.com
ต้องขอขอบพระคุณ Thaibsd.com, mr.gill , อ.เกรียงไกร  แห่งมหาวิทยาลัยราชภัฏสุรินทร์  และอาจารย์กิตติพงษ์  สุวรรณราช
และพี่ ๆ น้อง ๆ ชาว 
BSD  ทุกคนครับ สำหรับคำแนะนำที่ดีครับ

EditPlus สุดยอด text editor

มาดูความสามารถของ EditPlus กันหน่อยว่าทำอะไรได้บ้างนอกจาก hilight สี ^_^ หลายท่านคงยังไม่เคยทำ template และการสร้าง Auto complete ไว้ใช้งานกัน ซึ่งหากว่าใครได้เคยใช้แล้ว จะพบกับความสะดวกสบายในการเขียนโปรแกรมขึ้นอีกมากทีเดี่ยว EditPlus เป็นโปรแกรม Editor ที่โปรแกรมเมอร์ นิยมมากตัวหนึ่ง เนื่องจากสามารถที่จะนำมาเขียนได้หลายภาษาและ
สามารถ ที่จะกำหนด shortcut เพื่อการทำ auto complete และสามารถที่จะสร้าง template ของแต่ละภาษาขึ้นมาได้เอง ซึ่งจะช่วยเพิ่มความสะดวก เวลาที่เราเขียนโปรแกรมได้มากทีเดี่ยว

หากใครยังไม่มี โปรแกรม EditPlus ก็ให้ไป Download มาก่อนนะครับที่ http://www.editplus.com/
Template คือต้นแบบของโปรแกรมที่เราจะเขียน ว่าต้องการให้ขึ้นต้นด้วยคำว่าอะไร อย่างเช่น template ที่มีมาให้อยู่แล้วของ
EditPlus คือ C/C++ , Perl , Java แต่ว่ายังไม่มีของ php ผมเข้าใจว่าที่ไม่มี tempalte ของ php เพราะว่า php เวลาจะเขียน โปรแกรม จะเริ่มด้วย <?php และจบ ด้วย ?> เท่านั้นเอง เขาเลยไม่ได้ทำไว้ให้ (คิดเอาเองนะนี้)
ส่วนของ Template ตัวอย่างของ Perl จะเริ่มด้วย
#!/usr/bin/perl
และมีโปรแกรมตัวอย่างมาให้ 1 บรรทัด คือ
print “Hello, World… “;
จากรูปจะเห็นว่ามี Template ของ C/C++ , Perl , Java แต่ยังไม่มีของ PHP

ต่อไปผมจะทำการเพิ่ม template ของ php เข้าไปเพื่อให้ เวลาที่เราเขียนโปรแกรมจะได้มี comment ของเราติดไปด้วยโดยไม่ต้องพิมพ์ใหม่ ทุกครั้งมาเริ่มทำ tepmlate ของ php กันเลยนะครับ
ให้คุณทำการสร้าง file ชื่อ template.php ไว้ใน C:Program FilesEditPlus 2 ซึ่งภายใน file นี้ เราจะเขียน comment และ กำหนดตำแหน่งที่เราจะเริ่มเขียนโปรแกรม ดังนี้

^! เป็นการกำหนด ตำแหน่งของ cursor เวลาที่เราสร้าง file php จาก template ตัวนี้
จากนั้นให้เข้าไปที่ menu Tools -> Preferences ของ EditPlus

จะได้ windows Preferences ดังรูป ให้ทำการเลือกที่ Templates และคลิก Add
จาก นั้นใส่ PHP ลงในส่วนของ menu text และ ใส่ C:Program FilesEditPlus 2 emplate.php ในช่อง file path จากนั้น คลิก OK แค่นี้ก็เรียบร้อย

ต่อไปมาลองใช้ template ที่เราสร้างดูกันเลยดีกว่า ให้คลิกที่ icon new จะพบว่ามีรายการของ PHP เพิ่มขึ้นมา

และเมื่อคลิกที่ PHP จะเห็นว่า file php ที่เราสร้างใหม่นี้ จะนำ template ที่เราสร้างไว้มาใช้ ทีนี้เวลาเขียนโปรแกรมครั้งต่อไปก็จะมี comment Copyright ของเราติดไปด้วยทุกครั้ง
Auto complete คือ การทำ shortcut ของคำสั่งนั้นเอง อย่างเช่นใน ภาษา php เวลาที่เราจะทำการ connect database MySQL เราจะต้องเขียน แบบนี้
1
2
3
4
$link = mysql_connect("mysql_host", "mysql_user", "mysql_password");
mysql_select_db("my_database");
$query = "SELECT * FROM my_table";
$result = mysql_query($query);
บางคนอาจจะจำคำสั่งทั้งหมดนี้ได้ แต่ผมคนหนึ่งละที่จำไม่ได้ ถึงจะเขียนมานานแล้วก็ตาม แล้วมันจะดีกว่าหรือเปล่า หากว่าเราสามารถจะพิมพ์แค่ คำว่า mycon แล้วข้อความทั้งหมดนี้มันขึ้นมาให้เราเอง และ EditPlus ก็มี Function ในเรื่องการทำ Auto complete ให้เราอยู่แล้ว
ขั้นแรกให้เข้าไปที่ http://www.editplus.com/html.html เพื่อทำการ Download php-5.0.3.zip กับ php_acp3.zip

php-5.0.3.zip ตัวนี้จะเป็น file ที่จะกำหนดเกี่ยวกับ syntax ของ ภาษา php ว่าคำใดบ้างเป็น function เพื่อจะได้ทำการ แยกสีให้ เราเห็นเวลาที่เราเขียนโปรแกรม
php_acp3.zip ตัวนี้เป็น file auto complete ที่เขาสร้างให้เราแล้ว (แต่ยังไม่ถูกใจเราเหรอก ต้องเพิ่มเติมบ้าง)
จากนั้นทำการ unzip และ copy php.stx และ php.acp มาว่างไว้ที่ C:Program FilesEditPlus 2 (ให้ทำการ copy ทับตัวเก่าไปเลยนะครับ เพราะว่าตัวนี้ใหม่กว่า)
จากนั้นให้ทำการเข้าไปที่ menu Tools -> Preferences ของ EditPlus
ทำการเลือก Setting & syntax และทำการเลือกที่ PHP โดยทำการใส่
C:\Program Files\EditPlus 2\php.acp ลงไปในช่อง Auto completion จากนั้นคลิก OK
เพียงเท่านี้เราก็จะสามารถใช้งาน auto complete ได้แล้ว

ทีนี้เราจะมาลองใช้งาน Auto complete กันดู ให้ทำการ คลิกที่ icon new แล้วเลือก PHP

จากนั้นให้ พิมพ์ คำว่า if แล้วกด space bar ที่ keyboard จะเห็นว่ามีการเพิ่มเครื่องหมาย {} ให้โดยอัตโนมัต

ต่อไปเรามาลอง เพิ่ม shotcut mycon เพื่อทำการสร้างคำสั่ง connect MySQL กันดูบ้าง ให้ทำการเปิด file C:\Program Files\EditPlus 2\php.acp ขึ้นมา

จะเห็นว่ามีคำสั่งต่างๆ ถูก add ไว้อยู่แล้ว ให้ทำการเลื่อนลงมาที่ บรรทัดล่างสุด แล้วพิมพ์ ข้อความนี้ลงไป แล้วทำการ save
1
2
3
4
5
#T=mycon
$link = mysql_connect("^!mysql_host", "mysql_user", "mysql_password");
mysql_select_db("my_database");
$query = "SELECT * FROM my_table";
$result = mysql_query($query);
ข้อสังเกต จะต้องมี เครื่องหมาย # อยู่ที่บรรทัดสุดท้ายของ file เสมอ และเราสามารถกำหนด ตำแหน่งของ cursor ได้โดยการใส่ ^! ลงไปในตำแหน่งที่ต้องการ
ต่อไปลองใช้ auto complete ที่เราสร้างไว้ดูบ้าง ให้ทำการสร้าง file php ขึ้นมาใหม่
จากนั้น พิมพ์คำว่า mycon แล้วก็กด space bar ดู จะพบว่าข้อความที่เรากำหนดไว้ใน auto complete จะถูกนำมาใช้แล้ว

ทีนี้หากว่าเรามี คำสั่งที่ต้องใช้ บ่อยๆ เราก็สามารถนำมาใส่ใน auto complete ได้ การเขียนโปรแกรมของเราในครั้งต่อๆไป ก็จะง่ายขึ้น

วันเสาร์ที่ 24 ธันวาคม พ.ศ. 2554

บทความเกี่ยวกับคอมพิวเตอร์ การใช้งานโปรแกรมคอมพิวเตอร์

หมวด หมู่หนังสือ บทความเกี่ยวกับคอมพิวเตอร์ การใช้งานโปรแกรมคอมพิวเตอร์โดยแบ่งเป็นหมวดหมู่ย่อยๆ เพิ่มเติมเช่น คอมพิวเตอร์เบื้องต้น ระบบปฏิบัติการ กราฟิค นำเสนอข้อมูล การสร้างเว็บไซต์ ฯลฯ 

หมวดหมู่หนังสือทั้งหมด

โปรแกรมสร้างเว็บไซต์ ออกแบบเว็บไซต์ เว็บบอร์ด CMS

 http://www.siamebook.com/lbro/website-dev-cms-software.html
 
โปรแกรมสร้างเว็บไซต์ ออกแบบเว็บไซต์ เว็บบอร์ด CMS
หนังสือเกี่ยวกับการพัฒนาเว็บไซท์ โดยนำเสนอวิธีใช้งานโปรแกรมต่างๆ ที่เกี่ยวข้องกับการสร้างโฮมเพจ

วันจันทร์ที่ 19 ธันวาคม พ.ศ. 2554

การคำนวณเมื่อลงทุน LTF-RMF

คำนวณภาษีเงินได้ เมื่อลงทุนใน RMF & LTF
  หมวดรายได้
เงินเดือน (ต่อเดือน)  บาท
โบนัส  บาท
รายได้อื่น  บาท
เงินที่นายจ้างจ่ายให้ครั้งเดียว
เพราะเหตุออกจากงาน
บาท
เงินได้ต่อปี บาท
  หมวดค่าลดหย่อน
ค่าใช้จ่าย บาท
ผู้มีเงินได้ บาท
สถานภาพการสมรส  
  บาท
บุตร  กำลังศึกษา  0 1 2 3
 ไม่ได้ศึกษา 0 1 2 3
  บาท
เบี้ยประกันชีวิต บาท
เงินสะสมกองทุนสำรองเลี้ยงชีพ % บาท
ค่าเลี้ยงดูบุพการี บาท
ดอกเบี้ยเงินกู้ยืม บาท
ประกันสังคม หัก ไม่หัก
เงินสมทบกองทุนประกันสังคม บาท
เงินบริจาค บาท
เงินได้สุทธิ บาท
 
ภาษีเงินได้ บาท
เงินลงทุนใน RMF สูงสุดที่จะได้รับสิทธิประโยชน์ทางภาษี
บาท
ท่านต้องการลงทุนใน RMF บาท
 
เงินลงทุนใน LTF สูงสุดที่จะได้รับสิทธิประโยชน์ทางภาษี
บาท
ท่านต้องการลงทุนใน LTF บาท
 
เงินได้หลังซื้อกองทุน บาท
 
ภาษีเงินได้หลังซื้อกองทุน บาท
ท่านประหยัดภาษีได้
บาท
คิดเป็นสัดส่วนของเงินลงทุน (ในปีที่ลงทุน)
%   
  

: : : คำเตือน: : :

: : : คำแนะนำ : การลงทุนมีความเสี่ยง ผู้ลงทุนควรศึกษารายละเอียดก่อนตัดสินใจลงทุน : : :
 
 
http://www.one-asset.com/ThailandMutualFund/RMF/calc2.htm

วันพุธที่ 9 พฤศจิกายน พ.ศ. 2554

หมู่บ้านพลัม ไทย

หมู่บ้านพลัม ไทย
http://www.thaiplumvillage.org/plum_practice_index.html


ภาวนาด้วยหัวใจ



บทนำ
     สติเป็นพลังแห่งความตระหนักรู้ และรู้สึกตัวทั่วพร้อมในปัจจุบันขณะ เป็นการเฝ้ามองอย่าง ลึกซึ้ง ในทุกขณะของชีวิตประจำวัน การดำรงสติเป็นการดำรงชีวิตอยู่อย่างแท้จริง ดำรงอยู่กับ ปัจจุบันขณะ และกับทุกสิ่งที่รายล้อมเรา รวมทั้งกับสิ่งที่เรากำลังทำอยู่ เราสามารถโน้มนำกาย และจิตให้ผสานสอดคล้อง ในขณะที่เราล้างจาน ขับรถ หรืออาบน้ำยามเช้า
     ในหมู่บ้านพลัม เราทำกิจวัตรต่างๆ เหมือนกับที่เราอยู่กับบ้าน เช่น เดิน นั่ง ทำงาน รับประทาน อาหาร เป็นต้น แต่ที่เราเรียนรู้ที่จะทำกิจวัตรต่างๆ ด้วยลมหายใจแห่งสติ ด้วยการตระหนักรู้ ในทุกขณะ เราฝึกสติทุกๆ ขณะตลอดทั้งวัน และไม่เพียงแต่ในห้องปฏิบัติสมาธิภาวนาเท่านั้น แต่ยังปฏิบัติในครัว ในห้องน้ำ ในห้องพัก และระหว่างทางเดินด้วย
     ในการฝึกปฏิบัติร่วมกันในสังฆะเป็นชุมชน การฝึกสติของเรานำมาซึ่งความเบิกบาน ผ่อนคลาย และมั่นคง เราเป็นระฆังแห่งสติแก่กันและกัน ช่วยเหลือและตักเตือนซึ่งกันและกัน ด้วยความ ช่วยเหลือของชุมชน ตลอดช่วงการฝึกปฏิบัติ เราสามารถฝึกบ่มเพาะความสงบและเบิกบาน จากภายในและรอบตัวเรา ประดุจของขวัญสำหรับทุกๆ คนที่เรารักและห่วงใย เราสามารถบ่มเพาะ ความมั่นคงและอิสรภาพ มั่นคงในความปรารถนาอันยิ่ง และเป็นอิสระจากความกลัว ความเข้าใจผิด และความทุกข์ทรมานทั้งปวง
     เพื่อนที่รักทั้งหลาย ขอให้เรามีความสามารถและชาญฉลาดในการฝึกปฏิบัติ เข้าสู่ทุกย่างก้าว ของการปฏิบัติด้วยความกระหายใคร่รู้และเต็มไปด้วยสัมผัสแห่งการแสวงหา ให้เราฝึกปฏิบัติ ด้วยความเข้าใจ ไม่ใช่เพียงแต่แบบแผนและสิ่งที่ปรากฏเห็น ขอให้มีความเบิกบานในการฝึก ปฏิบัติ ด้วยความผ่อนคลายและอ่อนโยน พร้อมใจที่เปิดกว้าง
     เนื้อหาหลัก "ภาวนา ด้วยหัวใจ"

เชิญระฆังแห่งสติ

เดินเจริญสติ

นั่งสมาธิ

หนังสือ พระอาจารย์พรหม วังโส

http://www.dhamaforlife.com/audio/BeHappy/index_.htm


  
 คลิกอ่าน   
    
คลิกฟังเสียง
 
001 คำปรารภในการทำซีดี
002 คำนำ
003 จากผู้แปล
004 คำอุทิศกุศล

005
บทที่ 1 ความสมบูรณ์แบบและความรู้สึกผิด ก้อนอิฐที่ไม่เข้าที่เข้าทางสองก้อน
006 สวนเซน
007 เท่าที่ทำแล้วก็เสร็จแล้ว
008 ทำสวนทวนทุกข์
009 ความรู้สึกผิดและการให้อภัย
010 ความรู้สึกผิดของอาชญากร
011 เด็กนักเรียนห้อง ข
012 เด็กน้อยในซุปเปอร์มาเก็ต
013 ผิดกันถ้วนหน้า
014 จงปล่อยวางความรู้สึกผิดตลอดกาล

015
บทที่ 2 ความรักและการอุทิศตน ความรักที่ไม่มีเงื่อนไข
016 เปิดประตูใจไว้
017 การอุทิศตน
018 ไก่กับเป็ด
019 ขอบคุณข้อบกพร่อง
020 เรื่องรักๆ ใคร่ ๆ
021 รักแท้

022
บทที่ 3 ความหวาดกลัวและความเจ็บปวด อิสระจากความหวาดกลัว
023 ทำนายทายทักอนาคต
024 การพนัน
025 ความกลัวคืออะไร
026 ประหม่าหน้าคน
027 กลัวความเจ็บปวด
028 ปล่อยวางความเจ็บปวด
029 เจ็บนิดๆไม่นาน ดีกว่าใช้ยาช่วยถอนฟัน
030 ไม่มีกังวล

031
บทที่ 4 ความโกรธกับการให้อภัย ความโกรธ
032 การพิจารณาคดี
033 งานปฏิบัติธรรม
034 ปีศาจกินความโกรธ
035 ไม่ไหวแล้ว พอกันที ฉันไม่อยู่แล้ว
036 วิธีการที่จะระงับการต่อต้านการปกครอง
037 สงบลงด้วยการให้อภัย
038 การให้อภัยเชิงสร้างสรรค์

039
บทที่ 5 สร้างความสุข การยกย่องชมเชยพาเราไปได้ทุกแห่ง
040 วีไอพี เป็นได้อย่างไร
041 สองนิ้วช่วยยิ้ม
042 คำสอนที่ล้ำค่า
043 แล้วมันจะผ่านพ้นไปเช่นกัน
044 การเสียสละเยี่ยงวีรบุรุษ
045 ขี้วัวเต็มคันรถบรรทุก
046 มากเกินไปที่จะหวัง
047 ถังขยะก้นรั่ว
048 มันอาจจะยุติธรรมก็ได้

049
บทที่ 6 ปัญหาวิกฤติและการแก้ไขด้วยเมตตา กฏแห่งกรรม
050 ดื่มชาเมื่อไม่มีทางออก
051 ไปตามกระแส
052 ติดกับระหว่างเสือและงู
053 คำแนะนำเพื่อชีวิต
054 มีปัญหารึ
055 การตัดสินใจ
056 การโทษผู้อื่น
057 คำถามสามข้อของจักรพรรดิ
058 วัวร้องไห้
059 เด็กหญิงเล็กๆ กับเพื่อนของเธอ
060 งู นายกเทศมนตรี และพระ
061 งูตัวร้าย

062
บทที่ 7 ปัญญาและความสงบภายใน ปัญญานำ น้ำใจตาม
063 ความห่วงใยต่อลูกชาย
064 ปัญญาคืออะไร
065 กินอย่างฉลาด
066 การแก้ปัญหา
067 ฟังผิด
068 ไม่ใช่ปัญญา
069 โอษฐภัย
070 เต่าพูดมาก
071 พูดได้ฟรี ไม่ต้องจ่ายภาษี

072
บทที่ 8 จิตกับสัจธรรม หมอผี
073 อะไรใหญ่ที่สุดในโลก
074 การค้นหาจิต
075 วิทยาศาสตร์
076 ศาสตร์แห่งความสงบ
077 ความเชื่ออันงมงาย

078
บทที่ 9 คุณค่าและการปฏิบัติธรรม เสียงที่ไพเราะที่สุด
079 อำนาจปิรามิด
080 หินที่มีค่า
081 แล้วฉันจะเป็นสุข
082 ชาวประมงเม็กซิกัน
083 พอ

084
บทที่ 10 อิสรภาพและความ อ่อนน้อมถ่อมตน อิสระสองประเภท
085 อิสระชนิดไหนล่ะที่ท่านชอบ
086 โลกเสรี
087 อาหารค่ำกับองค์กรนิรโทษกรรมสากล
088 การแต่งตัวของพระ
089 หัวเราะตัวเอง
090 การหัวเราะที่ดังสุดของหมามะกัน
091 เหม็นลม
092 เมื่ออาตมาบรรลุธรรม
093 หมอหรือหมู
094 ฮาริคริชน่า
095 ค้อนใคร
096 มองเป็นเรื่องตลกดีกว่า
097 ไอ้โง่

098
บทที่ 11 ความทุกข์และการ ปล่อยวาง คิดยากกว่าทำ
099 ขุ่นเพราะขน
100 กรรมของเราหนอ บุญของเขาหนอ
101 ไม่ปลอบก็เหมือนปลอบ
102 การเจ็บป่วยเป็นเรื่องผิดปกติรึ
103 เยี่ยมคนป่วย
104 หัวเราะไม่ห้าม
105 คอนเสิร์ตชีวิต
106 ใบไม้ร่วง
107 ปุ่มชะตากรรม
108 เมียข้ามชาติ
109 หัวเราะให้ออก
110 เสน่ห์กองขี้
111 ประวัติผู้เขียน
112 จากใจผู้จัดทำ
113 Don't Worry Be Happy

พระอาจารย์พรหมวังโส

http://www.bloggang.com/mainblog.php?id=sleepwalker&month=18-04-2008&group=11&gblog=28

พระอาจารย์พรหมวังโส

เมื่อ วันอาทิตย์ - วันจันทร์ต้นเดือนเมษา ฉันมีโอกาสไปฟังพระธรรมเทศนาของพระอาจารย์พรหมวังโส 2 วัน

เลยขอนำ การเทศน์เมื่อวันอาทิตย์ที่ 6 เมษายน มาเล่าสู่กันฟัง
เนื่องจากหลวงพ่อ เทศน์เป็นภาษาอังกฤษ ฉันจึงแปลและเรียบเรียงตามความเข้าใจ
ผิดพลาดประการ ใดขออภัยไว้ล่วงหน้า และขอน้อมรับความผิดไว้ทุกประการ


สมาธิ คืออะไร

หลวงพ่อถามแล้วสาธิตโดยยกแก้วน้ำให้ดู
ยิ่งยก แก้วไว้นานเท่าไร แก้วก็จะยิ่งหนักมากขึ้นเท่านั้น
เมื่อถือไว้นานๆ จนรู้สึกว่าแก้วหนักเกินไป

เรื่องง่ายๆ ที่ควรจะทำก็คือ วางแก้วใบนั้นลง
หลังจากวางลงแล้ว เมื่อเรายกแก้วใบเดิมขึ้นมาใหม่
เรา จะรู้สึกเหมือนกับว่าแก้วใบนั้นเบาลง

การนั่งสมาธิก็เหมือนการวาง แก้วลง
เมื่อออกจากสมาธิ เราจะพบว่า ชีวิตนั้นไม่หนักหนาสาหัสจนเกินไปนัก



ปล่อยวาง

หลวงพ่อเปรียบเทียบสมาธิกับการทำให้น้ำในแก้ว นิ่ง
หลายๆ คน ทำสมาธิโดยการบังคับ ให้ใจนิ่ง
เหมือนกับการพยายามถือ ไว้ให้นิ่งๆ
ยิ่งเราเกร็ง ตั้งใจถือแก้วให้อยู่นิ่งๆ
น้ำในแก้วกลับ ยิ่งสั่นไหว

การทำให้น้ำในแก้วนิ่งนั้น
จำเป็นต้องวางแก้วน้ำ นั้นลง
แม้ว่าในช่วงที่เรายกแก้วน้ำลงสู่พื้นนั้น น้ำอาจจะกระฉอกมากสักหน่อย
เหมือนเมื่อเราปลดปล่อยการควบคุมบังคับจิตใจ
มัน อาจจะกระเพื่อมเกินปกติไปบ้าง
แต่ที่สุดแล้ว มันก็จะนิ่ง เหมือนกับน้ำในแก้วที่วางอยู่บนพื้น



let it go


ทำไม

หลวง พ่อเล่าว่า ครั้งหนึ่ง สมัยที่ท่านยังบวชอยู่ที่วัดป่านานาชาติ
ครั้ง หนึ่งท่านเพิ่งออกมาจากสมาธิ และเดินสวนกับหลวงพ่อชา
หลวงพ่อชาจ้องท่าน เขม็งแล้วถามด้วยเสียงอันดังว่า 'พรหมวังโส ทำไม!'
หลวงพ่อได้แต่ตอบว่า I don't know
หลวงพ่อชาหัวเราะ แล้วบอกว่า งั้นจะบอกให้
หลวงพ่อจึง ตั้งใจฟัง คำตอบจากครูบาอาจารย์
คำตอบของคำถามว่า "ทำไม"
คำตอบของ หลวงพ่อชาคือ "ไม่มีอะไร"
แล้วหลวงพ่อชาก็ถามว่า เข้าใจไหม
ในตอนนั้น หลวงพ่อก็ตอบไปว่า เข้าใจ
ทั้งที่จริงๆ ก็ยังไม่เข้าใจ

ที่ว่า ไม่มีอะไรก็คือ
ไม่มีใคร ไม่มีตัวตน มีแต่ความว่าง




การ นั่งสมาธิ
การวางแก้วลง
การเลิกยึดถือ
การหยุดทำ
การไม่พยายาม จะไปที่ใด
หรือไม่พยายามจะเป็นสิ่งใด
การไม่ตัดสิน
การเลิกพยายาม จะควบคุมสิ่งต่างๆ


ในการนั่งสมาธิ เราจะพบว่า ยิ่งเราปล่อยวางได้มากเท่าใด ตัวเราก็จะยิ่งหายไปมากเท่านั้น
ยิ่งเรา ปล่อยวาง เลิกพยายามควบคุมสิ่งต่างๆ ได้มากเท่าใด เราก็จะยิ่งสงบมากขึ้น
ยิ่ง อยู่นิ่ง ก็จะยิ่งมีพลัง มีความสุข และยิ่งว่าง




หาก ต้องการมีร่างกายที่แข็งแรง ก็ต้องออกกำลังกาย
หากต้องการมีจิตใจที่มี กำลัง ก็ต้องให้มันอยู่นิ่งๆ



ยิ่งคิด ยิ่งทำ มากเท่าใด จิตใจก็จะยิ่งอ่อนแอลง
ยิ่ง ตัวเราหายไปมากเท่าใด จิตก็จะยิ่งมีกำลังมากขึ้นเท่านั้น

มีคำกล่าว ในคัมภีร์วิสุทธิมรรคตอนหนึ่งว่า

The path is, but no traveller on it is seen
Enlightenment is, but no person will enter enlightenment

ถ้า หากยังยึดถือในตัวตนอยู่ การนั่งสมาธิก็จะเป็นหนทางอันยากลำบาก
ยิ่งเรา พยายามที่จะควบคุม สมาธิก็ยิ่งยากที่จะเกิดขึ้น




ชีวิต เปรียบดังรถโดยสารที่ไร้พลขับ


ในชีวิตของเราเราต้องพบ เจอกับเรื่องต่างๆ มากมาย
บางครั้งรถโดยสารที่เรานั่งไปก็ผ่านไปยัง เหตุการณ์ดีๆ
เหตุการณ์ที่เราอยากจะให้รถของเราแล่นไปช้าๆ หรือหยุดนิ่ง
เพื่อ จะได้ชื่นชมสิ่งดีๆ เหล่านั้นนานๆ
มิไยที่เราขอร้องคนขับให้ลดความเร็ว ลง
หรือตะโกนบ่นว่าสักเท่าไร ก็ไม่ได้ผล
ยิ่งเราอยากให้รถวิ่งช้าลง
ก็ ดูเหมือนคนขับจะกระทืบคันเร่งพารถห้อตะบึงให้ผ่านพ้นไปอย่างสุดความสามารถ

บาง ครา ที่รถแล่นผ่านไปยังเหตุการณ์อันไม่น่ารื่นรมย์
เหตุการณ์ที่เราอยาก จะพ้นไปเสียเร็วๆ
เราก็ตะโกนร้องให้คนขับรีบๆ เหยียบคันเร่งไปเสียให้พ้นๆ
คนขับก็กลับจะแกล้งขับให้ช้าเฉื่อย หรือบางทีอาจจะจอดรถเสียเฉยๆ




ส่วนมากในการปฏิบัติธรรม นั้นในขั้นต้น
เรามักจะเสาะหาเจ้าตัวคนขับรถ เพื่อที่เราจะได้ไม่เป็นทุกข์
เพื่อที่เราจะสามารถควบคุมรถโดยสารคันนี้ ได้ตามต้องการ
ให้แล่นช้าในยามที่เรามีความสุข
ให้แล่นเร็ว เมื่อเรามีความทุกข์

แต่เราสำรวจไปทั่วทั้งคันรถ
เราตามหาลึกลงไป เรื่อยๆ เราจะได้พบว่า
ณ ที่นั่งคนขับนั้น ไม่มีผู้ใดนั่งอยู่

แล้ว เราจะทำอย่างไร
เราทำได้เพียงแต่กลับไปนั่งที่ผู้โดยสาร และหยุดบ่น

ก็ จะบ่นไปทำไมในเมื่อไม่มีใครอยู่ฟัง
นั่งให้สบายๆ ดีกว่า

นี่อาจจะ เป็นครั้งแรกในชีวิตที่เรายอมรับว่า
เราไม่อาจควบคุมอะไรได้

และ เมื่อนั้นเราก็จะเรียนรู้ที่จะปล่อยวาง



เป้าหมายของชีวิต
เคยมีคนถามหลวงพ่อว่า เป้าหมายของชีวิตคืออะไร

เป้าหมายของชีวิตคือการหาเป้าหมายของชีวิต
ถ้า ลองพิจารณาดู จะพบว่านี่คือความจริง
เมื่อเราพบเป้าหมายของชีวิตแล้ว
ก็ เท่ากับเราได้บรรลุเป้าหมายของชีวิต


สมัยยังเป็นนักวิทยาศาสตร์
หลวง พ่อมองผ่านกล้องโทรทรรศน์ เพื่อจะค้นหาความจริงของจักรวาล
แต่ต่อมาแทน ที่จะอยากรู้ว่ามีอะไรบนดวงดาว
หลวงพ่อกลับอยากรู้ว่า ใครกันที่กำลังมองดูดวงดาวเหล่านั้นอยู่
หลวงพ่อใช้การนั่งสมาธิเป็น เครื่องมือที่จะค้นพบคนๆ นั้น
คนๆ นี้คือใครกัน
ใครกันที่กำลังนั่ง ฟังเทศน์อยู่
ใครกันที่กำลังทำอะไรต่อมิอะไร

เป้าหมายทั้งหมดของ ศาสนาพุทธคือการค้นพบเก้าอี้คนขับรถอันว่างเปล่า
เพื่อที่จะหายไป

เรา กำลังทนทุกข์

ยิ่งมีตัวตนมาก ก็ยิ่งทุกข์มาก
ยิ่งหายไปมาก ก็ยิ่งทุกข์น้อยลง

How wonderful it is, to be nothing...

วันศุกร์ที่ 21 ตุลาคม พ.ศ. 2554

GRUB bootloader - Full tutorial

http://www.dedoimedo.com/computers/grub.html
GRUB bootloader - Full tutorial


This tutorial focuses on GRUB legacy. If you're looking for a tutorial on GRUB 2, the next generation of the popular bootloader, please take a look at this article.
One of the most frightening things about Linux is the horrible word bootloader. The primary reason for this is the fact that most new Linux users have only ever used Windows operating systems. In the Windows world, they have never bothered with bootloaders. For them, the issue of a system booting was a transparent one. At most, they would use Windows Recovery Console to fix problems for them. Thus, they have been spared the need to learn about the single most important piece of software on a computer - the little program that makes it all work.
This article is supposed to provide you with basic understanding of the GRUB bootloader. If you have read my other Linux articles, you are familiar with partitioning and Linux notation, as well as with the command line. The next logical step is to enhance this knowledge by taking one step further. Understanding how GRUB works and what boot entries in the boot menu mean will help you understand how the operating systems work, how to fix, recover or modify the GRUB menu to suit your needs, and how to setup different work environments with several operating systems.
In the past, we have relied on the installation setups to make the hard work for us. In fact, setting up GRUB, while frightening, is a quite simple and fully reversible procedure. Mastering the GRUB is a very important step in building up the confidence to use Linux.
So if you are ready, read on.
But first of all, a foreword of wisdom. This article is a compilation of sources and examples that will help you learn about GRUB. Of course, it's all out there somewhere, on the Internet. However, new Linux users will probably find the notion of spending hours searching for relevant pieces of information (especially if their PC won't boot) somewhat frustrating. The goal of this guide is to help provide simple and quick solutions to most common problems regarding multi-boot setups and installation of Linux operating systems.

Table of contents


  1. Everything is a file
  2. Introduction
    1. What about LILO?
  3. How does GRUB work?
  4. GRUB notation
  5. GRUB configuration
    1. Installation of GRUB
      1. GRUB on a floppy disk
      2. Installing GRUB natively
      3. Installing GRUB with grub-install
    2. Setting up GRUB manually (after installation)
      1. Backup!
      2. Adding a new operating system to the GRUB menu
  6. Common problems
    1. GRUB got deleted; how to restore?
      1. The easy way
      2. The hard way
    2. Windows is installed on a non-first hard disk (Swapping)
    3. There is more than one Windows operating system installed on one hard disk (Hide/Unhide)
    4. You resized a partition; GRUB is gone
  7. Useful tools
  8. Extras for special geeks
  9. Links
    1. My other articles
    2. General information (by alphabetic order)

Everything is a file

To be able to successfully master the secrets of GRUB, you must understand one of the basic foundations of *NIX-based operating systems. Everything is a file. Even hard disks and partitions are treated as files. There is no magic. If you remember this, you will find the supposedly perilous task of tampering with partitions no different than playing with files using a file explorer (or the command line).
Now that we have established this, we can move on to the more technical parts of grubbing.

Introduction

GNU GRUB is a bootloader (can also be spelled boot loader) capable of loading a variety of free and proprietary operating systems. GRUB will work well with Linux, DOS, Windows, or BSD. GRUB stands for GRand Unified Bootloader.
GRUB is dynamically configurable. This means that the user can make changes during the boot time, which include altering existing boot entries, adding new, custom entries, selecting different kernels, or modifying initrd. GRUB also supports Logical Block Address mode. This means that if your computer has a fairly modern BIOS that can access more than 8GB (first 1024 cylinders) of hard disk space, GRUB will automatically be able to access all of it.
GRUB can be run from or be installed to any device (floppy disk, hard disk, CD-ROM, USB drive, network drive) and can load operating systems from just as many locations, including network drives. It can also decompress operating system images before booting them.
You can learn much, much more from the official GNU GRUB Manual 0.97.

What about LILO?

You may have heard about another Linux bootloader called LILO (stands for LInux LOader). While a sensible option for many Linux users, I believe that GRUB is a better choice, for several reasons:
  • LILO supports only up to 16 different boot selections; GRUB supports an unlimited number of boot entries.
  • LILO cannot boot from network; GRUB can.
  • LILO must be written again every time you change the configuration file; GRUB does not.
  • LILO does not have an interactive command interface.
All in all, it seems that GRUB is the winner. So let's see what this baby can do.

How does GRUB work?

When a computer boots, the BIOS transfers control to the first boot device, which can be a hard disk, a floppy disk, a CD-ROM, or any other BIOS-recognized device. We'll concentrate on hard disks, for the sake of simplicity.
The first sector on a hard is called the Master Boot Record (MBR). This sector is only 512 bytes long and contains a small piece of code (446 bytes) called the primary boot loader and the partition table (64 bytes) describing the primary and extended partitions.
By default, MBR code looks for the partition marked as active and once such a partition is found, it loads its boot sector into memory and passes control to it.
GRUB replaces the default MBR with its own code.
Furthermore, GRUB works in stages.
Stage 1 is located in the MBR and mainly points to Stage 2, since the MBR is too small to contain all of the needed data.
Stage 2 points to its configuration file, which contains all of the complex user interface and options we are normally familiar with when talking about GRUB. Stage 2 can be located anywhere on the disk. If Stage 2 cannot find its configuration table, GRUB will cease the boot sequence and present the user with a command line for manual configuration.
Stage 1.5 also exists and might be used if the boot information is small enough to fit in the area immediately after MBR.
The Stage architecture allows GRUB to be large (~20-30K) and therefore fairly complex and highly configurable, compared to most bootloaders, which are sparse and simple to fit within the limitations of the Partition Table.

GRUB notation

This section is intended to help you get familiar with GRUB, without touching anything. The next section deals with actual files and manual configuration.
GRUB has its own notation, which is very similar yet somewhat different from the general notation a typical Linux user might be used to.
Now, here's an example of a typical GRUB entry:
(hd0,1)
  • The brackets are a must; all devices listed in GRUB menu must be enclosed in brackets.
  • hd stands for hard disk; alternatively, fd stands for floppy disk, cd stands for CD-ROM etc.
  • The first number (integer for geeks) refers to the physical hard drive number; in this case, the first drive, as they are counted from zero up. For example, hd2 refers to the third physical hard drive.
  • The second number refers to the partition number of the selected hard drive; again, partitions are counted from zero up. In this case, 1 stands for the second partition.
From here, it is evident that GRUB (menu) does not discriminate between IDE or SCSI drives or primary or logical partitions. The task of deciding which hard drive or partition may boot is left to BIOS and Stage 1.
As you see, the notation is very simple.
Primary partitions are marked from 0 to 3 (hd?,0), (hd?,1), (hd?,2), (hd?,3). Logical partitions in the extended partition are counted from 4 up, regardless of the actual number of primary partitions on the hard disk, e.g. (hd1,7).
The entries alone are not enough to boot an operating system though.
GRUB also needs to know what operating system images to load. These are assigned as parameters to each of the called devices, including special flags (switches). For example, Windows Safe Mode is a special flag.
Here is an example of a GRUB menu booting only Ubuntu.
GRUB Ubuntu boot
Here's an example of a GRUB menu from a computer with triple boot (SUSE 10.2, Ubuntu 6.10 and Windows XP). This is the actual menu.lst on one of my real machines.
GRUB triple boot
Let's try to understand what the entries mean. Only uncommented lines count. Comments are marked with #. The lines that have a series of small gray xs showing are in indication that text therein belongs to the line preceding it. In other words, there text simply dropped to another line to visually accommodate the text editor and screen resolution limitations.
default 0
timeout 8
The first line (default 0) means that the first operating system listed will be booted. In this case, it's SUSE 10.2. The second line (timeout 8) tells how much time (seconds) the user has to make his choice before the default entry is loaded. Simple, isn't it?
gfxmenu (hd0,2)/boot/message
The GRUB menu can also be graphic. The fancy stuff needed to present the user with a colorful background and possibly some extras is located on the first physical disk, third partition (hd0,2). This is a primary partition, as we have seen earlier.
title openSUSE 10.2
root (hd0,2)
kernel /boot/vmlinuz-...
initrd /boot/initrd.img-...
This is the first operating system entry in the menu.
  • title is as simple as it sounds. It's merely a string that's meant to help the user read the menu in human terminology.
  • root (hd0,2) tells GRUB where its configuration files are located. In this instance, they can be found under (hd0,2)/boot/grub.
  • kernel /boot/vmlinuz-... boots the actual kernel image. There can be many such images available. The fact there is no device specified before the /boot/vmlinuz indicates the image is located on the same partition as the GRUB itself. This is often the default case for your primary choice of operating system.
  • initrd /boot/initrd.img-... is the temporary file system that makes system preparations - adapts generic kernel image to specific hardware - before the real root is loaded.
The extra switches used after the kernel indicate where the actual root is located, what graphic mode is used and where the swap partition resides. This article will not go into detail regarding the more advanced GRUB configurations.
title Ubuntu, kernel ... (/dev/sda9)
kernel (hd0,8)/boot/vmlinuz-...
initrd (hd0,8)/boot/initrd.img-...
  • Again, title indicates a name, in this case fancily adorned with technical details.
  • kernel (hd0,8)/boot/vmlinuz-... points to the 9th partition on the first hard disk (hd0,8). Accidentally, the root flag (/dev/sda9) indicates that the root partition is the same as the one containing the kernel image. Normally, this is the case, and for the sake of simplicity, you will want this option during your installations.
  • initrd (hd0,8)/boot/initrd.img-... nothing new here.
Note regarding kernel images and root partitions: On older computers with BIOS that do not support access to more than the first 1024 cylinders, you might setup a boot partition that contains the kernel image, while the root itself is located elsewhere. But people with computers younger than the botched Y2K crisis need not worry.
Another thing you might notice is that the Ubuntu entry is fairly detailed. This feature is called Multi-boot Compliance; openSUSE recognizes Ubuntu and can accurately call its images (including special switches) and mount the partitions. However, most operating systems are only partially multi-boot compliant.
A little later on, I will show you how the Ubuntu entry could have been treated differently, with the same results.
title Windows
rootnoverify (hd0,0)
chainloader (hd0,0)+1
  • rootnoverify (hd0,0) means that openSUSE cannot understand Windows operating system, i.e. no multi-boot compliance. Therefore, the operating system is called without any fore-knowledge of the kernel. GRUB assumes that the relevant boot images will be found on the target partition and mounted by the other operating system bootloader. As you can see, Windows was installed on the first partition of the first hard disk. This is the most convenient option.
  • chainloader (hd0,0)+1 feature is used for operating systems that cannot be booted directly. Not surprisingly, Windows operating systems cannot be booted directly. They are booted by the method of chainloading. As the name implies, GRUB passes the control of the boot sequence to another bootloader, located on the device to which the menu entry points. This can be a Windows operating system, but also any other, including Linux.
Back to Ubuntu. You remember that I have told we could have booted Ubuntu in an alternative way? Indeed, we could have simply chainloaded it, just like Windows.
title Ubuntu
root (hd0,8)
chainloader (hd0,8)+1
This would have worked equally well.
The last option in the menu allows you to boot SUSE in the failsafe mode (sort of Safe Mode, no graphics) and does not contribute to our knowledge, therefore we will skip it at the moment.
Let's see some more examples.
The example below is actually written in the Ubuntu menu.lst (commented, of course).
title Windows 95/98/NT/2000
root (hd0,0)
makeactive
chainloader +1

title Linux
root (hd0,1)
kernel /vmlinuz root=/dev/hda3 ro
By now, you should be able to "read" GRUB language with ease. We begin with the title. root specifies the partition where we expect to find the Windows kernel and mounts it (rootnoverify would leave this job to the Windows bootloader). makeactive command sets the active partition on the root disk (above) to GRUB root device. This means that the next command, chainloader, is executed without the target partition specified (as the target partition is the same, now).
The second entry is even simpler. We name a Linux, we call its partition and we boot the kernel. In this case, we see the very interesting case where the kernel image and root (/) partition of the operating system are NOT located on the same partition. This would be a very likely case for older computers - or ones with a specific boot partition.
Finally, the crazy stuff:
A GRUB menu booting 100+ systems of DOS, Windows, Linux, BSD, and Solaris
You see, it's very simple! Once you get the hang of it, it actually becomes fun.
For more information, you must read the GNU GRUB Manual 0.97.
In particular, you need to familiar with The list of command line and menu entry commands.

GRUB configuration

Most of the time, you will not want or need to touch GRUB. When you install operating systems, especially in the right sequence (inconsiderate OS first - like Windows, flexible OS later - Linux and family), the GRUB will be installed automatically and relevant entries appended.
Nevertheless, you should know when and what to do if things go wrong.

Installation of GRUB

GRUB can be installed to a variety of devices. Most people will be interested in setting up GRUB on their hard disk. Nevertheless, it does not hurt to know learn about other options. Of course, you can skip forward.
Before we install anything, we need to know where our files are.
If installed, GRUB menu is located on the root partition under:
/boot/grub/menu.lst
Always, always back this file before making any changes!
The GRUB files can be found in the image of your operating system (usually a CD), under:
/usr/lib/grub/i386-pc
You should also be aware of the basic Linux commands regarding the hard disks and partitions. To this end, you might want to try my article Highly useful Linux commands & configurations.
Nevertheless, for those who do not fancy reading yet another article, here's a brief version:
You can display your PC environment information either through terminal or a text editor. Files through text editor are invoked by specifying the text editor and a target file (with su or sudo for system files).
sudo vi /etc/fstab
OR
sudo gedit /etc/fstab
Alternatively, you can simply print the contents of the files in the terminal by using the cat (concatenate) command.
(sudo) cat /etc/fstab
Some useful commands that one might need when dealing with boot, hard drives and partitions:
Display the partition table:
fdisk -l
Display the mounted partitions:
cat /etc/fstab
Now that we know what we need and where to find it, it's time to install GRUB.

GRUB on a floppy disk

To create GRUB on a floppy disk, we must copy the Stage 1 and Stage 2 files from the image directory to the first and second sector of the floppy disk. We'll use the dd command, which copies information sector by sector.
Here's the set of commands that you need to execute (taken from the Manual):
cd /usr/lib/grub/i386-pc
dd if=stage1 of=/dev/fd0 bs=512 count=1
dd if=stage2 of=/dev/fd0 bs=512 seek=1
Just a short explanation: if stands for input file, of stands for output file, /dev/fd0 refers to the first mounted floppy device, bs specifies the block size (in bytes), count instructs how many blocks should be copied, and seek tells how many blocks should be skipped before writing. Not surprisingly, since we need to write the files to the first two sectors of the floppy disk, we write stage1 to the first sector, and copy stage2 to the second (skip first, then write).
Now that we have taken this deep fancy for the command line, I'll leave you with the nuances of different commands for homework. More on dd on Wikipedia.
Regarding the GRUB on floppy, that's it. Since we have copies the stages from OS image, all of the required information is there. Of course, you can always make manual adjustments. But that's the next chapter.

Installing GRUB natively

Native install means placing GRUB Stage 1 in the first sector of the hard disk (MBR or Partition Table). This means you will be able to boot without a secondary device, like a floppy disk (which have become a rarity nowadays). However, this also means that if you install an inconsiderate OS later on (like Windows) or try to repair the MBR for some reason (by running fdisk /MBR from DOS prompt), you will erase the GRUB and render all systems listed in the menu.lst unbootable.
To install GRUB in MBR, you will need to boot from external media (floppy, live Linux CD). Then, once you reach the GRUB prompt, execute the following commands:
Find the GRUB root device:
find /boot/grub/stage1
GRUB will search for all available Stages 1 and present them. If you have more than one operating system image present (e.g. SUSE, Kubuntu, Mandriva), you will have more than one stage1 available.
Example:
Let's say the computer has the following operating systems installed on different partitions:
  • SUSE on (hd0,1)
  • Kubuntu on (hd0,2)
  • Mandriva on (hd0,4)
All these will be returned as potential roots for GRUB device (as each OS has its own files).
If you wish to use SUSE GRUB, then you will setup the GRUB root device to (hd0,1):
root (hd0,1)
If you want Mandriva's GRUB, then:
root (hd0,4)
If you know in advance what you want to do, you can skip the find command.
Once you have decided on the root, you need to write the information to the MBR:
setup (hd0)
Finally, quit the GRUB prompt:
quit
As a sequence, the commands that you need are:
find /boot/grub/stage1 (optional)
root (hdX,Y)
setup (hd0)
quit
You can also setup GRUB on another drive or partition, but then you will have to chainload GRUB to another bootloader for this to work.
That's it. Easy peasy orange squeasy!

Installing GRUB with grub-install

This method is considered less safe (according to the Manual), as it guesses the mapping. Still, for total newbs in need of dire help, this might be the preferred method.
You only need to invoke a single command - namely, where to install the bootloader. Furthermore, this command can be written in several ways, all equivalent:
grub-install /dev/hda

grub-install /dev/hd0

grub-install '(hd0)'

grub-install hd0
After you have installed the GRUB, your operating systems should boot. Once booted, you can once again start playing with GRUB, manually changing settings - adding and removing entries, chainloading other bootloaders, or even hiding and unhiding partitions.

Setting up GRUB manually (after installation)

You can reconfigure or reinstall GRUB at any moment.

Backup!

First, before you make any changes to the GRUB configuration file, it is most warmly recommended that you backup the existing menu. You might even consider copying to another machine or printing the menu, in case things go bunkerous.
cp /boot/grub/menu.lst /boot/grub/menu.lst_backup
To access GRUB, execute the following command in Linux terminal:
sudo grub
After a few moments, the GRUB command line should show up. You can identify it by the grub> prompt.
GRUB prompt
Alternatively, you can reach the GRUB command line during bootup. When the GRUB menu loads, press C on the keyboard.

Adding a new operating system to the GRUB menu

Let's say you have installed yet another operating system on your machine, Sabayon. During the installation, you skip the GRUB setup. This means that the original GRUB remains untouched - and it does not contain an entry about Sabayon. For all practical purposes, Sabayon is not bootable.
Note: GRUB menu entries are called stanzas (probably a twist of instance?).
So, we need to add Sabayon to the list.
If you know where Sabayon is installed, you just need to add its entry to the menu.lst.
title Sabayon
root (hdX,Y)
chainloader +1
That's it.
You can also do this while booting the computer, without editing the menu. When the original GRUB comes up, press C to reach the command line. And then:
root (hdX,Y)
chainloader +1
Optionally, you will use the find command to get around.
Basically, this is the whole of GRUB magic. As you can see, it's very very simple. But for people who have never heard of GRUB and see long lists of strange commands, the prospect can be daunting.
Now that we have covered the basics of grubbing, it's time for extras and some more common problems.

Common problems

GRUB got deleted; how to restore?

This will often happen if you install Windows after Linux. Windows assumes it's the only operating system in the world and does not try to live with existing information present in the MBR; it overwrites it. For people with dual-boot and very little knowledge of Linux, this is a disaster. Luckily, it's very easily recoverable one.

The easy way

Use Super Grub Disk. I have written about this tool in detail in my article A (cool) list of Linux tools, under Rescue.

The hard way

  • Boot from floppy disk or CD (any Linux live CD should do).
  • Get to the grub command line.
find /boot/grub/stage1 (optional)
root (hdX,Y)
setup (hd0)
quit
The same as before!

Windows is installed on a non-first hard disk (Swapping)

GRUB cannot directly boot Microsoft operating systems. And sometimes, even chainloading may not work, especially if Windows is not installed on the first hard disk. Once again, you should remember that you should always install Windows first, on the first hard disk, on the first partition (the rule of three first). Nevertheless, even if you have Windows installed on a separate disk, you can solve the problem by swapping.
You need to perform a virtual swap between hard disks. Like this:
map (hd0) (hd1)
map (hd1) (hd0)
After you add these two lines, you should be able to boot into Windows (or DOS, for that matter).

There is more than one Windows operating system installed on one hard disk (Hide/Unhide)

Again, Windows can cause problems if there's more than one instance present on a hard disk, especially if installed on primary partitions. When you use the chainloader command, the control is transferred to the Windows boot loader, but which one?
The problem is easily solved by hiding and unhiding partitions. If GRUB hides a partition, it will not be visible by Windows and prevent a possible confusion. Vice versa, if you unhide a partition, Windows will detect it and be able to boot from it, without getting confused.
Here's the example taken from the Manual that demonstrates this point.
Let's say we have Windows installed on the first and the second partition of your hard disk. We wish to boot the first instance of Windows. Then, we need to execute the following set of commands to make it all work:
unhide (hd0,0)
hide (hd0,1)
rootnoverify (hd0,0)
chainloader +1
makeactive

You resized a partition; GRUB is gone

This is an interesting case. It can happen after you use a partitioning or an imaging software to make changes to the Partition Table. Usually, this will happen when you make such a change in Windows. Linux will not be informed of the change, because Windows is blind to anything else on the machine save Microsoft thingies. Consequently, GRUB will suffer.
The solution is that most likely the filesystem is damaged and needs to be repaired.
Boot from a live CD and execute the following commands, assuming you know where Linux partitions are.
Check the filesystem:
fsck.ext2 /dev/hdXY
Replace X and Y with hard disk letter and partition number that you want to check (hda2, hdb3, etc.).
Create the ext2/3 filesystem parameters again.
tune2fs -j /dev/hdXY
Now mount the root filesystem on /mnt/sysimage and run grub:
mount -t ext2 /dev/hdXY /mnt/sysimage
OR
mount -t ext2 /dev/hdXY /mnt/sysimage

cd /mnt/sysimage/sbin
grub
You're back to the familiar grounds.
For more information on Linux commands, including fsck.ext2, tune2fs and others, see Manual pages on Linux Reviews.
Finally, some more tricky questions answered in Ubuntu wiki:
How to restore GRUB menu after Windows installation
How to identify the name of the boot drive (hd0, hd1, hd2, etc)
How to add Windows entry into GRUB menu
How to boot into Windows installed on a separate SATA drive

Useful tools

GParted
GParted is a Gnome Partition Editor. Although Linux-based, it fully supports the NTFS file system. It runs from a CD.
SystemRescueCD
This is a live CD specifically geared toward rescue and recovery. The tools package includes some of the most important tools available for Linux user, like GParted, QTParted, Partimage, Grub, Lilo, sfdisk, security tools, network tools, and more.
Super Grub Disk
Super Grub Disk is intended to run from a floppy disk or CD and is used for system rescue. Most importantly, it can be used to restore boot loaders, including GRUB, LILO and even Windows boot loader.
TestDisk
TestDisk is a utility specially designed to recover lost partitions and make non-booting disks bootable again. This highly useful tool can be found on a number of live CDs, including Knoppix and GParted. It supports NTFS partitions and also comes in Windows flavor.

Extras for special geeks

Multiboot with GRUB Mini-HOWTO
How To Multi-boot Operating Systems
How to boot Ubuntu from the Windows Bootloader
Filesystems and Mounting

Links:

GNU GRUB
GNU GRUB FAQ
GNU GRUB Manual 0.97
The list of command line and menu entry commands
GNU GRUB on Wikipedia
A GRUB menu booting 100+ systems of DOS, Windows, Linux, BSD, and Solaris

My other articles:

Highly useful Linux commands & configurations
A (cool) list of Linux tools

General information (by alphabetic order):

cat
dd
initrd
LILO
Logical Block Address
Manual pages (man) on Linux Reviews
NTLDR
That's it. Enjoy!