Installing on SSD: moving /tmp and /var into tmpfs in RAM memory

I’m trying to optimize the file structure for my SSD. Current fstab is,

UUID=4af029ee-9a7e-4e42-b1d9-99b0d4c34846 swap swap defaults 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 / btrfs noatime,defaults 0 0
UUID=fc2ca443-0bcb-4f3e-bfdd-719b6ffa5ecf /home ext4 noatime,defaults 1 2

#UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /tmp btrfs subvol=@/tmp 0 0
#UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/spool btrfs subvol=@/var/spool 0 0
#UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/tmp btrfs subvol=@/var/tmp 0 0
#UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/log btrfs subvol=@/var/log 0 0

tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/spool tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=1777 0 0

UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /boot/grub2/i386-pc btrfs subvol=@/boot/grub2/i386-pc 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /boot/grub2/x86_64-efi btrfs subvol=@/boot/grub2/x86_64-efi 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /opt btrfs subvol=@/opt 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /srv btrfs subvol=@/srv 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /usr/local btrfs subvol=@/usr/local 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/cache btrfs subvol=@/var/cache 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/crash btrfs subvol=@/var/crash 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/lib/libvirt/images btrfs subvol=@/var/lib/libvirt/images 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/lib/machines btrfs subvol=@/var/lib/machines 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/lib/mailman btrfs subvol=@/var/lib/mailman 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/lib/mariadb btrfs subvol=@/var/lib/mariadb 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/lib/mysql btrfs subvol=@/var/lib/mysql 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/lib/named btrfs subvol=@/var/lib/named 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/lib/pgsql btrfs subvol=@/var/lib/pgsql 0 0
UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/opt btrfs subvol=@/var/opt 0 0

**Question one: Should I change
“UUID=3c4938af-c70d-42a9-abb3-91bced2eecc6 /var/lib/libvirt/images btrfs subvol=@/var/lib/libvirt/images 0 0”
and the other /var files to
“tmpfs /var//lib/libvirt/images tmpfs defaults,noatime,mode=1777 0 0” ?
**
Question two:
I’ve added the following to my /etc/rc.d/boot.local file to create a filestructure in /var for /log,
for dir in apparmor apt cups dist-upgrade fsck gdm installer samba unattended-upgrades ;
do
if ! -e /var/log/$dir ] ; then
mkdir /var/log/$dir
fi
done
Should I be doing this for /spool and /tmp as well? What about the other directories mentioned in Question one? Is this necessary?

**Question three: **How are most people configing this on their SSDs? TIA

Fantastic btrfs incest mode
I use ext4 for everything
I mounted / (root)> / home> / boot on ssd
Bios > SATA configuration: AHCI.

UUID=21f4840c-ff3d-48f0-a36a-5578ce6041c1 /                    ext4       acl,user_xattr,noatime,discard        1 1
UUID=4a79e528-7bbb-4357-ac42-c6b1b4796448 /archivio            ext4       defaults              1 2
UUID=2568bd9d-67b8-4cc3-9c61-6230b0b2d5a1 /boot                ext4       acl,user_xattr,noatime,discard        1 2
UUID=42b49c5f-a050-4506-b9b5-7b66fa9c071c /home                ext4       acl,user_xattr,noatime,discard        1 2
UUID=da51f0b3-b149-423f-a6a8-0556e79dc257 /tmp                 ext4       acl,user_xattr        1 2
UUID=3216c0a4-023c-4f56-8298-31f4e39c5ac3 /var                 ext4       acl,user_xattr        1 2

Hi
Don’t bother, new SSD’s handle many writes and reads, 20GiB plus a day, far more than can be expected for normal use… What brand/model of SSD

If you want to go that route, then consider a re-install and select expert partitioner mode, then here you can configure the mount points and exclude directories if using btrfs.

The system already optimizes for an SSD device, fstrim etc. They only thing I do is configure swap to reduce it’s swappiness…

Hi
A word to the wise, you have your opinion, just like everyone else, we can all argue to the cows come home about the features etc of whichever filesystem, Desktop etc is better or not. If you want to make a change to the defaults, the forum here is not the place, either the Factory mailing list or a feature request and get some traction to changing it.

If wanting to help, then I suggest to keep things on a technical level (we have chat and soapbox) and guide/help the user with their specific issue if you can. Thanks :wink:

Thanks Malcolm. I’ve been using Samsung SSDs, both 250gb, one is an 840 the other is an 850. The 840 I’ve been using daily since 2013 and was starting to develop weird issues, (freezing, garbled text) that I’d attributed to my getting lazy in recent years and just installing the stock openSuse with no special tweaks for SSDs, (no swappiness adjusting, no tmpfs, etc). I’d figured that the openSuse developer lords had incorporated SSD adjustments (fstrim, etc) as standard in the stock distros, but had not seen mention of these changes anywhere. My recent problems w/the Samsung 840 had made me question this assumption.

Thanks for the response.

Hi
Ahh Samsung… they have been known to be quirky, if you test them with fstrim from the command line, it may still be blacklisted (840’s perhaps);

Just check with;


fstrim --verbose --all

Is the firmware on the SSD’s all up to date?

This thread maybe of interest about fstrim: https://forums.opensuse.org/showthread.php/525998-Btrfs-Root-ran-out-of-space-via-this-forum-i-fixed-it-are-my-settings-ok-pls?highlight=fstrim

Samsung 850 EVO and Pro work just fine.

Firmware on both is up to date. From what you have said, I gather that you are of the opinion that it is not needed to establish /tmp and /var in RAM via tmpfs? Correct? Thanks for the useful and thoughtful responses.

Hi
I have never worry about it these days, but that’s just me :wink:

I have five laptops here with various OCZ’s, a Crucial and a SanDisk SSD(s). When using ext4 on my oldest one (OCZ Agility 60GB) a number of years ago I did a few extra tweaks, but now just run the defaults, on average my systems are writing 6~7GB to the SSD a day, well below the manufacturers specs… the one above is at 38,770 power on hours and SSD_LIfe_Left is at 99% (has been like that for awhile)… There has been some discussion on the forum about the btrfs defaults, but I don’t see any indication of any of my SSD’s failing in the near future…

Here is an example of the garbled text that I am getting from the Samsung 840 drive,


I’ve moved the drive to machines with similar hardware configs, and have totally wiped the drive using the Samsung bootable exe available from Samsung Magician and then totally openSuse 42.3 with standard SSD optimizations…still I get freeze-ups and this weird malformed text. Note that all of the capital "D"s and lower case"p"s are affected. This machine with the Samsung 850 installed runs fine. I think the drive is toast even though SMART drive calls it “good”. Go figure. Anyone here ever seen this before?

Hi
Can you repost your image at say paste.opensuse.org (set to never expire)…

Is the SSD still under warranty? How many power on hours?

Here’s the image on paste.opensuse.org,
SUSE Paste

Warranty on the 840 is only 3 yrs, Samsung Magician (on the WinOS partition) says 4.2 tb written. Not sure how to get total power-on hours. I have done a total erase and reformat, so these metrics may no longer be available.

Hi
As root user run;


smartctl -a /dev/sda

No need to re-install.
Just open up YaST > Partitioner and re-define whatever mount points you wish to change.

To the @OP,

  1. Be aware that when doing a web browser download and possibly other types of downloads (except torrent), as your file downloads a temporary file is created in /tmp and when completed only then is moved to a destination (typically &USER/Downloads). This means that if you place /tmp in RAM, you need that much RAM… to accommodate all your running processes <and> the possibly massive file(s) if for instance you’re downloading DVD ISOs.

So, unless you’re able to re-direct various application behaviors, it’s generally not advisable to mount /tmp in RAM.
It should be enough that SSD read performance is generally pretty darn fast (writes can be slow, but is typically not that critical particularly if write-backs are implemented which is often the case).

  1. If you’re chasing performance, one of the first references you should visit is the ArchWiki
    Solid state drive - ArchWiki
    And, it seems that a brand new, excellent article for optimization was just created days ago…
    Improving performance - ArchWiki

TSU

Hi
A word of caution when using other distro HowTos… a lot on the second link is already done in openSUSE OTB with scheduler udev rules etc (openSUSE recommend deadline for SSD’s which they even dispute in the article saying to use deadline and not noop), so verify first by checking the parameters listed. If not sure post away in the forum :wink:

You could also use a tmpfiles.d snippet for this instead of such a script.

See “man tmpfiles.d”.

On Sun 20 Aug 2017 08:36:01 PM CDT, malcolmlewis wrote:

V_idocq;2834968 Wrote:
> Fantastic btrfs incest mode
Hi
A word to the wise, you have your opinion, just like everyone else, we
can all argue to the cows come home about the features etc of whichever
filesystem, Desktop etc is better or not. If you want to make a change
to the defaults, the forum here is not the place, either the Factory
mailing list or a feature request and get some traction to changing it.

If wanting to help, then I suggest to keep things on a technical level
(we have chat and soapbox) and guide/help the user with their specific
issue if you can. Thanks :wink:

Hi All
So a clarification to the word used, since user V_idocq uses google
translate as English is not the first language…

The word in Italian was “incasinato”, the way I see it is the sentence should have been;

“Fantastic btrfs messed up mode”

But again the point still stands that technical help is the primary
purpose in these forums, opinions etc in the other forum areas :wink:


Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
openSUSE Leap 42.2|GNOME 3.20.2|4.4.79-18.26-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

Power on hours = 11225
Total LBAs Written = 8939491026
POR Recovery Count = 245
CRC Error count = 1

Thoughts on this?

Hi
POR is related to sudden power off and recovery… so it has to rebuild the data etc… so it’s done that 245 times, maybe a bit excessive?

Ref: http://www.samsung.com/semiconductor/minisite/ssd/downloads/document/SSD_Application_Note_SMART_final.pdf

Maybe other users have seen that corruption, I haven’t…

Hmmmm…not sure about the 245 sudden power-offs. That does seem a bit high…however, I started using this drive in late December 2013…that’s approximately 180 weeks. That’s more than 1 sudden power-off per week. That does seem high. I do have VMWare Workstation installed on this SSD. The virtual hard drives are kept on a spinning HD.