Monday, February 29, 2016

OS optimization to Run on Flash Card

1.   Disable Access Time Attributes & changing journaling method parameter for the disk Access


A) Each time a file is accessed OS updates its access time parameter by writing to disk
To prevent this we have to use noatime parameter during filesystem mounting in fstab.
 
Also to reduce write cycle, use data=writeback ensure data less frequently written.(might have consequences in previous data appearing on crash).
 
        LABEL=/ / ext3 defaults,noatime,nodiratime,data=writeback  1 1

B) Then run following command before rebooting to make change journaling type. This is necessary otherwise system won’t start.
        tune2fs -o journal_data_writeback /dev/hda1
(assuming hda1 is /)
C) see whether it has changed or not using 
        tune2fs -l /dev/hda1 | more
(assuming hda1 is /)
 
Data=journal is advisable to robust filesystem, tune2fs -o journal_data /dev/hda1
 
 
 
Recover Linux if it doesnt boot
1.Linux rescue
2.chroot /mnt/sysimage
3.vi /mnt/sysimage/etc/fstab then change any
 

2.   Increasing writeback timings for the disk disk


In /etc/rc.local
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs

other two option not sure has to be added or not
echo 20 > /proc/sys/vm/dirty_ratio
echo 10 > /proc/sys/vm/dirty_background_ratio
 
 

3.   Disable Swap

disable swap (remove swap volume from /etc/fstab)

or in /etc/rc.sysinit add following line
swapoff  /dev/swap_partition
 

4.   Put frequenting access temporary areas in Ram

/etc/fstab

tmpfs      /var/log        tmpfs        defaults,noatime           0    0
tmpfs      /tmp            tmpfs        defaults,noatime           0    0
tmpfs      /var/tmp        tmpfs        defaults,noatime           0    0 
(PS: It might be a good idea to have a swap partition when using tmpfs.)
Ramfs only uses ram space and has to provide limit otherwise will grow dynamically
Tmpfs uses swap space so it will write to disk.


5.   Change the IO-Scheduler for Flash Drive

Usually Linux uses I/O schedulers that assists read and writes to happen in a sequential matter, however flash based drives are much simpler than traditional hard drives and have no seek penalty. For that reason "noop" is much better suited for flash-drives since it just pushes things forward in the order data come in (FIFO).

Edit the /etc/grub.conf file. Add “elevator=noop” to the kernel line.
  1. kernel /vmlinuz-2.6.27.5-117.fc10.i686 ro root=/dev/sda2 rhgb quiet elevator=noop
(or to change on fly  # echo "noop" > /sys/block/sda/queue/scheduler)


ToD0:
1. Find list of var files that need to put to Ramdisk
2. Find how much will each require space
3. Script to delete files after exceeding limits.


No comments:

Post a Comment

Featured Post

XDP - Getting Started with XDP (Linux)