In this case im using a ssd drive named /dev/sdb with filesystem formatted to ext4, it is know that ssd has a limited writes cycles eventually wears off overtime compared to normal HDD but ssd has a greater speed advantage compared to hdd drives.
Checking ssd current state with smartctl.
ssd is dected as sdb on my system.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465.8G 0 disk └─sda1 8:1 0 465.8G 0 part /media/dancers sdb 8:16 0 111.8G 0 disk ├─sdb1 8:17 0 100G 0 part /home ├─sdb2 8:18 0 1.8G 0 part [SWAP] └─sdb3 8:19 0 10G 0 part /
root ~ smartctl -data -A /dev/sdb smartctl 6.6 2017-11-05 r4594 [x86_64-linux-4.19.4-200.fc28.x86_64] (local build) Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org === START OF READ SMART DATA SECTION === SMART Attributes Data Structure revision number: 1 Vendor Specific SMART Attributes with Thresholds: ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE 5 Reallocated_Sector_Ct 0x0032 100 100 000 Old_age Always - 0 9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 96 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 64 165 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 191 166 Unknown_Attribute 0x0032 100 100 --- Old_age Always - 4 167 Unknown_Attribute 0x0032 100 100 --- Old_age Always - 0 168 Unknown_Attribute 0x0032 100 100 --- Old_age Always - 7 169 Unknown_Attribute 0x0032 100 100 --- Old_age Always - 103 170 Unknown_Attribute 0x0032 100 100 --- Old_age Always - 0 171 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 0 172 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 0 173 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 4 174 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 24 184 End-to-End_Error 0x0032 100 100 --- Old_age Always - 0 187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0 188 Command_Timeout 0x0032 100 100 --- Old_age Always - 0 194 Temperature_Celsius 0x0022 065 052 000 Old_age Always - 35 (Min/Max 20/52) 199 UDMA_CRC_Error_Count 0x0032 100 100 --- Old_age Always - 0 230 Unknown_SSD_Attribute 0x0032 100 100 000 Old_age Always - 231933476918 232 Available_Reservd_Space 0x0033 100 100 005 Pre-fail Always - 100 233 Media_Wearout_Indicator 0x0032 100 100 --- Old_age Always - 449 234 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 1064 241 Total_LBAs_Written 0x0030 100 100 000 Old_age Offline - 418 242 Total_LBAs_Read 0x0030 100 100 000 Old_age Offline - 88 244 Unknown_Attribute 0x0032 000 100 --- Old_age Always - 0
Look out for Media_Wearout_Indicator to see the how heatlhy is the drive, in this case it is 100 so need to worry for now may me value will deteriorate over the time , vlaue of below 10 should be when we should to considering to replace the drive.
To decrease no of writes to the disk we can use the nomount flag to fstab , this would elimate writing time stamps to disk for read files on disk.
here is the fstab settings
root ~ cat /etc/fstab # # /etc/fstab # Created by anaconda on Thu Nov 29 15:03:35 2018 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=8ab5debd-b855-4bef-a242-5f8c77eaa0ef / ext4 noatime,discard,errors=remount-ro 1 1 UUID=53c920b5-76fc-494e-8960-7db73e090af2 /home ext4 defaults 1 2 UUID=ed7c65c3-2d8d-45de-8a70-0ed1122f16eb swap swap defaults 0 0 UUID=e4043faf-1a0d-4f87-968f-d0ba1acb9457 /media/dancers ext4 defaults 0 0
Temporary filesystem /tmp can be mounted to decrease writes on hdd this can be done with the below entries in fstab.
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0 tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0 tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0
Tweaking swappiness value
By default in linu< swappiness value is set to 60 which means that start using swap after 60% of ram is used, if we have enough ram on the system then we can reduce the amount of swap usage by chaning vm.swappiness value.
for better performance on my laptop i will be going with swappiness value of 10.
Setting swappiness.
1. sysctl -w vm.swappiness=10 or 2. Edit /etc/sysctl.conf and add vm.swappiness=10 or #echo 10 > /proc/sys/vm/swappiness #root ~ sysctl -p vm.swappiness = 10 kernel.sysrq = 1 vm.swappiness = 10 vm.vfs_cache_pressure = 50 vm.overcommit_memory = 1Setting i/o scheduler to deadline For running host as a kvm-host server we will use deadline i/o scheduler#echo 'deadline' > /sys/block/sda/queue/scheduler To make changes persistent, to load at boot time add elevator=deadline to grub configuration. # root ~ cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="resume=UUID=ed7c65c3-2d8d-45de-8a70-0ed1122f16eb video=SVIDEO-1:d rhgb quiet console=tty0 console=ttyS0,115200n8 elevator=deadline transparent_hugepage=never" GRUB_DISABLE_RECOVERY="true" GRUB_BACKGROUND="/boot/grub2/themes/linux.jpg" GRUB_GFXMODE="800x600" GRUB_SERIAL_COMMAND="serial --speed=9600 --unit=0 --word=8 --parity=no --stop=1" export GRUB_COLOR_NORMAL="white/black" export GRUB_COLOR_HIGHLIGHT="yellow/red" Generating grub file from command line root ~ grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.19.4-200.fc28.x86_64 Found initrd image: /boot/initramfs-4.19.4-200.fc28.x86_64.img Found linux image: /boot/vmlinuz-4.16.3-301.fc28.x86_64 Found initrd image: /boot/initramfs-4.16.3-301.fc28.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-e4fc1c10a0464289bef888c478eb8356 Found initrd image: /boot/initramfs-0-rescue-e4fc1c10a0464289bef888c478eb8356.img doneroot ~ cat /sys/block/sda/queue/scheduler noop [deadline] cfq