How To Make Debian/Linux SSD friendly

I am moving operating systems to SSD but keep all data on normal disk drives for obvious reasons.
So basically only operating systems and applications are on SSD.

The question is what should be done top the OS filesystem to make it SSD friendly.
The servers has up to 512GB of memory, so swap is not necessary unless applications relies explicitly on physical swap space. I think jackd does.

  1. So I need mount swap to physical memory (for jackd etc). Seems stupid but it is seemingly needed and swapfile cannot be just ignored for some applications.
  2. Probably need to mount /var/log/messages to memory.

What else is very intensive in the OS directory tree I need to mount to memory at boot ?

Then during logout I need to dump the contents of /var/log back to disk if I need persistent logs. That is straightforward to do.

1 Like

Debian Linux kernel will do this for you automatically at boot time. Just install Debian Linux on your SSD and set that drive as a boot drive. Next, you need to create a partition for the secondary disk at, say, /disk1/ or /data/ and store all data on it. There is no need to tweak or do anything on your part for SSD. Is there any specific issue are you facing?

AFAIK this ain’t specific to Debian but the filesystem driver and in some ways the kernel.

Swapping ain’t as intensive as you claim, and normally a Linux doesn’t swap a whole lot. You could drop the swappiness value to make sure it’s used as little as possible by the OS: Linux Add a Swap File Tutorial - nixCraft

Thanks Nixcraft.
I did not know about the automatic process. That is news to me.
Very nice thank you and will be helpful for new installs.

However, I dd the boot disk image over from the hard drive to the SSD, so there is no chance (I think) for Debian) to figure it is an SSD.

So I have two options,

  1. do a very minimal reinstall of only kernel and such after dd and not break my current install.
  2. I need to do it by hand.

Currently it is not viable to do a complete reinstall on SSD and rebuild the installation.

What do you suggest? Is there an easy way to do 1) above and let the minimal reinstall on the SSD trigger Debian to set it up as an SSD, or can it be done after a DD ?

The option (2) is much safer and useful currently I guess, as I can script the mounts needed and only need to know exactly which directories needs to be mounted in ram.

Or I can install new on SSD and then copy over the necessary folders to the new install. This can be tricky and break things and is generally not advised.

1 Like

AFAIK you’ll just need to add discard to the SSD’s fstab mount settings, everything else is automatic on boot.

Some recommend using cron to schedule the TRIMming, though.

Ok I changed my fstab entry for / to
/sda2 / ext4 noatime, discard 1 1
, but upon reboot it dumps me into intramfs.
Doesnt like it it seems.

I did check that my SSD supports trim/discard, and it does using
lsblk --discard

I followed,

I dont know if “1 1” caused the intramfs, but if it was 01, then it would mean the filesystem must not be dumped, so I figured that is not correct for the SSD, so I used “1 1”
Without the discard option as mentioned above what I entered, it boots just fine with the “1 1” options.

You did it wrong: there can’t be a space in , discard.

Keep it 0 1 for the root device, use 0 2 for the 2nd, and so on. The 1st number is used by dump(8) (man 8 dump), but I haven’t researched how a filesystem dump works and why would you use it, but seems most ppl don’t need it.

Space there never made a difference for me in the past and I verified several times in the past it doesnt matter. I will however keep your warning in mind as it is more consistent.

However, the problem was solved with; changing 1 1 to 0 1, and it booted successfully.

I was under the impression (as I read last night) that the 1 1 option is obsolete and automatically is read as the default 0 1.
Apparently that is not the case, as setting it to 1 1 dumps me on intramfs while 0 1 doesnt and boots normally.

@retnev How did you installed Debian on SSD? Installer? Automated method?

As I mentioned in my second to original post, migration by dd.

I now want to implement moving directories to memory.

I followed this page, which was quite helpful.
This person set up his system as follows.

LABEL=SSDsuse121     /                    ext4 acl,noatime,nodiratime,discard   1 1
LABEL=SSDsuse121m    /suse121m            ext4 acl,noatime,nodiratime,discard   0 2
LABEL=SSDcommon      /common              ext4 acl,noatime,nodiratime,discard   0 2
LABEL=SSDsuse122m    /suse122m            ext4 acl,noatime,nodiratime,discard   0 2
LABEL=SSDgrub        /grub                ext4 noacl,noatime,nodiratime,discard 0 2
LABEL=SSDswap        swap                 swap defaults              0 0 proc
/proc                proc defaults              0 0 sysfs
/sys                 sysfs noauto               0 0 debugfs
/sys/kernel/debug    debugfs noauto             0 0 usbfs
/proc/bus/usb        usbfs noauto               0 0 devpts
/dev/pts             devpts mode=0620,gid=5     0 0 tmpfs
/ramdisk             tmpfs nodev,nosuid,noatime,mode=1777,size=100M 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  0paste code here

Note that he also used “1 1” for /.
As already mentioned , that created intramfs dump for me and “0 1” solved it.
What I dont agree with is with swapspace being on the SSD. That WILL kill it.
What I do is just to not have any swap at all and then deal with applications that physically need a swap partition by creating it in memory.
I generally prefer just to buy and install way-way more memory than I need, and just get rid of the swap partition. Memory ends up much cheaper in the long run than failing SSD’s. Difficult to sell a well used SSD and memory generally can increase in value in some cases. To me it is a no-brainer.

What he also did was to add nodiratime and acl. I did that and it works with those options.

My immediate question to both of you.
Do you agree with the directories he mounted in physical memory, that is all the entries below the LABEL entries.
Are there any more you want me to add, or for some reason keep on the SSD. ?

What I want to arrive at is that the system boots from the SSD, but then basically run in memory, and applications are loaded from the SSD, and nothing else.
Should last way longer and give me max benefits.

After all this is done, and I find any application that uses a root access cache in its directory or such, and it becomes obvious it is a busy process, then I can always move it to memory.
So I will have to monitor all SSD activity continuously and set traps.