Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Saturday, June 28, 2008

Some tips about hard disk

Just faced a 24-mount forced check by fsck today (on Debian using ext3). So I'd like to increase mount times to 2 folds before beginning the forced check. After googling around a bit, I found it here.

$sudo tune2fs -c 60 /dev/hda6


This means the maximum mount time increases to 60 times before starting the forced mount check. Anyway, it is not a good idea to disable the forced check.

Next is to find the UUID (Universally Unique Identifier) of the hard disk. It is useful to identify your hard disk regardless of order of installation. For example, if the first hard disk is sda and the second hard disk is sdb and they both have different file system. When you swab the cable (and port) this nomenclature will change and what in /etc/fstab will not work. But if the UUID is used, both hard disks are still be mounted correctly. Alright, this is how to get your UUID:


Use ls


$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 2008-06-28 21:05 B628CC5228CC1373 -> ../../hda1
lrwxrwxrwx 1 root root 10 2008-06-28 21:05 bb34fd58-ca7a-499e-a74c-fe8ba771a148 -> ../../hda6
lrwxrwxrwx 1 root root 10 2008-06-28 21:05 c1fdb5ad-05d6-47f5-b6eb-852bb834df55 -> ../../hda7


or this command


$ blkid /dev/hda6
/dev/hda6: UUID="bb34fd58-ca7a-499e-a74c-fe8ba771a148" TYPE="ext3"


That's all for today...

Sunday, June 08, 2008

Life with Debian - memo

วันก่อนหาเรื่องยุ่งโดยการพยายามอัปเกรด Kubuntu Gutsy ให้เป็น Hardy โดยเริ่มจากการใช้ upgrade wizard ให้อัปเกรดผ่านเครือข่าย (เพราะโควต้าของเดือนเหลืออีกเยอะ) หลังจากทำเสร็จบูตใหม่มีปัญหาเม้าส์ใช้ไม่ได้ซะงั้น (แต่ trackpad ใช้ได้) เลื่อนตัวชี้เม้าส์ไม่ไปเอาเลย ตอนนั้นยังมึนๆ ไม่มีความคิดในการค้นหาข้อมูลอะไรเท่าไหร่ และไม่รู้ด้วยว่าเกิดจากอะไร (ตอนนี้พอคาดได้ว่าอาจเกิดจากการหันไปใช้ x.org 7.3 และเกิดความไม่เข้ากันบางประการกับ evdev เพราะตอนเปลี่ยนมาเป็น Debian ก็คล้ายๆ กัน) แต่รู้สึกว่า ถ้าใช้พวก *buntu ควรจะ out of the box เลยตัดสินใจลองลงใหม่แบบ clean install (ก็ไม่สะอาดมาก ยังเก็บพวกแฟ้มตั้งค่าทั้งหลายเอาไว้ใน /home partition) ลงเสร็จก็อัปเกรดแพ็คเกจต่างๆ ตามที่มันเตือนให้อัปเกรด เสร็จแล้วลองใช้ไป เจอปัญหาเดิม - -' แถมด้วยทีนี้ล็อกเอาท์ไม่ได้ พอล็อกเอาท์แล้วหน้าจอมืดไปเลย แต่ถ้า shutdown ไปเลยหรือ reboot ได้ตามปกติ ตอนนั้นคิดได้ว่า...

  1. ไม่น่าเลยกู ใช้ Gutsy ได้ดีๆ ไม่เอา
  2. LTS=ต้องรอไปใช้ปีหน้ารึเปล่าฟะ ชักเหมือน M$ ที่ถ้าจะเปลี่ยนจริงๆ กรุณารอ SP[123...]
  3. มีตัวอย่างเยอะแยะ เช่น Plynoi เป็นต้นทำไมไม่เชื่อมัน (เค้าว่ากาลามสูตรไง :P)
  4. ...

เป็นต้น

ทีนี้ชั่งใจอยู่นานว่าจะเอาไงกะมันดี ทั้งมีคนยุให้ลง gentoo ซะเลย แต่ก็อย่างที่บอกผมรู้สึกว่า gentoo นี่มันเสียเวลาทำมาหากิน เลยตัดสินใจลง Debian ดีกว่า หลังจากคราวที่แล้วลงไปแล้วไม่สัมฤทธิ์ผล หันกลับไปหา Gutsy ใหม่ เอาเหอะ ลงก็ลง ไหนๆ ก็รู้สึกว่า Hardy มันไม่ค่อยสมบูรณ์ คราวนี้ทำใจกล้าลง debian unstable ซะเลย ใหม่ดี เหอๆ

เริ่มจาก ดาวน์โหลด testing snapshot CD + KDE ของวันที่ 02062008 มาซะเผาลงแผ่นแล้วก็บูต จัดการ format partition ที่เป็น system เดิมแล้วให้ mount /home ที่เก่า (แนะนำให้แบ่ง /home เป็นอีก partition นึง ถ้าไม่มีอะไรผิดพลาด การตั้งค่าต่างๆ เกือบทุกอย่างและข้อมูลในนั้นยังอยู่ครบ) ลงแผ่นนึงแล้วให้มันดาวน์โหลดที่เหลือจากอินเทอร์เน็ต คืนนั้นใช้เวลาไปกว่าสามชั่วโมง เพราะว่าช่วงนี้ noise ในสายโทรศัพท์มันเยอะเป็นบ้า ความเร็วตกเหลือไม่ถึงเม็ก T_T (วันก่อนทำความสะอาดไปได้มา 6 เม็กกว่าๆ อีกไม่กี่ชั่วโมงกลับไปเท่าเดิม T_T)

เอ้า ลงเสร็จบูตใหม่ ไหง kdm ไม่ขึ้น ขึ้นแต่ login prompt...

แสรดดด ...

เอ หรือว่ามันจะมีการบูตด้วย runlevel ที่ไม่มี graphic mode ลอง startx ซิ

ได้ผล ... ขึ้น TWM ไม่ใช่ KDE ... แสรดดด

ลองเล่นๆ ดู โคตร primitive แต่ยังดีที่ยังมีอย่างอื่นมาพอสมควร -> iceweasel เป็นต้น เลยยังพอ surf อินเทอร์เน็ตได้ ระหว่างนั้นลอง apt-get นู่นนี่อีกหลายอย่าง ปรากฏว่ามีมั่งไม่มีมั่ง กำลังสงสัยว่าเป็นที่แหล่งสำเนา (mirror) หรือเปล่า (ใช้ของ aarnet.edu.au) เลยเปลี่ยนแหล่ง repo เป็น ftp.au.debian.org แล้วก็เปลี่ยน dist จาก lenny เป็น unstable ทั้ง main, contrib, non-free ซะ ก่อนที่จะ
#apt-get update
#apt-get dist-upgrade


เอาล่ะ ทีนี้นั่งหา window manager ที่มัน primitive น้อยลงหน่อย เผอิญหันไปเห็น Window Maker เลยเอานี่แหละ เรียบ ง่าย สวย เร็ว เล่นไปเล่นมาซักพัก ก็จัดการ add printer ก่อนผ่าน CUPS (localhost:631) เรียบร้อย ก็ยังเหลืออะไรที่ต้องทำเพิ่มให้มันใช้ได้เหมือนตอนใช้ kubuntu อีกพอสมควร

ก่อนอื่นคือติดตั้ง KDE :P

ลงเสร็จ amarok มันเล่น mp3 ได้เลยแฮะ ไม่รู้มันเอา codec มาจากไหน ยังงงๆ อยู่

ต่อไปคือ ผมติดการใช้ sudo ซะแล้ว แต่ตอนนี้ต้อง su แทน ก็เลยลง sudo แต่ก็ยังใช้ไม่ได้เพราะว่า ยังไม่ได้ใส่ชื่อตัวเองลงไปใน sudoers จริงๆ ก็ไม่ได้รังเกียจ su หรอก แต่ว่าบางที apt-get อะไรทิ้งไว้ก่อนเข้านอน พอเสร็จมันก็เป็น root อยู่อย่างนั้นมันเสียวๆ ไงไม่รู้ สรุปก็เพิ่มชื่อตัวเองเข้า sudoers chmod +w ให้เขียนได้ก่อนแล้วเพิ่ม

user_name ALL=(ALL) ALL


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

ต่อไปทีนี้เป็นเรื่องการเข้าถึงไดรว์ฟ ntfs ปรากฎว่า ไม่สามารถเมานท์ได้ในฐานะ user ปกติ โดยใช้ ntfs-3g ก็ตามหากันต่อไปว่าทำอย่างไรดี หาไปหามาก็เจอที่เว็บของเค้าเองแหละ ก่อนอื่นลง FUSE ซะก่อน (libfuse2, fuse-utils) แล้ว add ตัวเองเข้ากลุ่ม fuse, disk จากนั้นเปลี่ยน permission โปรแกรม ntfs-3g โดยการ setuid root ให้ซะ แบบนี้

sudo chmod 4755 /usr/bin/ntfs-3g


ซึ่งจะทำให้ permission มันกลายเป็น

$ ls -l /usr/bin/ntfs-3g
-r-Sr-sr-t 1 root root 35460 2008-05-29 05:22 /usr/bin/ntfs-3g


แล้วอย่าลืมเติม entry เข้าไปใน /etc/fstab ด้วย แบบนี้

/dev/hda1     ntfs-3g     user,noauto,rw,umask=0,nls=utf8    0     0


ทีนี้เราก็สามารถเมานท์ ntfs ได้ในฐานะ user ทั่วไปแล้ว แถมเขียนได้ด้วย เฮ่อ~~

ยังไม่จบแค่นี้ ยังต้องหาทางทำให้เม้าส์ VX Rev. มันใช้ได้ครบทุกปุ่มก่อน ลอง evdev ตอนนี้ยังไม่ work ตรง side scroll มันไม่เจอว่าเป็นปุ่ม ตรง Zoom อีก ถ้าทำได้แล้วก็จะมาบันทึกเพิ่มต่อไป


Wednesday, September 13, 2006

Finally, I switched to Kubuntu

At this time, I think there's no GNU/Linux distro that is more popular than the Ubuntu family (Ubuntu, Kubuntu, Xubuntu and Edubuntu). Secrets behind this success may be the ease of use and installation (some said that even their grandmas can install Ubuntu), community support, fresh new stuffs in the repository as well as marketing. However, this episode is not a review because many blogs have done that already. It's just my experience about migration from another distro to Kubuntu.

My previous distro is PCLinuxOS. It's a great distro providing many great components, community support as well as many (somewhat) up to dated software repositories. However, I had messed it up trying to manually install a program that has a conflict with the installed version (okay, it's DBUS). After that, it lost its ability to detect newly attached hardwares. Moreover, I had a problem with Konqueror saying that it freezed repeatedly when trying to open some certain web pages, for examples, kde-look.org and some Thai homepages. I tried to find many solutions including upgrading KDE, changing fonts, disabling java, etc... but no luck at all. After screwing up PCLinuxOS, I decided to give Ubuntu family a try and chose Kubuntu because it use KDE as its desktop.

However, I took more than two days to migrate from PCLinuxOS to Kubuntu. Why? Firstly, because I chose to keep my old /home partition and use the same username as in PCLinuxOS. This caused some problems. KDE couldn't start at the first time because of the remaining settings in my old home directory. The solution was to remove all KDE related settings (.kde directory). Some applications couldn't run at first because of the same problem, therefore, I decided to remove all settings from my home directory T_T (my god, all of my bookmarks). Secondly, there were so many updates for the installed softwares at the time I installed Kubuntu. I had to download all of them and took more than half a day. It looks like a "fresh Windows installation nightmare". Thirdly, Kubuntu does not provide my everyday life programs out of the box, so that I had to apt-get all of them. I had built Bon Echo 2.0 beta2 on PCLinuxOS but it did not work on Kubuntu at first because it had no gtk2!!! Okay, I could apt-get it all, though it took me another day, no problem. Fourthly, it came to multimedia problems. As you know that Ubuntu family does not provide codecs for restricted formats such as mp3, wma, wmv, dvd and so on, so that you have to download and install these codecs yourself. However, it is easier using EasyUbuntu which will manage to download and install all codecs, plugins and many more you need to your box. Next, NTFS problem, I could mount my Windows partition but couldn't access it unless I am a root. The solution was to add


/dev/hda1 /media/windows
ntfs noauto,user,exec,suid,nls=utf8,umask=0222 0 0


to /etc/fstab. Also, I had a problem seeing files that their names are Thai characters in the NTFS partition. Actually, it's not a problem at all if Konqueror is set to use Thai font for icon or filename. Finally, language problem, there's no Thai kde-l10n in the repository so that Kubuntu cannot display Thai interface. I know, I know, it's my fault. So, please wait until KDE 4 is included to the repository ;).

After a few days of finding packages, apt-get and configuration, my Kubuntu laptop is fully equipped with my everyday programs, codecs, plugins, my favourite games and ready to work now. Hope that I will not screw it up again so soon.

Tuesday, August 29, 2006

OpenOffice.org Uninstallation

จั่วหัวซะน่ากลัว แต่จริงๆ ก็ไม่มีอะไรมาก แค่คิดว่าทำไมตัว OpenOffice.org สำหรับ Linux ซึ่งมาเป็นชุด rpm ชุดใหญ่ มันดันไม่มีเครื่องมือสำหรับติดตั้งและยกเลิกการติดตั้งติดมาให้ด้วย

จริงๆ แค่คิดจะติดตั้งก็ยากแล้วสำหรับบางคน เค้าคงคิดว่าคนใช้ Linux ก็ต้อง Geek ระดับนึงละมั้งซึ่งที่จริง มันไม่ใช่แบบนั้น ผมเองยังงมหาวิธีติดตั้งนานพอดู (เพราะไม่รู้ว่า rpm มันใช้ wild card ได้ด้วย) สำหรับการติดตั้งโปรแกรมก็เคยเขียนไว้ทีนึงแล้วที่นี่ ก็แค่สั่ง rpm -Uvh *.rpm ในไดเร็คทอรีที่เก็บชุดโปรแกรมเอาไว้ก็แค่นั้นตัว rpm จะจัดการติดตั้งให้ตามลำดับเรียบร้อยไม่ต้องห่วงเรื่อง dependencies

ทีนี้ บางคนอาจจะรู้สึกว่า OO.o ไม่ค่อยเหมาะกับเราแฮะ หรืออาจจะอยากใช้ KOffice หรือ Abiword/GNOME Office แทน แล้วก็อยากจะลบ OO.o ทิ้ง ทีนี้ทำไงดี (จะมีไหมเนี่ย ผมว่า OO.o เป็นชุดออฟฟิศที่เหมาะกับคนไทยมากที่สุดแล้วหละ) เก็บเอาไว้ก็เปลืองฮาร์ดดิสก์ ก็เป็นที่มาที่อยากจะเขียนตัว uninstall ซะเลย ทีแรกก็เขียนเป็น text mode ก่อน ต่อมาก็ซนอยากเขียนให้มันมี GUI มั่งก็เลยใช้ประกอบกับ Kdialog

หลักการทำงานก็ไม่มีอะไรมาก ก่อนอื่นหามาให้ได้ก่อนว่า packages ที่ทำการติดตั้งลงไปเนี่ยมันมีอะไรบ่้าง แบบนี้

rpm -qa |grep openoffice


ซึ่งมันจะ return ค่าออกมาแบบ

openoffice.org-[package]-[version]


เป็นจำนวนมากคิดว่าได้ทั้งหมด 26 packages หลังจากนั้นก็ตัดส่วนที่แสดงเวอร์ชันออกแล้วเก็บทั้งหมดลงไฟล์ชั่วคราวแล้วใช้ for loop เพื่อทำการ uninstall ด้วยคำสั่ง


for package in `cat $tmpfile`
do
rpm -e --nodeps $package
done


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

ข้อเสียจากการใช้สคริปต์นี้คือ มันช้าโคตร เพราะว่าใช้ rpm -qa ทำการหา packages หลายรอบ ยังหาวิธีการจัดการกับ rpm package ที่ดีกว่านี้ไม่ได้ แถมพอใช้ร่วมกับ Kdialog ก็ทำให้ผู้ที่สามารถ run script นี้ได้เต็มรูปแบบก็มีแต่ root อีก (คือต้อง login เป็น root เพราะ su จะมีปัญหาเวลาเรียกใช้งานโปรแกรมที่เป็น X นอกจากจะ export display ออกไปให้คำสั่ง su สามารถใช้ display ได้ด้วย แต่ตามค่าปริยายแล้วเป็นสิ่งที่ไม่ควรทำ) ใช้ kdesu ก็ไม่ได้ สคริปต์มันไม่ทำงานต่อ ถ้าใครจะปรับปรุงสคริปต์นี้มห้มันดีขึ้นก็ได้นะ ไม่ว่ากัน และขอขอบคุณด้วย

ลองดูสคริปต์ได้ ที่นี่ ครับ