Freeradius dynamic vlan assignement 802.1x
eap.conf
peap
copy_request_to_tunnel = yes
use_tunneled_reply = yes
user
dhc Cleartext-Password := "pasondhc"
Tunnel-Type = VLAN,
Tunnel-Medium-Type = IEEE-802,
Tunnel-Private-Group-ID := "105"
u10 Cleartext-Password := "u10"
Tunnel-Type = VLAN,
Tunnel-Medium-Type = IEEE-802,
Tunnel-Private-Group-ID := "10"
inner-tunnel
add perl to authorize
peap
copy_request_to_tunnel = yes
use_tunneled_reply = yes
user
dhc Cleartext-Password := "pasondhc"
Tunnel-Type = VLAN,
Tunnel-Medium-Type = IEEE-802,
Tunnel-Private-Group-ID := "105"
u10 Cleartext-Password := "u10"
Tunnel-Type = VLAN,
Tunnel-Medium-Type = IEEE-802,
Tunnel-Private-Group-ID := "10"
inner-tunnel
add perl to authorize
vmware 9.0.2 and 3.10 kernel
http://uwot.eu/blog/2013/07/linux-kernel-3-10-and-vmware-workstation-9/
http://mysticalzero.blogspot.ca/2013/07/vmblock-patch-for-linux-310-vmware.html
http://mysticalzero.blogspot.ca/2013/07/vmblock-patch-for-linux-310-vmware.html
task blocked for more than 120 seconds
This was seen quite frequently on Centos 5 using software raid 1. These was only added since kernel 2.6.18.194. I found there are two causes:
The first one is the same as described here http://blog.ronnyegner-consulting.de/2011/10/13/info-task-blocked-for-more-than-120-seconds/. Adjusting the following helps: lower vm.dirty_background_ratio, and either lower or increase vm.dirty_ratio. increase vm.dirty_ratio so that the sync io never happens and decrease it so that when sync io happens, it does not take as long.
The second cause seems to be related to barrier being enabled. This happens when IO is heavy on the partition mounted with barrier=1. After set barrier=0, I could not no longer reproduce the issue. I wonder if there is a bug/interaction when barrier=1.
The second cause seems to be related to barrier being enabled. This happens when IO is heavy on the partition mounted with barrier=1. After set barrier=0, I could not no longer reproduce the issue. I wonder if there is a bug/interaction when barrier=1.
df Showed More Disk Usage Than du
Process holding on to the FD of the file has been deleted
lsof -n -P | grep deletedthen kill processes holding on to the deleted file.
Monitor Dirty Cache
while true; do grep -A1 dirty /proc/vmstat; grep Dirty /proc/meminfo; sleep 1; done
tunning MD RAID
http://blog.rot13.org/2012/10/mdadm-how-to-tune-your-md-software-raid.html
http://www.cyberciti.biz/tips/linux-raid-increase-resync-rebuild-speed.html
http://www.cyberciti.biz/tips/linux-raid-increase-resync-rebuild-speed.html
High IO Wait
for x in `seq 1 1 100`; do ps -eo state,pid,cmd | grep "^D"; echo "----"; sleep 5; doneref: http://bencane.com/2012/08/troubleshooting-high-io-wait-in-linux/
#!/bin/sh while true; do echo "---------- `date` ---------"; uptime echo "#################" ps -eo state,pid,args | grep "^D"; echo "#################" top -b -n 1 -c |head #iotop -o -b -n 1 | head echo "#################" grep Dirty /proc/meminfo grep -A 1 dirty /proc/vmstat sleep 10 donesee if the process does fsync
strace -p pid -e trace=fsync,fdatasyncmonitor a process's cpu, rss and etc
monitor() { pid=$1 peakRSS=0 peakCPU=0 RUNTIME=0 totWrite=0 totalCPU=0 while true; do sampleRSS="$(ps -o rss= $pid 2> /dev/null)" || break let peakRSS='sampleRSS > peakRSS ? sampleRSS : peakRSS' sampleCPU="$(ps -o pcpu= $pid 2> /dev/null)" || break #echo $sampleCPU res=`echo "$sampleCPU > $peakCPU" | bc` if [ $res -eq 1 ]; then peakCPU=$sampleCPU fi totalCPU=`echo "$totalCPU + $sampleCPU" | bc` sampeWrite=`grep "^write_bytes" /proc/$pid/io | awk '{print $2}'` let totWrite='sampeWrite > totWrite ? sampeWrite : totWrite' RUNTIME=$(($RUNTIME + 1)) sleep 1 done avgcpu=`echo "scale = 2; $totalCPU / $RUNTIME" | bc` echo "PeakRSS: $peakRSS" echo "PeakCPU: $peakCPU" echo "AvgCPU: $avgcpu" echo "TotWrite: $totWrite" echo "Runtime: $RUNTIME" }
smartctl
# smartctl -d ata -a /dev/sda # smartctl -d ata -l error /dev/sda smartctl version 5.36 [x86_64-redhat-linux-gnu] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF READ SMART DATA SECTION === SMART Error Log Version: 1 ATA Error Count: 2512 (device log contains only the most recent five errors) CR = Command Register [HEX] FR = Features Register [HEX] SC = Sector Count Register [HEX] SN = Sector Number Register [HEX] CL = Cylinder Low Register [HEX] CH = Cylinder High Register [HEX] DH = Device/Head Register [HEX] DC = Device Command Register [HEX] ER = Error register [HEX] ST = Status register [HEX] Powered_Up_Time is measured from power on, and printed as DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes, SS=sec, and sss=millisec. It "wraps" after 49.710 days. Error 2512 occurred at disk power-on lifetime: 783 hours (32 days + 15 hours) When the command that caused the error occurred, the device was active or idle. After command completion occurred, registers were: ER ST SC SN CL CH DH -- -- -- -- -- -- -- 40 51 80 a0 44 91 ee Error: UNC 128 sectors at LBA = 0x0e9144a0 = 244401312 Commands leading to the command that caused the error were: CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name -- -- -- -- -- -- -- -- ---------------- -------------------- c8 00 80 a0 44 91 ee 00 1d+13:03:26.878 READ DMA ec 00 00 00 00 00 a0 00 1d+13:03:26.875 IDENTIFY DEVICE ef 03 42 00 00 00 a0 00 1d+13:03:26.875 SET FEATURES [Set transfer mode] Error 2511 occurred at disk power-on lifetime: 783 hours (32 days + 15 hours) When the command that caused the error occurred, the device was active or idle. After command completion occurred, registers were: ER ST SC SN CL CH DH -- -- -- -- -- -- -- 01 51 80 a0 44 91 ee Error: AMNF 128 sectors at LBA = 0x0e9144a0 = 244401312 Commands leading to the command that caused the error were: CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name -- -- -- -- -- -- -- -- ---------------- -------------------- c8 00 80 a0 44 91 ee 00 1d+13:03:22.338 READ DMA ec 00 00 00 00 00 a0 00 1d+13:03:22.335 IDENTIFY DEVICE ef 03 42 00 00 00 a0 00 1d+13:03:22.335 SET FEATURES [Set transfer mode] Error 2510 occurred at disk power-on lifetime: 783 hours (32 days + 15 hours) When the command that caused the error occurred, the device was active or idle. After command completion occurred, registers were: ER ST SC SN CL CH DH -- -- -- -- -- -- -- 40 51 80 a0 44 91 ee Error: UNC 128 sectors at LBA = 0x0e9144a0 = 244401312 Commands leading to the command that caused the error were: CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name -- -- -- -- -- -- -- -- ---------------- -------------------- c8 00 80 a0 44 91 ee 00 1d+13:03:19.452 READ DMA ec 00 00 00 00 00 a0 00 1d+13:03:19.449 IDENTIFY DEVICE ef 03 42 00 00 00 a0 00 1d+13:03:19.449 SET FEATURES [Set transfer mode] Error 2509 occurred at disk power-on lifetime: 783 hours (32 days + 15 hours) When the command that caused the error occurred, the device was active or idle. After command completion occurred, registers were: ER ST SC SN CL CH DH -- -- -- -- -- -- -- 40 51 80 a0 44 91 ee Error: UNC 128 sectors at LBA = 0x0e9144a0 = 244401312 Commands leading to the command that caused the error were: CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name -- -- -- -- -- -- -- -- ---------------- -------------------- c8 00 80 a0 44 91 ee 00 1d+13:03:16.566 READ DMA ec 00 00 00 00 00 a0 00 1d+13:03:16.563 IDENTIFY DEVICE ef 03 42 00 00 00 a0 00 1d+13:03:16.563 SET FEATURES [Set transfer mode] Error 2508 occurred at disk power-on lifetime: 783 hours (32 days + 15 hours) When the command that caused the error occurred, the device was active or idle. After command completion occurred, registers were: ER ST SC SN CL CH DH -- -- -- -- -- -- -- 40 51 80 a0 44 91 ee Error: UNC 128 sectors at LBA = 0x0e9144a0 = 244401312 Commands leading to the command that caused the error were: CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name -- -- -- -- -- -- -- -- ---------------- -------------------- c8 00 80 a0 44 91 ee 00 1d+13:03:13.680 READ DMA ec 00 00 00 00 00 a0 00 1d+13:03:13.677 IDENTIFY DEVICE ef 03 42 00 00 00 a0 00 1d+13:03:13.677 SET FEATURES [Set transfer mode]
Write Hex to a File from Bash
$printf '\x78\x56\x34\x12' > binfile $perl -e 'print pack "H*", "78563412"' > binfile $ od -x binfile 0000000 5678 1234
Cron Job to Suspend Machine Everyday at 2:05am
# cat /etc/cron.d/suspend # suspend every day at 2am. 5 2 * * * root /sbin/pm-suspend
Hex to C String
In case, you do not have sprintf or atoi and etc. Not efficient but works.
char hexDigit(unsigned char n) { if (n < 10) { return n + '0'; } else { return (n - 10) + 'A'; } } void hexify_ascii(char c, char * buf) { char high = (c >> 4) & 0xF; char low = c & 0xF; *buf = hexDigit(high); *(buf + 1) = hexDigit(low); } void printHex(char* input, int len) { char buf[200]; char* p = buf; int i; for (i = 0; i < len; ++i) { hexify_ascii(input[i], p); p+=2; } *p = 0; uart_print(buf); // printf("%s\n", buf); }
Creating Bootable Fedora 18 USB Stick
livecd-tools
First make 1 partition with bootable flag with fdisk$ sudo mkfs.vat /dev/sdc1 $ sudo yum install livecd-tools livecd-iso-to-disk path-to/Fedora-18-x86_64-DVD.iso /dev/sdc1
CISCO Router Commands
Basic
# write = copy running-config startup-config # write eraseCtrl-R = refresh line Ctrl-Z = end Ctrl-A = beginning of a line Ctrl-E = end of the line Ctrl-D = Delete previous char Ctrl-W = delete previous word
IP Address, subnetting
Class A: starts with 0x0xxxxxxx (0-127), 127=128-1 Class B: starts with 0x10xxxxxx (128-191), 191 = 128+64-1 Class C: starts with 0x110xxxxx(192-223), 223 = 128+64+32-1 Class D: starts with 0x1110xxxx(224-239), 239= 128+64+32+16-1 Class E: starts with 0x11110xxx(240-255) not used.List DHCP lease and clients
show dhcp server show dhcp lease show ip dhcp binding
NAT
config t interface gigabitethernet 0/1 ip nat inside end # forward ssh ip nat inside source static tcp 192.168.10.1 22 interface BVI3 22 # turn it off no ip nat inside source static tcp 192.168.10.1 22 interface BVI3 22
SVI - Switch Virtual Interface
There is no physical interface for the VLAN and the SVI provides the Layer 3 processing for packets from all switch ports associated with the VLAN. - There is one-to-one mapping between a VLAN and SVI# int vlan 1 # ip address 192.168.0.254 255.255.255.0 # int vlan 2 # ip address 192.168.1.254 255.255.255.0# ip default gateway 192.168.1.254
IP Routing
# ip routing # no ip routing
Static Routing
# ip route 0.0.0.0 0.0.0.0 192.168.1.5 # ip route 192.168.0.0 255.255.255.0 192.168.2.5 # show ip route 192.168.0.1
RIPv2
# conf t # router rip # version 2 # no auto-summary # network 192.168.1.0 # network 192.168.3.0
Router on a Stick, sub-interfaces
On the switch, configure the link to router as trunk# switchport trunk encapsulation dot1q # switch mode trunk # show interfaces trunkOn the router interface, remove IP on the main interface
# int fa0/0 # no ip address # int fa0/0.2 # encapsulation dot1Q 2 # ip address 192.168.1.1 255.255.255.0 # int fa0/0.4 # encapsulation dot1Q 4 # ip address 192.168.3.1 255.255.255.0 # show ip route
udevinfo
udevinfo -q env -n /dev/sdc
udevinfo -a -p /sys/class/net/eth2
udevinfo -a -p $(udevinfo -q path -n /dev/sdc)Test udev rules
# udevtest /block/sdc udevadm test /block/sdc # udevcontrol reload_rules
Fedora 18 XFCE 4.10 Experience
I think the XFCE 4.10 in Fedora 18 fixed a couple of things
- Audio Mixer is now similar to old one (from Gnome).
- Folder/file browser is faster than before, but there is still a bit lag when I double click it. I have i7 2600K, so there should be no lag.
setpci to disable usb3 ports on TUSB7320
# setpci -d 104c:8241 e0.L 00000000 # setpci -d 104c:8241 e0.L=0300 # setpci -d 104c:8241 e0.L 00000300
read/write eeprom
# $1 = offset readEEPROM() { setpci -d $DEVICE b1.b=$1 setpci -d $DEVICE b2.b=a1 setpci -d $DEVICE b0.b } # $1 = offset $2 = value writeEEPROM() { setpci -d $DEVICE b0.b=$2 setpci -d $DEVICE b1.b=$1 setpci -d $DEVICE b2.b=a0 }
Emacs 24 kill-region and yank
To restore the old kill-region and yank behaviour, add the following to .emacs:
(setq x-select-enable-clipboard nil) (setq x-select-enable-primary t) (setq mouse-drag-copy-region t) (setq select-active-regions nil) (global-set-key [mouse-2] 'mouse-yank-at-click)
Emacs-24 Space bar () complete file
This was changed to allow entering file name with space without quote. The old behaviour can be restored with
class="lisp">(define-key minibuffer-local-filename-completion-map (kbd "SPC") 'minibuffer-complete-word) (define-key minibuffer-local-must-match-filename-map (kbd "SPC") 'minibuffer-complete-word)
gpg hangs
I am not sure why it hangs, since I have a lot of entropy.
The solution worked for me is "Ctrl-z" then type "fg". I do not know why suspend then restart it would make a difference. This is on Centos 5.
This is a workaround rather than a permanent fix.
using strace on it also wakes it up.
$ cat /proc/sys/kernel/random/entropy_avail 4096
The solution worked for me is "Ctrl-z" then type "fg". I do not know why suspend then restart it would make a difference. This is on Centos 5.
This is a workaround rather than a permanent fix.
using strace on it also wakes it up.
Subscribe to:
Posts (Atom)