Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Thursday, August 20, 2015

Wednesday, February 25, 2015

RAMDISK

linux command (network)

Add Network (network command)

(1)add interface
[root@server ~]#cd /etc/sysconfig/network-scripts
[root@server ~]#vi ifcfg-eth0
DEVICE="eth2"
BOOTPROTO="dhcp"
HWADDR="00:02:C9:27:59:FE"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
IPV6INIT="no"

(2)If set ip, will not active after reboot.
When we set some ip address, after reboot or services restart will not active. This means that we have to kill the temporary store ip address. This often occur when we had a dhcp Ip address, then we wants to change to a static. But i also found out that if i wants to change a new network card, will also happen, the ip will not change.

Please set ip address first, then clear this.
[root@server ~]#cd /etc/udev/rules.d
[root@server ~]#rm 70-persistent-net.rules

(3) show ip address
[root@server ~]#ifconfig

(4) show ip interface
[root@server ~]#ip a












(5) ethtool - query or control network driver and hardware settings
ethtool ethernet interface
#ethtool eth0
This will let you see your link rate, support wake on lan, lan detect or not, and so on.

(6) enable your interface
#ifdown eth0
#ifup eth0

(7) ping
ping ip address
ping -c 1 ipaddress  ==>ping one second

(8) Search dhcp client ip address, or bmc ip address
cat /var/log/messages | grep BMC MAC address
example: cat /var/log/messages | grep  xx:xx:xx:xx:xx:xx

(9) changed Server name 
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=putXX




Linux command

PART 1 SIMPLE COMMAND

(1) list directory contents (refer to window dir)
command: ls
Description /purpose: Print or list the file or folder in this directory

[root@server ~]# ls

command: ll
Description /purpose:  Print or list the file or folder in this directory, but this will show information.
[root@server ~]# ll













(2) print name of current/working directory (pwd)
Description /purpose: show which directory or path you are in right now.
[root@server ~]# pwd
/root

(3) copy (cp)
Description /purpose: copy file or create backup

#cp dhcp.conf dhcp.conf.bk

(4)move or rename file ( mv)
Description /purpose:  rename a file name, or generate a file
#mv old.txt new.txt

(5) cat
Description /purpose: read a file name
cat 123.txt

(6)modify text (vi or vim)
Description /purpose: to modify some file
vi is modify, and vim is improve, which will have show in different color.
Some variable need to used

vi











vim

:q! ==>exit without saving
:w! ==>save
:wq!==>save and quit
:x!==>save and exit
? or / ==>search

Note: For more information, please refer shell script



(7) touch
Description /purpose:to generate a file. Different between vi is it don't have to save to generate a file. It will generate a file if input touch command.
touch aaa.txt

(8)tail
Description /purpose: output the last part of files
will print last 10 line 
#tail /var/log/message

 output appended data as the file grows. 
#tail -f

difference from cat versus tail
tail is different from cat, is cat will read all the file once, but tail will not. For example if you have a log file, you cat log file, it will read all the line from first line to last line. But tail will read last line, and if the file still have message, it will also show.

 (9) clear
Description /purpose:clear the terminal screen
#clear


PART 2 Intermediate (common used and file related)

1. extract file
tar -zxvf extract.tar.gz
#tar -zxvf filename.tar.gz 

2. compress file
tar -tzvf compressed.tar.gz
tar -zcvf filnename.tar.gz 'folder destination/'
#tar -zcvf filnename.tar.gz folder /test

3. mount
what is mount?
A mount is where I wants to mount a directory into one folder. Mount this command can used for many ways.
Basely mount this command is like if i have a directory names test, if i wants to mount a directory "dhcp" into test this directory. Directory test all the data will be used by dhcp this directory. In other word mean all test directory will be gone, will only appear dhcp data. If you umount it, it will be appear.

Mount this command can be used for:

Mount for folder to folder which is like shortcut
# mount --bind /etc/dhcp /dhcpfile_test











Mount for usb drive to /mnt directory 




Mount for network 



4 link or shortcut
command "ln -s"
ln -s orginally folder or file shortcut
# ln -s /etc/dhcp/ /dhcpfile











5 set date
date MMddhhmmyyyy




BATCH(.bat) SCRIPT(window)

PART1 SIMPLE

(1)CREATE FOLDER

set /P id=Enter id:
mkdir %id%

(2) FOLDER NAME WITH DATE
for /F "tokens=1-4 delims=/ " %%A in ('date/t') do (
set DateDay=%%A
set DateMonth=%%B
set DateYear=%%C
)

set CurrentDate=%DateMonth%-%DateDay%-%DateYear%

mkdir %CurrentDate% 

(3) PING 
@echo off
set /p a="Enter IP Address or Name: "
ping %a%
pause

(4)


PART2 Mixed function script
(1) user enter Devices name and IP address

@echo off
for /F "tokens=1-4 delims=/ " %%A in ('date/t') do (
set DateDay=%%A
set DateMonth=%%B
set DateYear=%%C
)


set CurrentDate=%DateDay%-%DateMonth%-%DateYear%
set /P name=Enter name of folder:
set /p bmc_ip="Enter BMC IP Address: "


mkdir %CurrentDate%_%name%

@echo on
ipmitool -I lan -H %bmc_ip% -U USERID -P PASSW0RD sensor >  %CurrentDate%_%name%/SENSOR.TXT
ipmitool -I lan -H %bmc_ip% -U USERID -P PASSW0RD sel list >  %CurrentDate%_%name%/list.TXT
ipmitool -I lan -H %bmc_ip% -U USERID -P PASSW0RD sel elist > %CurrentDate%_%name%/elist.TXT


output:
Enter name of folder: DUT1-1
Enter BMC IP Address: 192.168.1.2

Wednesday, November 12, 2014

PXE Setup

PXE legacy/uefi NFS[RHEL6.4]
PXE legacy/uefi HTTP/FTP[RHEL6.4]
Set up Pxe Server with RHEL7.X/ Centos7.X HTTP

Set up Pxe Server with kicstart automation (uefi /legacy ) NFS

introduce folder and create folder: 
[root@localhost ~]# cd /
[root@localhost /]# mkdir /install/nfs_share
[root@localhost /]# mkdir /install/tftpboot

/install/nfs_share  ==>put kicstart file, and out centos images
/install/tftpboot ==>put your pxe menu page

1.Disable Firewall:
[root@localhost ~]# service iptables stop

2.Disable SELinux
[root@localhost ~]# setenforce 0

3. copy cdrom file from dvd rom into desktop
[root@localhost ~]# cp –av /media/CentOS_6.4_Final /*

4.Convert centos images folder into iso file
command: mkisofs –r –o [filename].iso /[file destination/
[root@localhost ~]# mkisofs –r –o Centos_6.4.iso / CentOS_6.4_Final

5. Set your ip address.
Eth0 set 192.168.2.1, mask: 24, gateway: 192.168.2.254
Eth1: set 192.168.1.1, mask: 24, gateway: 192.168.1.254
Reboot DUT

6.DHCP service
[root@localhost ~]#vi /etc/sysconfig/dhcpd
DHCPD_INTERFACE="et01 eth1"
[root@localhost ~]# vi /etc/dhcp/dhcpd.conf

dhcpd.conf: 

ignore client-updates;
ddns-update-style interim;
default-lease-time 259200;
max-lease-time 518400;
option arch code 93 = unsigned integer 16;
next-server 192.168.2.1;
subnet 192.168.2.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.2.2 192.168.2.200;
if option arch = 00:07{

#for uefi
filename "BOOTX64.efi";
}else{

#for legacy
filename "pxelinux.0";
}


}

7. TFTP service
[root@localhost ~]# vim /etc/xinetd.d/tftp

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

8. Create tftpboot directory

[root@localhost tftpboot]# chcon --reference /var/lib/tftpboot /install/tftpboot
[root@localhost /]# cp /usr/share/syslinux/menu.c32 /usr/share/syslinux/vesamenu.c32 /usr/share/syslinux/pxelinux.0 /install/tftpboot/
[root@localhost /]# mkdir /install/tftpboot/pxelinux.cfg
[root@localhost /]# mount -o loop Centos_6.4.iso /mnt/
[root@localhost /]# mkdir -p /install/tftpboot/kernel/centos6.4
[root@localhost /]# cp /mnt/isolinux/vmlinuz /install/tftpboot/kernel/centos6.4
[root@localhost /]# cp /mnt/isolinux/initrd.img /install/tftpboot/kernel/centos6.4
[root@localhost /]# cp /mnt/isolinux/isolinux.cfg /install/tftpboot/pxelinux.cfg/
[root@localhost /]# cp /mnt/isolinux/boot.msg /install/tftpboot/
[root@localhost /]# cp /mnt/EFI/BOOT/*.* /install/tftpboot/
[root@localhost /]# cp /efidefault /insatll/tftpboot/

9.NFS service
[root@localhost /]# mkdir -p /install/nfs_share/centos6.4
[root@localhost /]# vim /etc/fstab

fstab:
/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
UUID=46cb1b57-c057-4963-9682-23d850a3fc9d /boot ext4 defaults 1 2
/dev/mapper/VolGroup-lv_home /home ext4 defaults 1 2
/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
#add this line
/Centos_6.4.iso /install/nfs_share/centos6.4 iso9660 defaults,loop 0 0

to enable mount
[root@localhost /]# mount -a
#check to see if it is mounted
[root@localhost /]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
51606140 16999308 31985392 35% /
tmpfs 987372 228 987144 1% /dev/shm
/dev/sda1 495844 39677 430567 9% /boot
/dev/mapper/VolGroup-lv_home
184350796 191852 174794464 1% /home
/Centos_6.4.iso 3681792 3681792 0 100% /install/nfs_share/centos6.4


9.Edit exports
[root@localhost /]# vim /etc/exports

[root@localhost /]# mkdir -p /home/leopard

exports:
#/install/nfs_share/ 192.168.2.*(ro)
/install/nfs_share/ 192.168.2.0/24(ro,async,nohide,crossmnt) localhost(ro,async,nohide,crossmnt)
/home/leopard *(rw,no_root_squash,sync)

10.   Set up UEFI and Legacy configure menu boot

Set up UEFI PXE configuration
[root@localhost /]# cd /install/tftpboot
[root@localhost tftpboot]# vi efidefault

#debug --graphics
default=0
#splashimage=(nd)/splash.xpm.gz
timeout 40
#hiddenmenu

title [Leopard_uEFI] CentOS 6.4 x64 for SOL kickstart
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=nfs:192.168.2.1:/install/nfs_share/sol.ks text console=ttyS1,57600
initrd /kernel/centos6.4/initrd.img

title [Leopard_uEFI] CentOS 6.4 x64 for com kickstart
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=nfs:192.168.2.1:/install/nfs_share/com.ks text console=ttyS0,57600
initrd /kernel/centos6.4/initrd.img

title [Leopard_uEFI] CentOS 6.4 x64 manual
root (nd)
kernel /EFI_kernel/centos64x64/vmlinuz ip=dhcp method=nfs:192.168.2.1:/images/centos64x64
initrd /EFI_kernel/centos64x64/initrd.img

title [Leopard_uEFI] CentOS 6.4 x64 for guifullap
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=nfs:192.168.2.1:/install/nfs_share/guifullap.cfg 
initrd /kernel/centos6.4/initrd.img

 Set up  legacy BIOS PXE configuration
[root@localhost /]# cd /install/tftpboot/pxelinux.cfg
[root@localhost pxelinux.cfg]# vi default

default menu.c32
    prompt 0
    timeout 300
    
      menu title ==== Boot Menu ====

#LABEL 1)CENTOSX64 LEDGACY (NFS method)   
#MENU  [Leopard_uEFI] CentOS 6.4 x64 for SOL kickstart
#kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=nfs:192.168.2.1:/install/nfs_share/sol.ks text console=ttyS1,57600
#initrd /kernel/centos6.4/initrd.img

LABEL 1) Boot from local drive
   menu label ^2) Boot from local drive
   localboot

LABEL 2) CentOS 6.4 x64 final SOL kickstart(http:// method)
kernel kernel/centos6.4/vmlinuz
append initrd=kernel/centos6.4/initrd.img text quiet console=ttyS1,57600n8 ks=nfs://192.168.2.1:/install/nfs_share/sol.ks

LABEL 2) CentOS 6.4 x64 final SOL kickstart(http:// method)
kernel kernel/centos6.4/vmlinuz
append initrd=kernel/centos6.4/initrd.img text quiet console=ttyS0,57600n8 ks=nfs://192.168.2.1:/install/nfs_share/com.ks

LABEL 4) CentOS 6.4 x64 final manual (http:// method)
kernel kernel/centos6.4/vmlinuz
append initrd=kernel/centos6.4/initrd.img method=nfs://192.168.2.1:/Centos6.4 ip=dhcp

11. kickstart setup
[root@localhost /]# cp /sol.ks com.ks /install/nfs_share/


11.vftfp setup (put driver inside ftp)
[root@localhost /]#cp /V9_20141028.tar /var/ftp

12.chkconfig setup (enable services)
[root@localhost /]# chkconfig xinetd on
[root@localhost /]# chkconfig tftp on
[root@localhost /]# chkconfig rpcbind on
[root@localhost /]# chkconfig nfs on
[root@localhost /]# chkconfig rpcidmapd on
[root@localhost /]# chkconfig nfslock on
[root@localhost /]# chkconfig vsftpd on
[root@localhost /]# chkconfig dhcpd on

13.Reboot server or start service
[root@localhost ~]# /etc/init.d/dhcpd restart
[root@localhost tftpboot]# /etc/init.d/xinetd restart
[root@localhost /]# /etc/init.d/rpcbind restart
[root@localhost /]# /etc/init.d/nfs restart
[root@localhost /]# /etc/init.d/rpcidmapd restart
[root@localhost /]# /etc/init.d/nfslock restart

# make sure vsftpd services is running
[root@localhost /]# /etc/init.d/vsftpd start

14 give permission to kernel
chmod 777 /install/tftpboot/kernel
chmod 777 /install/tftpboot/kernel/centos6.4

_______________________________________________________________________

Set up Pxe Server with kicstart automation (uefi /legacy ) HTTP

introduce folder and create folder: 
[root@localhost ~]# cd /
[root@localhost /]# mkdir /tftpboot


1.Disable Firewall:
[root@localhost ~]# service iptables stop

2.Disable SELinux
[root@localhost ~]# setenforce 0

3. copy cdrom file from dvd rom into desktop, and create into iso filoe
[root@localhost ~]# mkdir /var/www/html/Centos6.4
[root@localhost ~]# cd /var/www/html
[root@localhost html]# mkisofs -r -o /centos6.4.iso Centos6.4/

4. Set your ip address.
Eth0 set 192.168.2.1, mask: 24, gateway: 192.168.2.254
Eth1: set 192.168.1.1, mask: 24, gateway: 192.168.1.254
Reboot DUT

5.DHCP service
[root@localhost ~]#vi /etc/sysconfig/dhcpd
DHCPD_INTERFACE="et01 eth1"
[root@localhost ~]# vi /etc/dhcp/dhcpd.conf

dhcpd.conf: 

ignore client-updates;
ddns-update-style interim;
default-lease-time 259200;
max-lease-time 518400;
option arch code 93 = unsigned integer 16;
next-server 192.168.2.1;
subnet 192.168.2.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.2.2 192.168.2.200;
if option arch = 00:07{

#for uefi
filename "BOOTX64.efi";
}else{

#for legacy
filename "pxelinux.0";
}


}

6. TFTP service
[root@localhost ~]# vim /etc/xinetd.d/tftp

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

7. Create tftpboot directory

[root@localhost tftpboot]# chcon --reference /var/lib/tftpboot /tftpboot
[root@localhost /]# cp /usr/share/syslinux/menu.c32 /usr/share/syslinux/vesamenu.c32 /usr/share/syslinux/pxelinux.0 /tftpboot/
[root@localhost /]# mkdir /tftpboot/pxelinux.cfg
[root@localhost /]# mkdir -p /tftpboot/kernel/centos6.4
[root@localhost /]# cp /mnt/isolinux/vmlinuz /tftpboot/kernel/centos6.4
[root@localhost /]# cp /mnt/isolinux/initrd.img /tftpboot/kernel/centos6.4
[root@localhost /]# cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/
[root@localhost /]# cp /mnt/isolinux/boot.msg /tftpboot/
[root@localhost /]# cp /mnt/EFI/BOOT/*.* /tftpboot/
[root@localhost /]# cp /efidefault /tftpboot/


8. Create file in httpd directory
[root@localhost /]#  cd /var/www/html
[root@localhost html]# mkdir Centos6.4
[root@localhost /]# mount -o loop centos6.4.iso /var/www/html/Centos6.4


fstab:
/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
UUID=46cb1b57-c057-4963-9682-23d850a3fc9d /boot ext4 defaults 1 2
/dev/mapper/VolGroup-lv_home /home ext4 defaults 1 2
/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
#add this line

/centos6.4.iso /var/www/html/Centos6.4 iso9660 defaults,loop 0 0

9.   Set up UEFI and Legacy configure menu boot

Set up UEFI PXE configuration
[root@localhost /]# cd /install/tftpboot
[root@localhost tftpboot]# vi efidefault

#debug --graphics
default=0
#splashimage=(nd)/splash.xpm.gz
timeout 40
#hiddenmenu

title [Leopard_uEFI] CentOS 6.4 x64 for SOL kickstart 111
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=http://192.168.2.1/kickstart/centos6.4/sol.ks text console=ttyS1,57600
initrd /kernel/centos6.4/initrd.img

title [Leopard_uEFI] CentOS 6.4 x64 for com kickstart
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=http://192.168.2.1/kickstart/centos6.4/com.ks text console=ttyS0,57600
initrd /kernel/centos6.4/initrd.img

title [Leopard_uEFI] CentOS 6.4 x64 for guifullap
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=http://192.168.2.1/kickstart/centos6.4/guifullap.ks
initrd /kernel/centos6.4/initrd.img

title [Leopard_uEFI] CentOS 6.4 x64 for guifullap_manual
root (nd)
kernel /kernel/centos6.4/vmlinuz ip=dhcp method=http//192.168.2.1/Centos6.4
initrd /kernel/centos6.4/initrd.img

 Set up  legacy BIOS PXE configuration
[root@localhost /]# cd /install/tftpboot/pxelinux.cfg
[root@localhost pxelinux.cfg]# vi default
 default menu.c32
    prompt 0
    timeout 300
    
      menu title ==== Boot Menu ====

#LABEL 1)CENTOSX64 LEDGACY (NFS method)   
#MENU  [Leopard_uEFI] CentOS 6.4 x64 for SOL kickstart
#kernel /kernel/centos6.4/vmlinuz ip=dhcp ks=nfs:192.168.2.1:/install/nfs_share/sol.ks text console=ttyS1,57600
#initrd /kernel/centos6.4/initrd.img

LABEL 1) Boot from local drive
   menu label ^2) Boot from local drive
   localboot

LABEL 2) CentOS 6.4 x64 final (http:// method)
kernel kernel/centos6.4/vmlinuz
#append initrd=kernel/centos6.4/initrd.img \ method=http://192.168.2.1/Centos6.4 ip=dhcp
append initrd=kernel/centos6.4/initrd.img ks=http://192.168.2.1/kickstart/centos6.4/guifullap.ks ip=dhcp


LABEL 3) CentOS 6.4 x64 final SOL kickstart(http:// method)
kernel kernel/centos6.4/vmlinuz
append initrd=kernel/centos6.4/initrd.img text quiet console=ttyS1,57600n8 ks=http://192.168.2.1/kickstart/centos6.4/sol.ks

LABEL 4) CentOS 6.4 x64 final manual (http:// method)
kernel kernel/centos6.4/vmlinuz
append initrd=kernel/centos6.4/initrd.img method=http://192.168.2.1/Centos6.4 ip=dhcp



11. kickstart setup
[root@localhost /]# cd /var/www/html
[root@localhost html]# mkdir kickstart
[root@localhost kickstart]# mkdir centos6.4
[root@localhost /]# cp /sol.ks com.ks /var/www/html/kickstart/centos6.4

12.vftfp setup (put driver inside ftp) optional
[root@localhost /]#cp /V9_20141028.tar /var/ftp

13.chkconfig setup (enable services)
[root@localhost /]# chkconfig xinetd on
[root@localhost /]# chkconfig tftp on
[root@localhost /]# chkconfig rpcbind on
[root@localhost /]# chkconfig nfs on
[root@localhost /]# chkconfig rpcidmapd on
[root@localhost /]# chkconfig nfslock on
[root@localhost /]# chkconfig vsftpd on
[root@localhost /]# chkconfig dhcpd on
[root@localhost /]# chkconfig httpd on

14.Reboot server or start service
[root@localhost ~]# /etc/init.d/dhcpd restart
[root@localhost tftpboot]# /etc/init.d/xinetd restart
[root@localhost /]# /etc/init.d/rpcbind restart
[root@localhost /]# /etc/init.d/nfs restart
[root@localhost /]# /etc/init.d/rpcidmapd restart
[root@localhost /]# /etc/init.d/nfslock restart
[root@localhost /]#  /etc/init.d/httpd restart
# make sure vsftpd services is running
[root@localhost /]# /etc/init.d/vsftpd start

15 give permission to kernel
chmod 777 /tftpboot/kernel
chmod 777 /tftpboot/kernel/centos6.4


_______________________________________________________________________

Set up Pxe Server with RHEL7.X/ Centos7.X HTTP
all the settingis the same, except efidefault is different.

title [Leopard_uEFI] CentOS 6.4 x64 for guifullap_manual
root (nd)
kernel /kernel/rhel7.1/vmlinuz inst.stage2=http//192.168.2.1/rhel7.1
initrd /kernel/rhel7.1/initrd.img
-----------------------------------------------------------------------------------------------------------------

reference:
Chinese: 
http://benjr.tw/83/5
http://blog.xuite.net/geniusn/note/29065663-%E7%94%A8CentOS%E6%9E%B6%E8%A8%ADPXE+Server
http://www.dotblogs.com.tw/ghoseliang/archive/2013/05/01/102558.aspx
English:
http://djmimi-linux.blogspot.tw/2014/03/how-to-build-pxe-server-support-legacy.html