Oct 10, 2008

Install Guest Additions for Debian

如果你像我一样是在虚拟机中安装的Debian,那么安装好系统之后的第一件事应该是Install Guest Additions,缺了这玩意儿实在太不方便了。头一次安装Debian,没想到就碰了很大的钉子,搜索了半天,终于解决了,记录如下。

这时候,VBoxLinuxAdditions.iso一般都直接挂载好了,本想直接运行
sudo sh /media/cdrom/VBoxLinuxAdditions.run
来安装,命令没错,不过还不是时候,因为Debian默认新建的用户没有权限使用sudo(这个应该可以完善吧?)。此时会出现如下提示:
××× is not in the sudoers file . The incident will be reported。。。
其中×××是你的用户名,下同。

接下来就是赋予你的用户名sudo权限:
1、进入超级用户模式:su -
2、添加文件写权限:chmod u+w /etc/sudoers
3、编辑/etc/sudoers:vim /etc/sudoers
在"root ALL=(ALL) ALL"一行下面添加一行"××× ALL=(ALL) ALL"
不过,我在这里遇到了错误,后来把root那行复制,再把root改成自己的用户名才搞定。(root后面好像是个tab键?)
4、撤销文件的写权限:chmod u-w /etc/sudoers
然后退出root:su ×××

再次运行 sudo sh /media/cdrom/VBoxLinuxAdditions.run,又会出现如下错误提示:
“please install the build and header files for your current linux kernel.”
解决办法是安装以下两个文件:
sudo apt-get install build-essential linux-headers-`uname -r`

又会出现如下提示:
Media change: please insert the disc labeled...

此时需要修改source.list文件,如果你的电脑已经联网的话,并确保有其他的源,就把cdrom相关行删掉,保存就可以了。例如,
# deb cdrom:[Debian GNU/Linux 4.0 r4a _Etch_ - Official i386 DVD Binary-1 20080803-20:48]/ etch contrib main

deb cdrom:[Debian GNU/Linux 4.0 r4a _Etch_ - Official i386 DVD Binary-1 20080803-20:48]/ etch contrib main

再次运行
sudo apt-get install build-essential linux-headers-`uname -r`
重启X Window确保VBoxLinuxAdditioons虚拟光盘已挂载,此时再运行
sudo sh /media/cdrom0/VBoxLinuxAdditions-86.run (根据你的电脑配置选择运行文件)
重启就ok了。


参考资料:1.http://blog.chinaunix.net/u2/78601/showart_1271226.html
2.http://ubuntuforums.org/archive/index.php/t-446927.html

No comments:

Post a Comment