顯示具有 Ubuntu 標籤的文章。 顯示所有文章
顯示具有 Ubuntu 標籤的文章。 顯示所有文章

2009年4月15日 星期三

如何刪掉所有指定檔名的 command in Mac/Linux

日前遇到了一個問題需要刪掉 Folder 下所有檔名有 ".D" 開頭的檔案,
於似乎請教了高手, 找到了這個答案.

find ./ -type f -name ".*" -exec rm {} \;
".*" 的內容可以自行修改

可以徹底的刪掉不必要的, 擾人的檔案囉.

2008年4月23日 星期三

Create a separate home partition in Ubuntu

Create a separate home partition in Ubuntu

Introduction
This guide is for creating a separate /home partition if you already installed Ubuntu without a /home partition (i.e., /home is just a folder inside your / partition). If you have not yet installed Ubuntu but want to create a /home partition before installing (a very good idea, by the way), use this guide. If you want to know more about partition planning, read this.

Important Disclaimers

  • Even though I created the form of this tutorial, the steps outlined in it are taken directly from a text-only (command-line-driven) guide for this process.
  • I and others have been successful in creating a separate /home partition using this tutorial, but there are many who have had difficulty being successful with the process. If you are not confident in what you're doing or in repairing or recovering from this process should anything go wrong, then do not attempt the instructions outlined here. I cannot help you troubleshoot problems that result from following this tutorial.
  • Creating a separate /home partition involves resizing at least one existing partition. In almost all cases, the resizing of partitions does not result in data loss, but there still exists a (however small) risk of data loss, so you should back up your important data before attempting to resize your partitions.
  • The tutorial was created a long time ago using an older version of Ubuntu. The same principles should still work for recent versions of Ubuntu, but you may see little discrepancies in form (for example, the use of UUIDs in the /etc/fstab file).

Requirements
You must use a live CD for this process, for two reasons:

  1. In order to resize your existing / partition, it needs to be unmounted. The only way to unmount it is for it not to be in use, which means you can't boot to your regular Ubuntu installation while resizing it... which means you need a live CD
  2. If you screw up your installation by accident, you can use the live CD to restore your old settings and, in the worst situation, at least recover your important files

I'm using the example of a Ubuntu live CD and GParted, but you can very well use QTParted on Knoppix or DiskDrake on PCLinuxOS.

Making the new partition
Boot up a live CD and in your live session, install GParted (and ntfsprogs, just in case you're carving a partition out of an existing NTFS partition... before resizing an NTFS partition, though, make sure you defragment it in Windows). You can use Synaptic Package Manager to install it (Don't know what Synaptic is? Look here, or if you prefer the command-line, go to the terminal and type in

sudo apt-get update && sudo apt-get install gparted ntfsprogs

Then, press Alt-F2 and type

gksudo gparted

In GParted, find the partition you want to resize in order to make room for your upcoming /home partition. In this case, I'm resizing /dev/hda5, but your partition may be different. Be sure to keep track of the names of your partitions--these names are very important (/dev/hda1, /dev/hdb1, /dev/sda2, etc.).

Right-click on the partition and choose the Resize/Move option.

Choose the new size you want.

Then, in the new empty space, right-click and select New.

Choose to create the partition as Filesystem ext3.

When you're satisfied with your new partition layout, click Apply

Once the changes have been applied, make note of the partition name of your new partition and then quit GParted.

Now, in my example, my original partition that I shrunk was /dev/hda5, and it created a new partition called /dev/hda7, and my /home folder lives on /dev/hda1. It's very important that you substitute in your own appropriate partition names for the ones I'm using--you most likely will have only two partitions you're dealing with--the one you shrunk and the newly created one.

Using the new partition
Now, back in the terminal, I'm going to mount /dev/hda1 and /dev/hda7:

---------------------------------------------------------------------------------
sudo mkdir /old
sudo mount -t ext3 /dev/hda1 /old
sudo mkdir /new
sudo mount -t ext3 /dev/hda7 /new

---------------------------------------------------------------------------------

Now we're going to back up the /home directory on the old partition and move it to the new partition:

---------------------------------------------------------------------------------
cd /old/home
find . -depth -print0 | sudo cpio --null --sparse -pvd /new/
sudo mv /old/home /old/home_backup
sudo mkdir /old/home
---------------------------------------------------------------------------------

Yes, one of those lines looks really complicated--please type it as is--or, if you're unsure of your typing skills, copy and paste it into the terminal. Believe me--the command is necessary.

Next, we're going to specify to use the new home partition as /home:

---------------------------------------------------------------------------------

sudo cp /old/etc/fstab /old/etc/fstab_backup
sudo nano /old/etc/fstab
---------------------------------------------------------------------------------

You'll then be taken to the nano text editor. Add in this line:

---------------------------------------------------------------------------------

/dev/hda7 /home ext3 nodev,nosuid 0 2
---------------------------------------------------------------------------------

Then save (Control-X), confirm (Y), and exit (Enter)

After you reboot, you should be now using your new /home partition.

If you find that you are running out of room on your old partition and you're pretty confident everything is working as it should be, then go ahead and delete the backup of home:

---------------------------------------------------------------------------------

sudo rm -rf /home_backup
---------------------------------------------------------------------------------

What if it doesn't work?
You know, it really should work, but if you somehow messed up your /etc/fstab and didn't configure it correctly... well, that's why we have a live CD, so we can fix things.


Boot up the live CD, go to a terminal, and type:

---------------------------------------------------------------------------------

sudo mkdir /recovery
sudo mount -t ext3 /dev/hda1 /recovery
sudo cp -R /recovery/home_backup /recovery/home
sudo cp /recovery/etc/fstab_backup /recovery/etc/fstab
---------------------------------------------------------------------------------

Then, reboot.

2008年3月9日 星期日

Install ATI driver

1.首先到 ATI 下載最新的 7.12 (8.443) X86驅動程式


2.編譯前的準備工作

sudo apt-get install module-assistant build-essential fakeroot dh-make debhelper \
debconf libstdc++5 linux-headers-generic dkms
LANG=C
sudo apt-get update
sudo apt-get install module-assistant build-essential fakeroot dh-make debhelper debconf libstdc++5 linux-headers-$(uname -r)


3.刪除之前的函式庫

sudo rm /usr/lib/libGL.so*


4.編譯deb

首先cd到放置驅動程式的目錄裡

gusty 7.10:
bash *.run --buildpkg Ubuntu/gutsy

Feisty 7.04:
bash *.run --buildpkg Ubuntu/feisty


5.屏蔽fglrx核心模組

如果安裝過linux-restricted-modules,那麼此步必做!
否則可以跳過,不過一般都要做.

sudo gedit /etc/default/linux-restricted-modules-common

將裡面的

DISABLED_MODULES=""

改成

DISABLED_MODULES="fglrx"


6.安裝剛剛編譯好的deb

sudo dpkg -i xorg-driver-fglrx_*.deb fglrx-kernel-source*.deb fglrx-amdcccle*.deb


7.移除舊的fglrx

如果是第一次安裝,會提示找不到該文件的訊息.
別理他,照做就是了..

sudo rm /usr/src/fglrx-kernel*.deb
sudo apt-get -f install


8.編譯內核模組並安裝

sudo module-assistant prepare
sudo module-assistant update
sudo module-assistant build fglrx
cd /usr/src
sudo dpkg -i fglrx-kernel-*.deb
sudo depmod -a


9.配置驅動程式

sudo aticonfig --initial -f
sudo aticonfig --ovt=Xv

跟在/etc/X11/xorg.conf裡手動添加以下兩句是一樣的意思
Option "VideoOverlay" "on"
Option "OpenGLOverlay" "off"


10.把以前xorg.conf裡不支援aiglx的語句修改掉。

sudo gedit /etc/X11/xorg.conf

將裡面的

Section "Extensions"
Option "Composite" "0"
EndSection

Section "ServerFlags"
Option "AIGLX" "off"
EndSection

改成如下

Section "Extensions"
Option "Composite" "1"
EndSection

Section "ServerFlags"
Option "AIGLX" "on"
EndSection


11.按下Ctrl+Alt+Backspace重新啟動X-Window,以確認驅動程式是否安裝好

fglrxinfo

display: :0.0 screen: 0
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: ATI MOBILITY RADEON X700
OpenGL version string: 2.1.7170 Release
#秀出ATI顯示卡型號及相關資訊才是正確的

glxinfo | grep render

direct rendering: Yes
OpenGL renderer string: ATI MOBILITY RADEON X700
#如果開啟了xgl,那麼這裡一定是No,還有其他的一些訊息


12.開啟3D桌面,讓Compiz Fusion工作

SKIP_CHECKS=yes compiz

#看看將視窗最大最小化時,是否有3D的效果?
如果有,就表示成功囉..

mkdir -p ~/.config/compiz && echo SKIP_CHECKS=yes >> ~/.config/compiz/compiz-manager

#重啟一下看看是不是開機自動開啟了桌面特效,應該這樣就可以了。
如果不行的話,手動點擊桌面特效裡面的選項,把桌面特效給打開。


  
常見錯誤:

1.如果你碰到2D加速很慢的情況,在/etc/X11/xorg.conf 的 Device section
(就是有fglrx的那段)中添上

Option "XaaNoOffscreenPixmaps"


2.如果沒有3D加速,可嘗試

sudo mkdir /lib/modules/$(uname -r)/volatile
sudo ln -sf /lib/modules/$(uname -r)/misc/fglrx.ko /lib/modules/$(uname-r)/volatile/fglrx.ko
 

3.如果說/usr/X11R6/lib/modules/dri/fglrx_dri.so缺失,則執行

sudo ln -s /usr/lib/ /usr/X11R6/lib/modules


4.如果執行fglrxinfo出現 libGL.so.1: cannot open shared object file,則

sudo ln /usr/lib/libGL.so.1.2 /usr/lib/libGL.so.1


5.如果還有其他問題,比如nforce3的晶片(主要是asus的K8N),
說你仍然運行於mesa,無3D加速,可以看這裡:

http://wiki.cchtml.com/index.php/Troubleshooting


  
參考資料:

http://forum.ubuntu.org.cn/viewtopic.php?t=26188
http://wiki.cchtml.com/index.php/Ubuntu_Gutsy_Installation_Guide
 
  
  
安裝時遇到的狀況:

1.全部完成重開機後,/etc/X11/xorg.conf 裡會多出一行敘述!

Section "Extensions"
Option "Composite" "1"
Option "Composite" "0" #多餘的,請刪除..
EndSection


2.第一次安裝失敗重新安裝,在安裝編譯好的deb時出現錯誤

正在設定 fglrx-kernel-source (8.443.1-1) ...
Adding Module to DKMS build system

Error! DKMS tree already contains: fglrx-8.443.1
You cannot add the same module/version combo more than once.
Doing initial module build

Error! This module/version has already been built on: 2.6.22-14-generic
Directory: /var/lib/dkms/fglrx/8.443.1/2.6.22-14-generic/i686
already exists. Use the dkms remove function before trying to build again.
Installing initial module

Error! This module/version combo is already installed
for kernel: 2.6.22-14-generic (i686)
Done.

#由於找不到dkms的相關說明,一值無法解決這個問題,只好還原系統重新安裝.


2.一樣是在安裝編譯好的deb時出現錯誤!

正在設定 fglrx-amdcccle (8.443.1-1) ...

Processing triggers for libc6 ...
ldconfig deferred processing now taking place
/sbin/ldconfig.real: /usr/lib/libGL.so.1.2 is not a symbolic link
/sbin/ldconfig.real: /usr/lib/libGL.so.1 is not a symbolic link

#參考ATI wiki上的步驟,在編譯前先將原來的函式庫刪除就OK了!

Reference link:

Installing Ubuntu 7.10 (Gutsy Gibbon) on a Thinkpad T60

Fglrx

Ubuntu Gutsy Installation Guide