如何提高Ubuntu整体系统性能?

有什么提高ubuntu整体系统性能的技巧? 受这个问题的启发,我意识到Ubuntu上的某些默认设置可能相当保守,并且如果你想让它更快,可以很少或没有风险调整它。

这并不是特定于应用程序(例如,使firefox加载页面更快),但系统范围。

每个答案最好有1个提示,有足够的细节供人们实施。

我的几个将是:

  • 安装Preload (通过软件中心或sudo apt-get install preload );
  • 更改Swappiness值 – “它控制内核在尝试释放内存时更喜欢交换的程度”;

你的是什么?

PS:因为这不是一个独特的答案,而是一些有用的提示,我正在开发这个社区维基。

如果你是“普通的乔” ,那就不要做任何事情。 不要弄乱您不理解的程序或设置。 不要按照Internet上发布的提示,通过自己编译某些软件或安装自制内核来提高系统性能。

其中一些技巧确实会给你带来轻微的性能提升,但是如果你改变了错误的设置,禁用了错误的服务,安装了错误的驱动程序等等,其中一些技巧也会给你带来真正的麻烦。

因此,对您运行良好的系统感到高兴。 顺便说一句:为什么你需要这5%的性能改进? 它不会导致更快地键入您的办公室文档或在一半的时间内编辑您的假日照片。

而且要明确一点:如果你不是普通的Joe,而是一个开发人员/硬核玩家/ ……需要你可以获得的任何周期,你不是这个评论的目标……

禁用自动启动任何不需要的服务(甚至完全删除包)。

很多软件包会自动启动服务。 然后这些服务使用内存和CPU,即使它们几乎不被使用。 在这种情况下,最好是停止这些服务,或者将它们从自动启动中取出,并在需要时启动它们。

要从10.04启动中删除应用程序,请转到系统>首选项>启动应用程序 (在其他版本上可能略有不同)

在12.04,您可以通过单击“ 短划线”图标来选择启动应用程序。 然后,键入startup并选择“启动应用程序”。

替代文字

只需取消标记您不需要的应用程序。 但请确保它,不要只是删除你不知道的应用程序。 如果你不确定,请保持这种状态。 关于特定程序的谷歌搜索或新问题将有所帮助。

[免责声明]管理以下风险由您自行承担。

Tushar Neupaney 在这里给出了这样的建议:

1.使用较轻的应用程序(用它们替换默认应用程序)

  • Gedit >>鼠标垫
  • 图片浏览器(EOG …)>> Gpicview
  • 网络管理员>> Wicd
  • Evince >> epdfview

2.减少痉挛

  • sudo vim /etc/sysctl.conf

    编辑:vm.swappiness = 10

3.对于双核(使用并发)

  • sudo vim /etc/init.d/rc

    编辑:CONCURRENCY = shell

    shell选项现已过时。 默认值为makefileshell为2010-05-14 makefile的别名。

4.在/etc/apt/sources.list中的/ var / cache / apt / archives和不需要的apt-sources列表中清理apt缓存

  • sudo apt-get autoclean

5.安装BUM(启动管理器)

  • sudo apt-get install bum

    从启动中删除不必要的应用程序和服

6.删除一些不必要的TTY

  • sudo vim /etc/default/console-setup

    编辑:ACTIVE_CONSOLES =“/ dev / tty [1-3]”

    注意:转到/etc/init/并更改你想要的tty文件。 编辑它们并以“start on runlevel”开头的注释行。 因此,在这种情况下,您将把“tty4.conf”中的起始行注释为“tty6.conf”文件。

7.安装Prelink

  • sudo apt-get install prelink
  • sudo vim /etc/default/prelink

    编辑:PRELINKING =是

  • sudo /etc/cron.daily/prelink

    实际上,自Feisty Fawn以来Prelink一直没用 (因为Ubuntu现在使用非常有效的运行时链接器)。 此外,它是侵入性的 – 它直接修改可执行文件,最终可以打破它们。 要这样做。

8.安装预加载

  • sudo apt-get install preload

9.如果不使用hibernate和hibernatefunction,请删除kinit。

  • sudo vim /etc/initramfs-tools/conf.d/resume

    编辑:评论(把#放在前面)RESUME = XXXX ……………………

减少引导加载程序菜单超时

听起来微不足道,但我发现Ubuntu的默认10秒对我的口味来说太长了。 说我的屏幕有点自动调整res,我看到计数器第一眼看到8秒。

我会将超时编辑为3秒,让我看一下启动菜单(考虑我的屏幕调整到res的时间)。 很多时候,按箭头键选择另一个项目会停止计数器。

Grub (9.10 Karmic之前)

 sudo -i gedit /boot/grub/menu.lst 

查找并编辑“ TIMEOUT ”行

Grub 2 (新安装的9.10 Karmic及之后)

 sudo -i gedit /etc/default/grub 

查找并编辑“ GRUB_TIMEOUT ”行,然后运行sudo update-grub

在我的文件系统(ext4和reiserfs)添加“ noatime ”选项后,我的整体性能提升了。

我无法提供速度测试,但我邀请您试一试,亲眼看看。

Ubuntu论坛的有用资源: 在fstab中使用noatime保存硬盘 。

如果你缺少RAM,请使用Ubuntu repos中的zramswap或zram-config 。 它是虚拟交换,压缩未使用的RAM内容而不是将它们放到磁盘上(通常在你触及RAM屏障后冻结系统)。 每次用完RAM时,我都没有遇到任何性能损失而不是系统冻结。

这仅适用于Natty和up(因为你需要内核2.6.37.1或更新版本)。 对于较旧的系统,您可以使用compcache ,但您必须手动设置它。

对于那些从未达到RAM限制的人来说,它无论如何都会对HDD系统提供一些速度提升,但是你最好减少swappiness以达到同样的效果。

SSD用户:很可能你不会遇到任何速度提升,但zramswap可以减少SSD的磨损。

我不确定我的答案是否合格,因为Ubuntu通常意味着使用更轻的替代品的GNOME和Ubuntu变体具有略微不同的名称,如Xubuntu。

摆脱GNOME是我通常建议的第一件事。 如果您对像fluxbox这样的轻量级产品感到满意,那就去做吧。

更换SSD的Mechanical磁盘

固态硬盘速度更快,似乎是当今几乎所有计算机中最大的瓶颈 。

例如,我的启动时间从约15秒减少到约3秒,并且首次启动应用程序(Firefox,例如,从约5秒到不到一秒)大幅减少。

想要一些基准吗? 这是一个。

/etc/sysctl.conf设置vm.swappiness=10 。 当我填满记忆时,我得到了明显的速度提升。 由于我大部分时间都在使用Eclipse,因此物理内存可能会成为稀疏商品。

编辑:

从Ubuntu Swap FAQ :

“Ubuntu中的默认设置是swappiness = 60.减少swappiness的默认值可能会提高典型Ubuntu桌面安装的整体性能。 建议使用swappiness = 10的值 ,但可以随意试验。注意:Ubuntu服务器安装有对桌面系统的性能要求不同,默认值60可能更合适。“

常见问题解答非常完整,包括解释什么是交换,如何使用以及如何更改它。 推荐阅读任何想要修补swappiness或磁盘上交换文件大小的人。

听起来很傻,总是更新你的系统!

在我拥有的一台Ubuntu机器上,我发现将桌面效果设置为无(禁用所有图形效果)可以大大提高UI速度。

调整ext4以获得最大烟雾

启用回写模式。 此模式通常会提供最佳的ext4性能。 请注意,它以可靠性为代价,因为它禁用了写入数据的日记function。 在将元数据提交到日志之后,可以将数据写入主文件系统。 因此,崩溃和日志恢复后,旧数据可能会出现在文件中。

 tune2fs -o journal_data_writeback /dev/sdXX # Check fs options dumpe2fs /dev/sdXX |more 

来自kernel.org的文档 :

在data = writeback模式下,ext4根本不记录数据。 此模式提供与XFS,JFS和ReiserFS在其默认模式(元数据日记)中类似的日记function。 崩溃+恢复可能导致错误数据出现在崩溃前不久写入的文件中。 此模式通常会提供最佳的ext4性能。

更烟

要挤出更多性能,请添加fstab选项: data=writeback,noatime,nodiratime

即,编辑/etc/fstab找到驱动器的UUID并添加/替换现有选项

 /dev/sdXX /opt ext4 defaults,data=writeback,noatime,nodiratime 0 0 

确保在编辑fstab文件之前和重新引导之前已使用tune2fs打开写回模式。 我之前说过,因为我在改变了我的fstab之后重新启动了但是在我打开写回模式并且开启了我的启动之前。 什么都没有丢失,但我不得不使用现场CD获取访问权限并更改我的fstab。 如果您在非启动驱动器上启用首先测试,则更安全。

启动和关闭以及日常使用的速度都有很大提高。

您还可以关闭日志模式,这将提供额外的提升,为了增加安全性,确保您已连接UPS并正常工作,因为关闭这些function您的数据不安全,说我的系统没有UPS和它的电源至少中断了三次,我没有数据丢失,但你的里程可能会有所不同。

购买尽可能多的内存,机器可以容纳。

以下仅供专家使用。 顾名思义,它可以并且将会占用您的数据,即使您非常小心。

eatmydata是一个可以关闭fsync的包。 Fsync是一种系统操作,可确保在继续之前将数据写入磁盘。 通常您需要这样,因为它可以更容易,更快速地减少数据丢失,从而使断电和故障恢复。 它虽然有代价; 任何调用fsycn的东西都必须等待它排队,而不是简单地将数据传递给内核以便稍后写入。 在一些甚至许多文件系统中,fsync会写出所有数据,而不仅仅是你想要保护的东西。

在某些特定情况下,fsync不值得花费。 想象一下,你有一个服务器,该数字可以处理大量数据。 将其指向一个实时数据库,而不是转储到一致的本地数据库,安装eatmydata以关闭fsync,然后放手。 这仍然可以崩溃并丢失数据,但由于它不是任何东西的唯一副本,因此您可以从头开始重新启动该过程。 或者,例如,Ubuntu的构建服务器,我们关心的是最终生成的包。 或者,在桌面端,如果某个程序(如Firefox)正在同步,那么整个系统的速度就会降低。 只是准备丢失与使用此相关的所有数据,否则将面临可怕的后果。

关闭一直未使用的应用程序。

许多标准应用程序在后台运行时会占用大量内存,通常也会使用CPU。 Web浏览器,电子邮件客户端等在内存使用方面效率非常低,嵌入的javascripts经常使用CPU时间而对用户没有任何好处。

只需运行当前使用的应用程序,系统就会快得多。 此外,停止应用程序是释放内存泄漏中丢失内存的唯一方法。

在快速运行的系统上启动应用程序通常比在过载和慢速系统上切换窗口要少。

  1. 使用JFS文件系统。 它坚如磐石 。 它具有最低的CPU使用率和非常好的整体性能。

  2. 设置vm.vfs_cache_pressure。 这是我的/etc/sysctl.d/10-desktop-responsiveness

    [在评论行前面加上#,这个网页界面不喜欢它们……]

    这些设置可提高典型桌面工作负载的响应速度。

当这两个竞争RAM时,vm.swappiness指示linux内核支持缓存上的应用程序代码。

vm.vfs_cache_pressure控制inode / dentry(即文件系统)缓存与其他缓存,即我们希望尽可能将文件系统元数据保存在RAM中。

来自: http : //rudd-o.com/linux-and-free-software/tales-from-responsivenessland-why-linux-feels-slow-and-how-to-fix-that

 vm.swappiness=15 vm.vfs_cache_pressure=50 

虽然听说即使在Unity2D下你也遇到了同样糟糕的表现,但我很惊讶Unity会有点资源消耗。 一种可能的解决方案是使用其他更轻量级的桌面环境,例如Lubuntu(LXDE)或Xubuntu(XFCE)。 我认为你会发现整体响应能力和表现有很大差异。

此外,您可以尝试进入启动应用程序管理器并取消选中您不需要Ubuntu在登录时自动启动的应用程序和进程(例如,如果您没有蓝牙,则为蓝牙管理器,如果您不使用蓝牙,则为UbuntuOne) ,您根本不使用的程序等。)在此之前,首先在启动管理器中显示隐藏的启动应用程序:

 sudo sed -i 's/NoDisplay=true/NoDisplay=false/g' /etc/xdg/autostart/*.desktop 

配置交换

第1部分。设置swappiness。 这可能是根据degusa的答案,但它可能是相反的,它会有更多的效果。

我们中的一些人很高兴参与的一个场景是我们有足够的RAM。 一般来说,我们只占内核和应用程序直接使用的一小部分,有些(如果你使用其他调整来提高性能,例如在内存中安装/ tmp),ramfs和tmpfs会使用它们, gigs和gigs被用作磁盘缓存,以使我们的文件访问速度更快。

在这种情况下,一旦包括缓存在内的总使用内存变得很高,并且应用程序需要更多RAM,linux必须决定是从文件系统中获取一些缓存,还是交换到交换分区/文件。

Since we’ve tonnes of RAM, and quite possibly only bothered with swap at all so we could enable hibernation, we want it to lean toward taking some of that copious cache, and hence want a low swappiness. If we don’t care about being able to hibernate, we might even find that such a high-RAM machine doesn’t need swap at all.

Another scenario is someone with low RAM who is switching between a few heavy applications and spending a reasonable amount of time on each. Imagine perhaps a web dev who spends some time on their IDE, some on a graphics editor, some on their browser of choice, a bit on some other browsers to check on compatibility issues, and maybe 5 minutes every hour on their mail client. They’re also likely hitting the same files repeatedly with reads and writes and hence benefiting appreciably from file caching. This person could probably benefit from linux being more eager to swap out the memory used by whichever of those heavy applications they’re currently not active on, so swappiness should probably be higher for them.

Not only is the best setting for them likely to be higher than the most common advice, but they’re probably going to notice it more than the person who always has gigs to spare anyway, too.

Part 2. Priority & number of partitions.

Each swap partition has a priority, and linux will use that with the highest first. If not set in /etc/fstab, it’ll be treated as negative starting with -1 (explicit settings are between 0 and 32767 and so -1 is lower than any explicitly set) and continuing in order in fstab to -2, -3 and so on.

The best setting depends upon where the partitions physically are. If you’ve only one, then it doesn’t matter (but maybe you should have more than one, so read on).

If you’ve two or more on the same physical drive, then they should have different priorities so that it doesn’t try to use two partitions that require seeking between them (does anyone know if this is automatically avoided?). The defaults are fine. It’s probably not a good idea to have two swaps on the same drive anyway, but it can happen if you created one and then decided you needed more swap later (perhaps when adding more RAM).

If you’ve two or more on two or more physical drives that are of about equal speed, then setting them to the same priority will mean linux will use them both at the same time, which offers better performance for reasons analogous to why RAID or simply ensuring that there are frequently used files on both drives will – the work gets split between them.

If you’ve two or more physical drives of equal speed but have swap only on one, maybe you should change that, for the above reasons.

If you’ve two or more physical drives, of very different speeds, then generally you want the fastest drive to have a higher priority than the slower, so it’s used first. You may not even want to have any swap on the slower, though it might make sense if you eg have a small swap on a fast but small drive for fast swap, and a larger swap on the slower drive so you’ve enough space to hibernate.

If the faster of the two is an SSD, then there’s two alternatives with different pros and cons:

  1. Highest-priority, or perhaps only, swap on the SSD, for speed.
  2. Only swap on the non-SSD, to reduce writes on the SSD and hence increase its lifetime.

Number 2 is probably the one to go for if you only really have swap to allow for hibernation and otherwise your copious RAM means you don’t really need it (and if you’re spending money on an SSD, you should spend it on RAM too) unless perhaps you’re a boot-up speed fanatic who wants to boot from hibernation at a speed that’ll show off your fancy high-spec rig! Otherwise, the balance is all about speed vs SSD lifetime.

If you’ve a drive existing solely for swap so as not to compete with other file I/O, then you presumably are hard-core about performance and already know about this stuff better than me and are only reading this to see if I got anything wrong!

If you want to have a look at what services are started after booting on Ubuntu 10.04 run “jobs-admin”.

 sudo apt-get install jobs-admin 

If we are talking about getting from BIOS to internet connectivity i can recommend setting up network without using NetworkManager, personally I’ve done this because i have a very sluggish DHCP server and NetworkManager doesn’t start probing for network until i’ve logged in.

use lighter programs instead of default: gnumeric instead of oo calc, abiword instead of oo write and so on

If you use a Unity desktop then try a more lightweight interface like LXDE or Xfce.

Found what was slowing down my machine: gwibber-service . Maybe because I have an account in twitter that follows a lot of people and when it refreshed the machine went bad.

I was monitoring the machine with top as said @kmassada and when it was really slow noticed the process. Then executing:

 sudo sed -i 's/NoDisplay=true/NoDisplay=false/g' /etc/xdg/autostart/*.desktop 

as @blasmat indicated to go through Startup Applications I could see that the service started automatically and I disabled it. Now my computer is much faster. I think there are still improvements I can make (I don’t feel it at it top conditions), but after 20 hours of testing the performance I can say it really goes well.

The ubuntu-tweak utility has a handy “Janitor” tool that allows you to clear caches and orphan packages very easily.

 sudo apt-get install ubuntu-tweak 

Note that as of 2016-04-16 Ubuntu Tweak is abandoned, with last update over year ago – see https://github.com/tualatrix/ubuntu-tweak (what makes http://blog.ubuntu-tweak.com/2012/10/22/thank-you-ubuntu-tweak-will-continue.html outdated).

Ubuntu Tweak's Janitor

Use apt-fast instead of apt-get , and put your apt cache on tmpfs.

You’ll need aria or axel for apt-get to work so first either:

 apt-get install aria2c 

要么

 apt-get install axel 

I’ve used aria. Then you need apt-fast itself.

 sudo add-apt-repository ppa:apt-fast/stable && sudo apt-get update && sudo apt-get install apt-fast 

Answer the questions, and from then on apt-fast will act like apt-get in just about every regard except that it downloads packages in parallel. It makes no difference if you are going to install a single application, but lots for larger installs.

In combination, with this, my /etc/fstab has:

 tmpfs /var/cache/apt/archives tmpfs defaults,noatime,mode=1777 0 0 

This has the downside that if the same package is used several times over different boots, it’ll have to download it again, but then it may have been updated in the meantime anyway. It has the upsides of faster access of them, automatic clean-up of unused packages on reboot.

Since I’ve been re-installing a lot over the course of these experiments, it allowed me to do a comparison. After installation of 12.04 one will at the time of writing have about 300 updates including a kernel update available just after installing. I ignored software updater and did the above changes before apt-fast update && apt-fast dist-upgrade and the download part is many times faster (the actual installation takes the same time).

I have an alias of alias apt-get="apt-fast" so I don’t even need to change habits (the only differences are different feedback on the download, a confirmation on whether I want to download them, and an implied sudo should I forget it, but the commands to trigger anything is the same).

I would check for what processes are running and which ones are using up the most memory. There might be something you are installing that is a memory hogger. use top command or system monitor.

If you are not into eye candy, I even recommend installing the following packages. I noticed a considerable response time between unity and basic gnome

sudo apt-get install gnome-core gnome-session-fallback

I would also check my startup applications to see what runs at start up and what I don’t need to run at start up.

And I would also check responsiveness in specific applications.

last thing I would check graphics settings. Maybe you need to compromise battery life for performance.

Another good way to boost performance is to install CompizConfig Settings Manager, and disable animation effects, Fading Windows, and Window Decorations. Desktop wall and Expo are an option, too.

在此处输入图像描述

Also, use fast texture filter under OpenGL

在此处输入图像描述

Try a light-weight community flavour of Ubuntu

Instead of messing with your Ubuntu system: make a fresh installation of a community flavour of Ubuntu , a flavour with the same Ubuntu engine under the hood, but with a lightweight desktop environment, and with lighter application programs.

  • the ultra-light Lubuntu or

  • the medium light Ubuntu MATE or Xubuntu .

Try them live before installing. It is a good idea to keep using LTS releases, and I suggest that you start with 16.04.1 LTS, which is the version with the longest remaining support until End Of Life. See detailed tips at the following links,

  • Try Ubuntu (Kubuntu, Lubuntu, Xubuntu, …) before installing it

  • How to select the version and flavour of Ubuntu

  • Old hardware brought back to life

The version with longest support time (when this is written)

It is somewhat tricky to find 16.04.1 LTS , the version with the longest support time. The following links work (2017-06-29),

  • Ubuntu: old-releases.ubuntu.com/releases/xenial

  • Lubuntu 16.04, 16.04.1 and 16.04.2: cdimage.ubuntu.com/lubuntu/releases/16.04.1/release

  • Ubuntu MATE 16.04, 16.04.1 and 16.04.2: cdimage.ubuntu.com/ubuntu-mate/releases/16.04.2/release

  • Xubuntu 16.04, 16.04.1 and 16.04.2: cdimage.ubuntu.com/xubuntu/releases/16.04.2/release

Try the ck patchset: https://launchpad.net/~chogydan/+archive/ppa

It is a kernel with experimental patches to improve desktop performance.