星期四, 5月 17, 2018

Quick kernel compile guide under CentOS 7

1. Download linux kernel source form the following link, linux-4.16.8.tar.xz in this case.
https://www.kernel.org/

2. Install a CentOS 7 as Workstation and choose most of development package set.
Or you could install as follows later.

  • yum update
  • yum install -y ncurses-devel openssl-devel (make gcc bc  grub2, depends on your installation)


3. copy kernel file and extract file as "tar xvf linux-4.16.8.tar.xz"
--> create a linux-4.16.8 folder

4. Then copy /boot/config-3.10xxxxxx to /linux-4-16.8/.config

5. Compile
make oldconfig (this will compare with new config)
make menuconfig
make -j 4

make -j 4 bzImage (user 4 cores to compile, speed up)
make -j 4 modules
make -j 4 install
make -j 4 modules_install

星期三, 3月 23, 2016

CentOS 7 PXE server for legacy and UEFI BIOS client

Basic Requirement



disable selinux (/etc/selinux/config) and reboot
# service firewalld stop ; chkconfig firewalld off
# yum install dhcp tftp tftp-server syslinux vsftpd xinetd

--- For Ubuntu ---
#sudo apt-get install tftp-hpa isc-dhcp-server vsftpd

# cp -a /mnt/CentOS-DVD/* /var/ftp/pub
# mkdir -p /var/lib/tftpboot/pxelinux/pxelinux.cfg
# mkdir -p /var/lib/tftpboot/pxelinux/centos7
# mkdir -p /var/lib/tftpboot/uefi
# cp /var/ftp/pub/images/pxeboot/vmlinuz /var/ftp/pub/images/pxeboot/initrd.img /var/lib/tftpboot/centos7/
# cp /var/ftp/pub/images/pxeboot/vmlinuz /var/ftp/pub/images/pxeboot/initrd.img /var/lib/tftpboot/uefi
# cp /var/ftp/pub/EFI/BOOT/grubx64.efi /var/lib/tftpboot/pxelinux/BOOTX64.EFI
# cp /var/ftp/pub/EFI/BOOT/grub.cfg /var/lib/tftpboot/pxelinux/
# chmod -R 777 /var/lib/tftpboot

PXE environment configuration files


  • file tree under /var/lib/tftp

/var/lib/tftpboot/
/var/lib/tftpboot/pxelinux
/var/lib/tftpboot/pxelinux/centos7
/var/lib/tftpboot/pxelinux/centos7/vmlinuz
/var/lib/tftpboot/pxelinux/centos7/initrd.img
/var/lib/tftpboot/pxelinux/pxelinux.cfg
/var/lib/tftpboot/pxelinux/pxelinux.cfg/default
/var/lib/tftpboot/pxelinux/pxelinux.cfg/efidefault  -> should be able to skip this file
/var/lib/tftpboot/pxelinux/msgs
/var/lib/tftpboot/pxelinux/msgs/boot.msg
/var/lib/tftpboot/pxelinux/pxelinux.0
/var/lib/tftpboot/pxelinux/fonts
/var/lib/tftpboot/pxelinux/fonts/TRANS.TBL
/var/lib/tftpboot/pxelinux/fonts/unicode.pf2
/var/lib/tftpboot/pxelinux/tmp
/var/lib/tftpboot/pxelinux/tmp/grub.cfg
/var/lib/tftpboot/pxelinux/tmp/grubx64.efi
/var/lib/tftpboot/pxelinux/tmp/MokManager.efi
/var/lib/tftpboot/pxelinux/tmp/TRANS.TBL
/var/lib/tftpboot/pxelinux/BOOTX64.EFI
/var/lib/tftpboot/pxelinux/grub.cfg
/var/lib/tftpboot/uefi
/var/lib/tftpboot/uefi/vmlinuz
/var/lib/tftpboot/uefi/initrd.img



  • /var/lib/tftpboot/pxelinux/pxelinux.cfg/default

default 0
timeout 2000
F1 msgs/boot.msg
F2 msgs/expert.msg
prompt 1
display msgs/boot.msg
        label 0
localboot 1
        label 1
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ramdisk_size=65536 inst.repo=ftp://192.168.1.1/pub  ks=ftp://192.168.1.1/pub/ks.cfg


  • /var/lib/tftpboot/pxelinux/pxelinux.cfg/efidefault

#debug --graphics
default=0
#splashimage=/EFI/BOOT/splash.xpm.gz
timeout 5000
#hiddenmenu
title UEFI CentOS 7 Installation
        root (nd)
        kernel /centos7/vmlinuz
        initrd /centos7/initrd.img ramdisk_size=65536 inst.repo=ftp://192.168.1.1/pub  ks=ftp://192.168.1.1/pub/ks.cfg


  • /var/lib/tftpboot/pxelinux/msgs/boot.msg

1. Install Cent OS 7


  • /var/ftp/pub/EFI/BOOT/grub.cfg
*** modify the bottom of config, and left only this "menuentry".

menuentry 'Install CentOS 7' --class fedora --class gnu-linux --class gnu --class os {
        linuxefi /uefi/vmlinuz ip=dhcp inst.repo=ftp://192.168.1.1/pub  ks=ftp://192.168.1.1/pub/ks.cfg
        initrdefi /uefi/initrd.img


  • /var/ftp/pub/ks.cfg  (add this kickstart file manually)
openssl passwd -1 "000000" (run this command to have encryped root password)

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use NFS installation media
url --url="ftp://192.168.1.1/pub/"
# Root password (change the value to the value above)
rootpw --iscrypted $1$JagGKmgC$Mi3cHtb2cIm62SOtbHvxA1
# System authorization information
auth  useshadow  passalgo=sha512
# Use graphical install
graphical
firstboot disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux disabled
# Installation logging level
logging level=info
# System timezone
timezone Europe/Amsterdam
# System bootloader configuration
bootloader location=mbr
clearpart --all --initlabel
part swap --asprimary --fstype="swap" --size=1024
part /boot --fstype xfs --size=200
part pv.01 --size=1 --grow
volgroup rootvg01 pv.01
logvol / --fstype xfs --name=lv01 --vgname=rootvg01 --size=1 --grow
%packages
@core
wget
net-tools
%end
%post
%end


Server settings


  • xinetd + tftp server
    • /etc/xinetd.d/tftp

service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}


  • dhcp server
    • /etc/dhcpd/dhcpd.conf

option arch code 93 = unsigned integer 16; # RFC4578
allow booting;
allow bootp;
subnet 192.168.1.0 netmask 255.255.255.0 {
    option routers 192.168.1.1;
    range 192.168.1.100 192.168.1.200;
    class "pxeclients" {
        match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
        next-server 192.168.1.1;

        if option arch = 00:07 {
            filename "pxelinux/BOOTX64.EFI";
            }
        else {
            filename "pxelinux/pxelinux.0";
        }

    }
}



  • vsftp server

no need to modify vsftpd config file

Service enablement

chkconfig tftp on
chkconfig xinetd on
chkconfig dhcpd on
chkconfig vsftpd on
service xinetd start
service tftp start
service dhcpd start
service vsftpd start

星期五, 8月 07, 2015

Install Nagios on CentOS with DELL iDRAC script

My Nagios version is 3.5.1 and available to download from here.
http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.5.1/

check_iDRAC script could be downloaded from here
https://exchange.nagios.org/directory/Plugins/Network-and-Systems-Management/Check_iDRAC-for-DELL-iDRAC/details

MIB file could be downloaded from here.
http://dezoils.com/wp-content/uploads/2014/11/iDRAC-MIB.zip

-------------------------------------- How-To ----------------------------------

There are 2 systems in this instruction, 1 for CentOS (Host) and 1 for iDRAC device (DUT).

##########  DUT iDRAC port setting
                - connect to idrac web interface (log in of course)
                - in left side, go into the Overview / iDRAC settings / Network
                - in right side (from top panel), choose Services / SNMP Agent
                - make sure "Enabled" is checked
                - make sure "SNMP Protocol" is checked on option "All (SNMP v1/v2/v3)


##########  CentOS (Host)
- Install CentOS 7
                #yum search net-snmp (make sure you can see the package list, it's normal if there is a downloading process)
                #yum install net-snmp net-snmp-utils git -y
                #git clone https://github.com/dangmocrang/check_idrac
                #cd check_idrac
                #mv idrac_2.0b9 idrac_2.0b9.py
                #python idrac_2.0b9.py -h  (please check if it can print out the help page, if yes, the script works).
                copy IDRAC-MIB.mib file as attached to Desktop

                #pwd (confirm the current directly is "/root/check_idrac", if not, please do command "#cd /root/check_idrac")
                #mv idrac_2.0b9 idrac_2.0b9.py
                #python ./idrac_2.0b9.py -H $IP_Address -c public -m /home/dell/Desktop/IDRAC-MIB.mib –n –w mem
                it's very important, you have to get response like
----------------
Memory 1 (DIMM Socket A1) 2.00 GB/1600 MHz: ENABLED/OK [DDR3, Samsung, S/N: 234A70AF]
----------------




########## Nagios Installation
**copy attathed nagios-3.5.1.tar.gz and nagios-plugins-1.4.11.tar.gz to Desktop
su -
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
yum install   httpd php  gd gd-devel gcc glibc glibc-common openssl perl perl-devel make -y
cd /home/dell/Desktop
tar -xvzf nagios
cd nagios
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cp -rvf contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin   (set the password for "nagiosadmin" user)
systemctl start httpd.service
systemctl start nagios.service
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

cp /home/dell/Desktop/IDRAC-MIB.mib /usr/share/snmp/mibs/
cp /root/check_idrac/idrac_2.0b9.py /usr/local/nagios/libexec/
chown nagios.nagios /usr/local/nagios/libexec/idrac_2.0b9.py
echo "cfg_file=/usr/local/nagios/etc/objects/idrac.cfg" >> /usr/local/nagios/etc/nagios.cfg
touch /usr/local/nagios/etc/objects/idrac.cfg
gedit /usr/local/nagios/etc/objects/idrac.cfg
                - copy & past all contents list below (#### idrac.cfg file ###) into the file
                - then you need to modify $idrac_ip_address to real DUT (idrac) IP Address (there are 2 items)
                - then save it

service nagios restart

*** now you should be able to use Chrome to browse "http://CentOS_IP_Address/nagios/" and log in as user:nagiosadmin and password you just set.


$$$$$$ for multi-DUT (idrac) $$$$$$$$$$$
cd /usr/local/nagios/etc/objects

cp idrac.cfg idrac2.cfg
cp idrac.cfg idrac3.cfg

echo "cfg_file=/usr/local/nagios/etc/objects/idrac2.cfg" >> /usr/local/nagios/etc/nagios.cfg
echo "cfg_file=/usr/local/nagios/etc/objects/idrac3.cfg" >> /usr/local/nagios/etc/nagios.cfg

and you need to modify "/usr/local/nagios/etc/objects/idrac2.cfg,idrac3.cfg...etc" for the following items.
- host_name
- $idrac_ip_address
- command_name
- $idrac_ip_address
- host_name
- check_command
#service nagios restart
$$$$$$






#### idrac.cfg file ###
define host{
        host_name                       idrac-dut
        alias                           iDRAC Server
        address                         $idrac_ip_address
        check_command                   check-host-alive
        check_interval                  1
        retry_interval                  1
        max_check_attempts              5
        check_period                    24x7
        process_perf_data               0
        retain_nonstatus_information    0
        contact_groups                  admins
        notification_interval           1
        notification_period             24x7
        notification_options            d,u,r
        }

define command{
command_name    check-idrac
command_line   python /usr/local/nagios/libexec/idrac_2.0b9.py -H $idrac_ip_address -c public -m /usr/share/snmp/mibs/IDRAC-MIB.mib -n | tee /tmp/test.log
}


define service{
host_name       idrac-dut
service_description     OnlyForTesting
check_command   check-idrac
max_check_attempts      5
check_interval  1
retry_interval  1
check_period    24x7
notification_interval   3
notification_period     24x7
notification_options    w,c,r
contacts        nagiosadmin
contact_groups  admins
        }


-------------------------------------- End of How-To ----------------------------------

星期一, 12月 22, 2014

Ubuntu 14.04 issue of SDIO kernel support (sdhci-acpi)

check reference links below.

http://serverphorums2.rssing.com/browser.php?indx=20361555&item=4129

http://ubuntuhandbook.org/index.php/2014/08/install-upgrade-linux-kernel-3-16/

Simply, update your kernel up to 3.16
2. For 64-bit system:
cd /tmp/

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

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

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

sudo dpkg -i linux-headers-3.16.0-*.deb linux-image-3.16.0-*.deb
Reboot and done.
If for some reason this kernel release doesn’t work properly for you, reboot into previous kernel (Grub -> Advanced -> select previous kernel) and run this command to remove Linux Kernel 3.16:
sudo apt-get remove linux-headers-3.16.0-* linux-image-3.16.0-*
Finally update grub menu:

sudo update-grub

*********** might be useful for realtek rtl8723bs module ************
http://ubuntuforums.org/showthread.php?t=2249936


星期四, 6月 26, 2014

Install Unity8 with touch

Install Unity 8 with touch
install 14.10
apt-get update then upgrade
install unity8-desktop-session-mir
##############
- for unity8 login hangs fix
wget https://launchpad.net/~ci-train-ppa-service/+archive/landing-005/+build/6112664/+files/qtubuntu-sensors_0.6%2B14.10.20140619-0ubuntu1_amd64.deb
and install this fix for unity8
- for unity8 touch fix
mkdir /usr/idc and create a file named /usr/idc/Vendor_04f3_Product_023e.idc
add 2 lines there
device.internal = 1
touch.deviceType = touchScreen
###################
log out and in, then you will see a Unity8-Mir option in login section

Quick note of LXC on Ubuntu 14.10 with X, MIR on Unity7

Install LXC
install lxc
* sudo for all lxc command
lxc-create -t ubuntu -n project-name
## The OS installed here is very limited, only pure rootfs, so most of commands and packages need to be installed manually. And the default user and password is ubuntu.ubuntu##

configuration files
--------------------
/var/lib/lxc/project-name/config
- add mount socket config into it
#lxc.mount.entry = /dev/dri dev/dri none bind,optional,create=dir
#lxc.mount.entry = /dev/snd dev/snd none bind,optional,create=dir1

# For mount the X socket and use it
lxc.mount.entry = /tmp/.X11-unix tmp/.X11-unix none bind,optional,create=dir
lxc.mount.entry = /dev/video0 dev/video0 none bind,optional,create=file
---------------------

Run LXC under default unity7 with X socket
lxc-start -n project-name
install bash-completion
(for tab usage, and need to reboot for enable)
install firefox
$firefox --display=:0
(Or you can do "export DISPLAY=:0)
Now you can see the firefox running on the screen via LXC

Run LXC under default unity7 with MIR socket
install mir-demos
switch to console mode (tty1)
sudo mir-demo-server-shell (will create the mir on tty1)
switch to tty2
change the default socket config, /var/lib/lxc/project-name/config, to
lxc.mount.entry = /tmp/mir tmp/mir none bind,optional,create=dir
create /tmp/mir and MOVE mir_socket from /tmp to /tmp/mir
chmod 777 /tmp/mir/mir_socket
### in container ###
lxc-start -n project-name
install mir-demos
* check /tmp/mir to see if there is a "mir_socket" file.
mir_demo_client_eglplasma -m /tmp/mir/mir_socket
DONE!!!


Unprivileged LXC containers
add below 2 lines in config file
lxc.id_map = u 0 100000 65536
lxc.id_map = g 0 100000 65536

Then, assign yourself a set of uids and gids with:

sudo usermod –add-subuids 100000-165536 $USER
sudo usermod –add-subgids 100000-165536 $USER
sudo chmod +x $HOME

Now create ~/.config/lxc/default.conf with the following content:

lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:xx:xx:xx
lxc.id_map = u 0 100000 65536
lxc.id_map = g 0 100000 65536
And /etc/lxc/lxc-usernet with:

veth lxcbr0 10
And that’s all you need. Now let’s create our first unprivileged container with:


lxc-create -t download -n p1 -- -d ubuntu -r trusty -a amd64

chmod +x for /home/user/.local   and   /home/user/.local/share
the config file will store at $HOME/.local/share/lxc/project-name/config
DONE!!!



reference site
https://www.stgraber.org/2013/12/20/lxc-1-0-your-first-ubuntu-container/


星期三, 10月 30, 2013

Atheros 0036 on ACER Aspire V5-132 with Ubuntu 12.04.2 (issue for ath9k)

This machine has only wifi connection, no wired to connect to Internet.
The worst thing is the native ath9k driver is failed, that means you won't have any resource to connect outside the world..... :(
Thus, here is what I have done for the solution (easy job) to get my wifi back to real life.

1. need a smart phone to share network with usb connection....:)
2. if not, then you may need to have any other same ubuntu 12.04.2 device to download all the packages, then copy to your system. (apt-get download package-name)
3. apt-get update (for updating your source list)
4. apt-get install linux-headers-generic build-essential
(for compiling driver later)
5. download the compat driver from the link below
https://www.kernel.org/pub/linux/kernel/projects/backports/stable/
from the link, you need to find out the package name "compat-drivers-3.9-rc4-2-s.tar.bz2" and download to local.
6. extract file and enter the folder
7. sudo su (easier to do all jobs later)
8. ./scripts/driver-select ath9k
9. make;make install
10. you can reboot and get your wifi back now.