sexta-feira, 19 de setembro de 2008

Sort by field

/tmp/input:

192.168.1.100
192.168.1.19
192.168.1.102
192.168.2.1
192.168.0.2

# sort -t . -k 3,3n -k 4,4n /tmp/input

-t . : Set field to . (dot) as our IPs separated by dot symbol
-n : Makes the program sort according to numerical value
-k opts: Sort data / fields using the given column number. For example, the option -k 2 made the program sort using the second column of data. The option -k 3,3n -k 4,4n sorts each column. First it will sort 3rd column and then 4th column.

Output:

192.168.0.2
192.168.1.19
192.168.1.100
192.168.1.102
192.168.2.1

Referência

quarta-feira, 10 de setembro de 2008

Summer 2008

# cat << EOF > /usr/share/zoneinfo/Brazil/summer2008.zic
Rule Brazil 2008 only - Oct 19 00:00 1 S
Rule Brazil 2009 only - Feb 15 00:00 0 -

Zone Brazil/East -3:00 Brazil BR%sT
EOF

# zic /usr/share/zoneinfo/Brazil/summer2008.zic

# cat /etc/localtime > /etc/localtime.copy && \
ln -s /usr/share/zoneinfo/Brazil/East /etc/localtime

XFS

# mkfs.xfs -d agcount=4 -l size=32m /dev/[DEVICE]

Mount options: noatime,nodiratime,logbufs=8

Check fragmentation factor:

# xfs_db -r /dev/[DEVICE]

# xfs_db> frag & hit enter

If you need to defrag your hard drive:

# xfs_fsr -v /dev/[DEVICE]

terça-feira, 2 de setembro de 2008

ext3 tuning

1) Directory indexing

# tune2fs -O dir_index /dev/hdXY
# e2fsck -D /dev/hdXY

2) Journal mode

# tune2fs -O has_journal -o journal_data /dev/hdXY

3) Mount options

# mount -o nodiratime,noatime,data=journal /dev/hdXY /your_mount_point

Referências:

Advanced filesystem implementor's guide, Part 8

Ext3 tuning

Drunk Penguins

Drunk Penguins
Drunk Penguins