Menu Home

Ubuntu 服务器清理多余内核

Ubuntu Server 并无桌面环境,多次升级以后系统中会存在大量不同版本的内核,而每个内核占用非常多的硬盘空间(一般一个内核300mb左右占用),所以需要定期清理没用的内核。

1.查看当前使用的时哪个内核.

magth@cloud:~$ uname -a
Linux cloud 4.4.0-96-generic #119-Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

2.查看当前系统安装了多少内核

magth@magth:~$ dpkg --get-selections|grep linux
console-setup-linux				install
libselinux1:amd64				install
linux-base					install
linux-firmware					install
linux-generic					install
linux-headers-4.4.0-62				install
linux-headers-4.4.0-62-generic			install
linux-headers-4.4.0-92				install
linux-headers-4.4.0-92-generic			install
linux-headers-4.4.0-93				install
linux-headers-4.4.0-93-generic			install
linux-headers-4.4.0-96				install
linux-headers-4.4.0-96-generic			install
linux-headers-generic				install
linux-image-4.4.0-62-generic			install
linux-image-4.4.0-92-generic			install
linux-image-4.4.0-93-generic			install
linux-image-4.4.0-96-generic			install
linux-image-extra-4.4.0-62-generic		install
linux-image-extra-4.4.0-92-generic		install
linux-image-extra-4.4.0-93-generic		install
linux-image-extra-4.4.0-96-generic		install
linux-image-generic				install
linux-libc-dev:amd64				install
util-linux					install

3.一键清理多余内核命令

magth@magth:~$ dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

4.内核清理完毕

magth@cloud:~$ dpkg --get-selections|grep linux
console-setup-linux				install
libselinux1:amd64				install
linux-base					install
linux-firmware					install
linux-generic					install
linux-headers-4.4.0-96				install
linux-headers-4.4.0-96-generic			install
linux-headers-generic				install
linux-image-4.4.0-96-generic			install
linux-image-extra-4.4.0-96-generic		install
linux-image-generic				install
linux-libc-dev:amd64				install
util-linux					install

4.还有一种情况,系统内核已经卸载了,但是并未实际删除显示状态为 deinstall ,清理命令为:

magth@cloud:~$ dpkg --get-selections | grep deinstall | sed 's/deinstall/\lpurge/' | sudo dpkg --set-selections; sudo dpkg -Pa

Categories: ubuntu

RoyAkon

62 replies

  1. This is the right site for anybody who really wants to
    understand this topic. You realize so much its almost tough to argue with you (not that I really will need to…HaHa).

    You definitely put a new spin on a topic that’s been discussed for decades.

    Excellent stuff, just great!

  2. Hello There. I discovered your blog the usage of msn. This is a really
    neatly written article. I’ll be sure to bookmark it
    and return to learn extra of your useful info.
    Thanks for the post. I’ll definitely comeback.

  3. Its such as you learn my thoughts! You seem to know a lot
    about this, like you wrote the book in it or something. I feel that
    you simply could do with a few % to drive the message home a
    bit, but instead of that, that is fantastic blog. A great read.
    I’ll certainly be back.

  4. I think that everything composed made a ton of
    sense. But, what about this? suppose you typed a catchier title?
    I ain’t saying your information is not solid., however suppose you added something to possibly grab people’s attention? I mean Ubuntu 服务器清理多余内核 | 蜘蛛网间 is kinda boring.

    You ought to look at Yahoo’s front page and watch how
    they write article headlines to grab people interested.
    You might add a related video or a related pic or two to grab readers interested about everything’ve written. Just my opinion, it
    could make your blog a little livelier.

  5. First off I would like to say great blog! I had
    a quick question that I’d like to ask if you don’t
    mind. I was curious to find out how you center yourself and clear your head before writing.
    I have had difficulty clearing my mind in getting my ideas out there.
    I truly do take pleasure in writing but it just seems like the first 10 to 15 minutes tend to be wasted just trying to figure out how
    to begin. Any suggestions or tips? Thanks!

  6. Thank you a bunch for sharing this with all people you actually realize what you are
    talking approximately! Bookmarked. Kindly also discuss with my web site =).
    We could have a hyperlink alternate arrangement between us

  7. Good day I am so grateful I found your blog, I really found you
    by mistake, while I was researching on Bing for something else, Anyhow I am here
    now and would just like to say many thanks for a marvelous post and a all round exciting blog (I also love the theme/design), I don’t have time to
    look over it all at the minute but I have bookmarked it and also added your RSS feeds, so when I have time I will be back to read a great deal more,
    Please do keep up the fantastic jo.

  8. Hi, I do believe this is a great web site.

    I stumbledupon it 😉 I’m going to return yet again since i have book-marked it.
    Money and freedom is the best way to change, may you be rich and continue to help others.

  9. Hi there! I’m at work browsing your blog from my new iphone 4!

    Just wanted to say I love reading your blog and look forward to all your posts!
    Keep up the great work!

  10. I’m not sure why but this website is loading very slow for me.

    Is anyone else having this issue or is it a problem on my end?

    I’ll check back later and see if the problem still exists.

  11. I don’t even understand how I stopped up right
    here, but I thought this publish used to be good. I do not recognize who you’re however definitely you’re going to a well-known blogger if you aren’t already.
    Cheers!

  12. Good day! This is my first visit to your blog! We are a collection of volunteers and starting a new initiative
    in a community in the same niche. Your blog provided us useful information to work on.
    You have done a outstanding job!

    Take a look at my page Saundra

  13. Hello there, just became alert to your blog through Google, and found that it’s truly informative.

    I’m gonna watch out for brussels. I will be grateful if
    you continue this in future. Numerous people will be benefited
    from your writing. Cheers!

  14. Whoa! This blog looks exactly like my old one!
    It’s on a completely different topic but it has pretty much the same layout and design. Superb choice of colors!

  15. Awesome blog! Do you have any helpful hints for aspiring writers?

    I’m planning to start my own site soon but I’m a little
    lost on everything. Would you suggest starting with a free platform like Wordpress or
    go for a paid option? There are so many options out there that I’m totally overwhelmed ..
    Any recommendations? Thank you!

  16. I do not even қnow how I ended up hеre, but I thought
    thіѕ post wɑs ɡood. І dⲟn’t know wһo yoս are but certaіnly you ɑre going tto а famous blogger if уоu
    aren’t alгeady 😉 Cheers!

    mʏ webpage … more info

  17. Your style is really unique in comparison to other people I have read stuff from. I appreciate you for posting when you ave got the opportunity, Guess I all just book mark this page.

  18. I think other site proprietors should take this website as an model, very clean and wonderful user genial style and design, as well as the content. You are an expert in this topic!

  19. [url=https://maybeloan.com/][img]https://d.radikal.ru/d13/2007/77/b2697bc2556d.jpg[/img][/url]

    If you consider to search a service, where everyone could decide financial questions very fast, you need to visit maybeloan.com, where really to get online cash. More and more parents don’t receive salaries on time. That is the reason, why young families couldn’t take care of their children. Better to go here, where everybody can receive cash without queue. Any applicant has the chance to economize time because all applications are considered 24/7.

    If you are an entrepreneur or auditor and you wish to receive [b][url=https://maybeloan.com/installment-loans/hi-usa-il]installment loans in HI[/url] [/b] maybeloan company will help. Very often young mothers obtained payday loans in the United States of America. The basic reason consists of small incomes. Not all states support young moms and pay them maternal care. Mostly, some part of guys prefers to use installment loans online.

    Individual methods to help each one – the main task of service. You can be sure, that at service everybody person could search the best variant. If you are ready to get credit without additional papers and waiting, you can send an application form and managers will answer you. At service all actions are transparent and all information about the consumer remains within the service. Interest rates possible to calculate by yourself. However, service proposes any actions, which are interconnected with Visa, MasterCard, and other payment platforms. You may use payday loans online in Texas, because online cash is cozy to use, then cash from the bank.

    First, what you must to do – complete your petition after fill out the form and you can get [b][url=https://maybeloan.com/installment-loans/or-usa-il]installment loans in Oregon[/url] [/b] here. After the 2000s more and more people from the USA like to use online cash. By online cash probable to pay for different services and buying any products and goods on the Internet. That is why payday loans in Ohio or payday loans digital in Colorado are in demand. Feasible to get digital money to PayPal Inc. system or Skrill. Fast online payments allow men to get purchases or by the bills.

    At maybeloan.com to obtain dollars – it is a very comfortable way to get rid of any temporary financial difficulties. Diverse micro-financial organizations in the USA don’t allow cash for everyone. That is why part of micro-financial organizations in the USA present themselves like banking houses. But they don’t have a resolution despite their high-interest rates.

    At the moment in the USA, different guys have problems with their communal payments and they take loans for it. For example, payday loans online in Alabama usually taken for this. Guys who visit the website, want to find installment loans in Massachusetts. Banking houses, for example, Bank of America or Citigroup, Wells Fargo don’t furnish installment loans in Maryland. That is why, if you need some money, the best way to take it – visit a website.

    To receive cash in web from service can everyone, who is more than 18 years old. If you are a bus driver and other companies don’t want to give you cash, you can use online service and receive cash for your e-wallet. If you are an owner of an e-wallet, you will receive money as fast as possible.

    All transfers, which are pass at the website – are safe. Using a link, everyone can get diverse advantages: velocity, minimum of papers, with bad credit history, etc. You can use cash from the firm and even bad credit loans. At the moment a lot of businessmen don’t have an opportunity to close debt, that is why MayBeloan services – cool way out of the situation.

    Everyone can get money in just 20 minutes. That is why receive money online on the Internet – it is very fast and cool. You can read all accompanying documents, and then get from $100 – $3000 to your account. Digital cash advance in the USA at the moment – it is not a problem. If you have some questions, you shouldn’t waste a time, need to apply to customer support.

  20. Wow that was strange. I just wrote an very long comment but after
    I clicked submit my comment didn’t appear. Grrrr… well I’m not
    writing all that over again. Anyway, just wanted to say excellent blog!

    Here is my web page … Royal CBD

发表评论

电子邮件地址不会被公开。 必填项已用*标注