Ubuntu文字终端分辨率

原文:http://blog.csdn.net/shiyanhui66/article/details/6007280

喜欢ubuntu的绚丽的桌面效果,这需要装上英伟达驱动。但是装上之后发现终端的分辨率变低了,这令我十分不爽。google了一下,终于找到了解决办法,只需要将grub文件改一下就行了。具体如下:

安装v86d和hwinfo包

v86d - daemon to run x86 code in an emulated environment

hwinfo - Hardware identification system

sudo apt-get install v86d hwinfo

查看显卡支持的分辨率

sudo hwinfo --framebuffer

我的是:

    02: None 00.0: 11001 VESA Framebuffer
      [Created at bios.464]
      Unique ID: rdCR.sbqupgMqM7F
      Hardware Class: framebuffer
      Model: "NVIDIA G96 Board - kl1_n10p"
      Vendor: "NVIDIA Corporation"
      Device: "G96 Board - kl1_n10p"
      SubVendor: "NVIDIA"
      SubDevice:
      Revision: "Chip Rev"
      Memory Size: 14 MB
      Memory Range: 0xcd000000-0xcddfffff (rw)
      Mode 0x0300: 640x400 (+640), 8 bits
      Mode 0x0301: 640x480 (+640), 8 bits
      Mode 0x0303: 800x600 (+800), 8 bits
      Mode 0x0305: 1024x768 (+1024), 8 bits
      Mode 0x0307: 1280x1024 (+1280), 8 bits
      Mode 0x030e: 320x200 (+640), 16 bits
      Mode 0x030f: 320x200 (+1280), 24 bits
      Mode 0x0311: 640x480 (+1280), 16 bits
      Mode 0x0312: 640x480 (+2560), 24 bits
      Mode 0x0314: 800x600 (+1600), 16 bits
      Mode 0x0315: 800x600 (+3200), 24 bits
      Mode 0x0317: 1024x768 (+2048), 16 bits
      Mode 0x0318: 1024x768 (+4096), 24 bits
      Mode 0x031a: 1280x1024 (+2560), 16 bits
      Mode 0x031b: 1280x1024 (+5120), 24 bits
      Mode 0x0330: 320x200 (+320), 8 bits
      Mode 0x0331: 320x400 (+320), 8 bits
      Mode 0x0332: 320x400 (+640), 16 bits
      Mode 0x0333: 320x400 (+1280), 24 bits
      Mode 0x0334: 320x240 (+320), 8 bits
      Mode 0x0335: 320x240 (+640), 16 bits
      Mode 0x0336: 320x240 (+1280), 24 bits
      Mode 0x033d: 640x400 (+1280), 16 bits
      Mode 0x033e: 640x400 (+2560), 24 bits
      Mode 0x0345: 1600x1200 (+1600), 8 bits
      Mode 0x0346: 1600x1200 (+3200), 16 bits
      Mode 0x0347: 1400x1050 (+1400), 8 bits
      Mode 0x0348: 1400x1050 (+2800), 16 bits
      Mode 0x0349: 1400x1050 (+5600), 24 bits
      Mode 0x034a: 1600x1200 (+6400), 24 bits
      Mode 0x0352: 2048x1536 (+8192), 24 bits
      Mode 0x0360: 1280x800 (+1280), 8 bits
      Mode 0x0361: 1280x800 (+5120), 24 bits
      Mode 0x0362: 768x480 (+768), 8 bits
      Mode 0x0364: 1440x900 (+1440), 8 bits
      Mode 0x0365: 1440x900 (+5760), 24 bits
      Mode 0x0366: 1600x900 (+3200), 16 bits
      Mode 0x0367: 1600x900 (+6400), 24 bits
      Mode 0x0368: 1680x1050 (+1680), 8 bits
      Mode 0x0369: 1680x1050 (+6720), 24 bits
      Mode 0x0370: 1600x900 (+1600), 8 bits
      Mode 0x037b: 1280x720 (+5120), 24 bits
      Mode 0x037c: 1920x1200 (+1920), 8 bits
      Mode 0x037d: 1920x1200 (+7680), 24 bits
      Config Status: cfg=new, avail=yes, need=no, active=unknown

不过我感觉这个意义不大,因为虽然上面没有1366x768这个分辨率,但是还是可以在下面将参数设成1366x768.你可以根据你的爱好来修改,但是最好按上面机器支持的分辨率来修改,否则可能会出现意想不到的问题。

修改grub文件

/etc/default/grub


GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
#改成:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset video=uvesafb:mode_option=1366x768-24,mtrr=3,scroll=ywrap"

#GRUB_GFXMODE=640×480
#改成
#GRUB_GFXMODE=1366x768

其最终结果如下(不同的机器不一定相同,我的是Lenovo Y450):

# 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 nomodeset video=uvesafb:mode_option=1366x768-24,mtrr=3,scroll=ywrap"
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# 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=1366x768
# 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 entries
#GRUB_DISABLE_LINUX_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

修改initramfs-tools配置

/etc/initramfs-tools/modules

uvesafb mode_option=1366x768-24 mtrr=3 scroll=ywrap添加上去。

最终结果是这个样子:

# List of modules that you want to include in your initramfs.
#
# Syntax:  module_name [args ...]
#
# You must run update-initramfs(8) to effect this change.
#
# Examples:
#
# raid1
# sd_mod
uvesafb mode_option=1366x768-24 mtrr=3 scroll=ywrap

更新grub配置

sudo update-grub2
sudo update-initramfs -u

最后重启就行了。

linux Framebuffer分类(uvesafb、vesafb、sisfb)

http://blog.csdn.net/tangy110/article/details/6341922

http://en.gentoo-wiki.com/wiki/Framebuffer#vesafb

A framebuffer enables the kernel to display graphics on an otherwise text only console. These drivers can also be used for other things, such as running a non-accelerated X server or playing video in media players with framebuffer support. Framebuffer support is a requirement for applications like Fbsplash and Qingy.

uvesafb

Some tinkering is involved to get the uvesafb driver working. You will need to enable Connector - unified userspace <-> kernelspace linker and Userspace VESA VGA graphics support.

Rebuild the kernel, but don't install it just yet. The reason we first needed to build the kernel is that we need klibc to compile against a kernel withConnector - unified userspace <-> kernelspace linker and Userspace VESA VGA graphics support enabled. Next we need the sys-apps/v86d userspace helper, emerge -av v86d

Now, read the initramfs kernel configuration chapter for instruction on enabling initramfs support, which is needed to include bits of sys-apps/v86d in the kernel. Set the Initramfs source file(s) to /usr/share/v86d/initramfs,

Note: If you need to add v86d to an already existing initramfs source directory, look in /usr/share/v86d/initramfsand copy the files listed there.

Rebuild the kernel yet again and finally install it.

vesafb

The vesafb driver is a generic VESA driver that works with most VESA compatible cards.

sisfb

For users with a SiS card, you want the sisfb driver.

This driver supports the following SiS cards:

    SiS 300 series: SiS 300/305, 540, 630(S), 730(S)
    SiS 315 series: SiS 315/H/PRO, 55x, (M)65x, 740, (M)661(F/M)X, (M)741(GX)
    SiS 330 series: SiS 330 ("Xabre"), (M)760

Kernel Command Line Options

The kernel will only use the framebuffer if it is specifically told to do so. The required kernel command line option here is video= followed by the desired driver, a set of options, resolution, color depth and refresh rate.

uvesafb

Add to the kernel line of your /boot/grub/grub.conf, substituting the options to your liking,

video=uvesafb:mtrr:3,ywrap,1024x768-24@60

You can also create an entry disabling uvesafb using the following,

video=uvesafb:off

One reason for disabling UVesaFB, is to avoid known conflicts when using the binary NVidia driver with hibernate/suspend feature.

A uvesafb example is shown below, but keep in mind that how the kernel is told to use the framebuffer differs from driver to driver.

File: /boot/grub/grub.conf

...
title=Gentoo Linux
root(hd0,0)
kernel /boot/bzImage root=/dev/hda3 video=uvesafb:ywrap,mtrr:3,1024x768-32@70
...

Here we told the kernel to use the uvesafb driver with the ywrap and mtrr:3 options, set the resolution to 1024x768 with a color depth of 32 bits and a refresh rate of 70Hz.

vesafb

If you use the vesafb driver you will need to omit the resolution, color depth and refresh rate from the video= and follow with a vga= parameter. The vga= takes a decimal value (with no preceding 0x), or ask. Setting vga=ask is a good idea if you are unsure what to use, as the kernel will stop and ask you for the desired resolution and color depth. The Linux video mode numbers can be found here, but you should be aware that these number might not work on your particular hardware. A better way to see the modes you can set is to run:

hwinfo --vbe|grep Mode

So a vesafb example would be,

video=vesafb:mtrr:3,ywrap vga=792

which would be equivalent to a uvesafb of:

video=uvesafb:mtrr:3,ywrap,1024x768-24@60

To create a profile for disabling framebuffer, use either vga=normal or vga=nofb, or just omit vga= entirely.

sisfb

The video= parameter differs from other drivers.

The uvesafb driver entry,

video=uvesafb:ypan,mtrr:3,1024x768-32@70

would, using sisfb be,

video=sisfb:mode:1024x768x32,rate:70,mem:4096

Make sure you set the memory size of your card in KiB using the mem: option.

Other Options

MTRR

The mtrr option defaults to mtrr:0, meaning that MTRR will be disabled — equivalent to the nomtrr option.

The safest option is probably to use mtrr:1 and the most optimal option is most likely mtrr:3. The values represent:

0 - Disabled (equivalent to nomtrr) (default)
1 - Uncacheable
2 - Write-back
3 - Write-combining
4 - Write-through

Review the kernel documentation for more information.

ypan, ywrap and redraw

The ypan, ywrap and redraw are scrolling options. They set the way the kernel will handle the scrolling and panning of the framebuffer. If none of these are specified, the redraw option will be used, this is the safest but slowest option. Most modern hardware can handle ywrap, so this is most likely the option you want to use. If that fails you could try ypan, expect flickering using this though.

To clarify, a complete kernel command line in /boot/grub/grub.conf, using the uvesafb driver, with the mtrr:3 and ywrap options using a resolution of 1600x1200, a color depth of 32 bits and a refresh rate of 70 Hz would be:

File: /boot/grub/grub.conf

...
kernel /boot/bzImage root=/dev/hda3 video=uvesafb:1600x1200-32@70,mtrr:3,ywrap
...

Review the Kernel Documentation for more information.

Ubuntu 10.10启动进入命令行模式

  1. 运行 sudo gedit /etc/default/grub
  2. 找到 GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”
  3. 改为 GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash text”
  4. 运行 sudo update-grub
  5. 重启 over

根本不需要任何对GDM的操作

另外 中文locale下在命令行界面显示中文可以非常简单的安装zhcon即可 还自带命令行下的中文输入法

sudo aptitude install zhcon
zhcon --utf8

注意 一定要以 --utf8参数启动,zhcon默认是gb2312编码

如果控制台下没有输入中文的需要 ,那么可以使用jfbterm ,显示速度更快,也漂亮一点

sudo aptitude install jfbterm
jfbterm -q -c other,UTF-8,iconv,UTF-8

由于参数较长 可以写入文件并加上执行权限来运行

另外 ,为了开启framebuffer ,以提升zhcon或者jfbterm的性能,还需要修改 /etc/default/grub 文件, 将GRUB_GFXMODE前面的注释(#号)去掉,后面的根据你的机器修改为 800x600或者1024x768,注意不要修改为宽屏分辨率,除非你用vbeinfo这个命令测试出显卡支持宽屏分辨率下的framebuffer

例如

GRUB_GFXMODE=800x600x16