Tag Archives: kernel

Ubuntu: get last stable kernel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env ruby
require 'net/http'
require 'nokogiri'
require 'fileutils'
require 'securerandom'
require 'progressbar'
require 'micro-optparse'

VERSION='2.1'

options = Parser.new do |p|
  p.banner = "This is a script for getting last kernel version from kernel.ubuntu.com/~kernel-ppa/mainline, for usage see below"
  p.version = "script version #{VERSION}"
  p.option :arch, 'architecture type "amd64" or "i386", default "amd64"', :default => 'amd64', :value_in_set => ['amd64', 'i386']
  p.option :type, 'kernel type "generic" or "lowlatency", default "generic"', :default => 'generic', :value_in_set => ['generic', 'lowlatency']
  p.option :show, 'only show last stable kernel version end exit', :default => false, :optional => true
  p.option :install, 'install downloaded kernel', :default => false, :optional => true
  p.option :clear, 'remove folder with kernel deb packages from /tmp', :default => false, :optional => true
end.process!

HOST = 'kernel.ubuntu.com'
MAINLINE = '/~kernel-ppa/mainline/'
$arch = options[:arch] || 'amd64'
$type = options[:type] || 'generic'
$versions = []
$files = []

def get_all_versions
  $versions = []
  source = Net::HTTP.get( HOST, MAINLINE )
  page = Nokogiri::HTML( source )
  page.css('a').each do |a|
    $versions << a.text if !a.text.include? '-rc'
  end
end

def get_last_version
  get_all_versions if $files.empty?
  $versions[-1]
end

def get_all_files
  $files = []
  source = Net::HTTP.get( HOST, "#{MAINLINE}#{get_last_version}" )
  page = Nokogiri::HTML( source )
  page.css('a').each do |a|
    $files << a.text if( ( a.text.include? $arch and a.text.include? $type ) or a.text.include? '_all' )
  end
end


def generate_tmp_folder
  path = "/tmp/#{SecureRandom.hex}"
  FileUtils.mkdir_p(path) unless File.exists?(path)
  return path
end

def download_file(path, file)
  counter = 0
  file_path = "#{MAINLINE}#{get_last_version}#{file}"
  Net::HTTP.start( HOST ) do |http|
    response = http.request_head( URI.escape( file_path ) )
    ProgressBar
    pbar = ProgressBar.new( "progress", response['content-length'].to_i )
    puts file
    pbar.file_transfer_mode
    File.open( "#{path}/#{file}", 'w' ) do |f|
      http.get( file_path ) do |str|
        f.write str
        counter += str.length
        pbar.set(counter)
      end
    end
    pbar.finish
  end
end

if __FILE__ == $0

  if options[:show]
    puts "Last stable version: #{get_last_version.sub('/', '')}"
    exit 0
  end

  get_all_files
  path = generate_tmp_folder

  $files.each do |file|
    download_file(path, file)
  end

  if options[:install]
    puts "\nInstalling kernel\n"
    output = %x[ sudo dpkg -i #{path}/linux-*.deb ]
    puts output
    puts "\nDon't forget reboot your PC/server\n"
  end

  if options[:clear]
    puts "\nremoving #{path}\n"
    %x[ rm -rf #{path} ]
  end

  if !options[:clear] and !options[:install]
    puts "\nrun \ bash -c 'sudo dpkg -i #{path}/linux-*.deb\' if you'd like to install downloaded kernel!\n"
  end
end

Script version 2.1, new version could be found in github: https://github.com/alter/get_last_ubuntu_kernel.git

Ubuntu: install kernel 3.16

1
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16-utopic/linux-headers-3.16.0-031600-generic_3.16.0-031600.201408031935_amd64.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16-utopic/linux-headers-3.16.0-031600_3.16.0-031600.201408031935_all.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16-utopic/linux-image-3.16.0-031600-generic_3.16.0-031600.201408031935_amd64.deb

dpkg -i *.deb
reboot

INFO: task blocked for more than 120 seconds

This is a know bug. By default Linux uses up to 40% of the available memory for file system caching. After this mark has been reached the file system flushes all outstanding data to disk causing all following IOs going synchronous. For flushing out this data to disk this there is a time limit of 120 seconds by default. In the case here the IO subsystem is not fast enough to flush the data withing 120 seconds. This especially happens on systems with a lof of memory.

The problem is solved in later kernels and there is not “fix” from Oracle. I fixed this by lowering the mark for flushing the cache from 40% to 10% by setting “vm.dirty_ratio=10″ in /etc/sysctl.conf. This setting does not influence overall database performance since you hopefully use Direct IO and bypass the file system cache completely.

echo «vm.dirty_ratio=10» >> /etc/sysctl.conf
sysctl -p

proof link: http://blog.ronnyegner-consulting.de/2011/10/13/info-task-blocked-for-more-than-120-seconds/

Ubuntu: kernel 3.10.1

cd /tmp/
if your linux is 64bit:

1
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.1-saucy/linux-headers-3.10.1-031001-generic_3.10.1-031001.201307131550_amd64.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.1-saucy/linux-headers-3.10.1-031001_3.10.1-031001.201307131550_all.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.1-saucy/linux-image-3.10.1-031001-generic_3.10.1-031001.201307131550_amd64.deb

else if it's 32bit:

1
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.1-saucy/linux-headers-3.10.1-031001-generic_3.10.1-031001.201307131550_i386.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.1-saucy/linux-headers-3.10.1-031001_3.10.1-031001.201307131550_all.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.1-saucy/linux-image-3.10.1-031001-generic_3.10.1-031001.201307131550_i386.deb

sudo dpkg -i *.deb
update-grub
reboot