Linux - System Admin

From wiki.openedev
Jump to: navigation, search

Grep and Replace[edit]

  • Search and replace the exact word
 bash> grep -rl -w 'CONFIG_SPI_FLASH' configs/ | xargs sed -i 
       's/\<CONFIG_SPI_FLASH\>/CONFIG_MTD_SPI_NOR/g'
 Output:
 -CONFIG_SPI_FLASH=y
 +CONFIG_MTD_SPI_NOR=y
  • Search and replace the exact word with two word b/w line
 bash> grep -rl -w 'CONFIG_SPI_FLASH' configs/ | xargs sed -i
       's/<CONFIG_SPI_FLASH\>/CONFIG_MTD_SPI_NOR=y\nCONFIG_M25P80/g'
 Output:
 -CONFIG_SPI_FLASH=y
 +CONFIG_MTD_SPI_NOR=y
 +CONFIG_MTD_M25P80=y

Disk Performance[edit]

Linux provides variety of tools/commands that can easily handful to perform disk performance, but be careful while using because commands gives different results based on input from the user. The main fundamental about disk performance unlike character devices disk devices are block-oriented they have a concept called disk IO, cache IO so end results might vary based on these.

Don't worry below example are very straight forward - just use it based on your need.

Target details:

  • RAM Size: 8GB
  • Disk Block Size: 4096 (mkfs.ext4 -b 4096, to know disk block size tune2fs -l /dev/sda1)
  • File size: 16GB (Always take 2 * RAM size to avoid cache)

Note: Usually disk are formatted with block size which is of kernel PAGESIZE.

dd[edit]

  • sequential write
[root@ ~]$ mount
/dev/sda1 on /mnt type ext4 (rw,relatime,data=ordered)
[root@ mnt]$ dd if=/dev/zero of=32GB.dd bs=4096 count=8M conv=fdatasync                                                  
8388608+0 records in
8388608+0 records out
34359738368 bytes (34 GB) copied, 330.587 s, 104 MB/s
  • sequential read
[root@ mnt]# dd if=32GB.dd of=/dev/null bs=4096 count=8M
8388608+0 records in
8388608+0 records out
34359738368 bytes (34 GB) copied, 64.7675 s, 531 MB/s

xdd[edit]

hdparm[edit]

IOzone[edit]

IOzone is a filesystem benchmark tool. Unlike dd, we can do different types of read and writes using IOzone.

[[email protected] mnt]# iozone -i 0 -f iozone.test -r 64K -s 32G
Record Size 64 KB
File size set to 33554432 KB
Command line used: iozone -f iozone.test -r 64K -s 32G
Output is in Kbytes/sec
Time Resolution = 0.000001 seconds.
Processor cache size set to 1024 Kbytes.
Processor cache line size set to 32 bytes.
File stride size set to 17 * record size.
      KB  reclen  write   rewrite read   reread read   
33554432      64  218423  223738  505433 498893 192953
[[email protected] mnt]# iozone -i 1 -f iozone.test -r 64K -s 32G
Record Size 64 KB
File size set to 33554432 KB
Command line used: iozone -f iozone.test -r 64K -s 32G
Output is in Kbytes/sec
Time Resolution = 0.000001 seconds.
Processor cache size set to 1024 Kbytes.
Processor cache line size set to 32 bytes.
File stride size set to 17 * record size.
      KB  reclen  write   rewrite read   reread   
33554432      64                  505433 498893
  • Using -i option we can specify the write/read tests, see man iozone.
  • -s is for file size
  • -r is for record size (iozone breaking up a file of a given size into records, each record is of size specified with -r so test's are reading/writing in the form of records)

Note: IOzone output is stdout'ed as KB/s.

IOMeter[edit]

NAS Performance[edit]

Setup[edit]

Robocopy[edit]

Robust File Copy - One of the useful windows copy tool for heavy-duty file management like disk and network I/O's

IOZone[edit]

IOMeter[edit]