Help with ssd

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Domaiv

Help with ssd

Post by Domaiv »

I have decided to try out Linux,as I have just got a 60gb ssd. Windows takes up far too much space and I want to get the most out of my disk.

Because Linux is new to me every page I look at when trying to find info on the best settings to use with an ssd might as well be written in clingon. This might seem like I am trying to run before I can walk, but I would like to set the os that it reduces the amount of writes on the disk.

Could anyone point to a tutorial that can be understood by a mint virgin. I would like to set up a ramdisk for all cache and temp files. It would also be handy to know if I really need a swap partition, and if not how to get rid of it.

Thanks from a confused newbie.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29501
Joined: Wed Jul 06, 2011 3:58 am

Re: Help with ssd

Post by xenopeek »

Update 2: below I share how to enable TRIM for your SSD with the discard keyword. For some specific SSD models this may in fact cause file deletions you do to take more time than without the discard keyword. If that is the case for your SSD, here is the alternative of enabling TRIM with the fstrim command run once daily through cron: http://www.webupd8.org/2013/01/enable-t ... rives.html

Update: if you are using the MATE desktop, replace the editor "gedit" in below commands with "pluma". Or for KDE replace it with "kate.

Hi, first off, it is Klingon. You don't want to get caught by these guys misspelling their language :wink:

As for swap, that depends on how much main memory your machine has. (You can see this in Menu -> Control Center -> System Profiler and Benchmark, then under Devices click Memory and look at Total Memory--roughly devide by 1,000,000 to get to how much GB that is.) If you have 1GB or less, you really need swap. If you have around 2GB it depends on what you use your machine for (Internet and Office will run fine without swap, but if you do movie editing, rendering, DAW or such things you need swap). At 4GB or over you don't really need swap, I run without it. If however you want to hibernate your machine, you need swap at least equal to how much main memory your machine has.

On to optimizing for SSD. For this you need to open Terminal (find it in Menu). Normally the system is optimized to work with a normal harddisk, but this is actually all overhead for a SSD that is slowing the system down.To fix this, in Terminal type:

Code: Select all

gksudo gedit /etc/default/grub
Enter your password when asked, and then change the line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
To:

Code: Select all

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=noop"
Save & close the file. Then do the following to activate the changes from next reboot:

Code: Select all

sudo update-grub2
Next up, you need to find out if your SSD supports TRIM. Just copy & paste the following command string to the Terminal and execute it. When asked type your password (nothing will seem to happen as you type, this is normal):

Code: Select all

for h in /dev/sd?; do if [ `sudo hdparm -I $h | grep TRIM | wc -l` != 0 ]; then sudo hdparm -I $h | egrep "/dev/|Model"; fi; done
Did it list your SSD? Then it supports TRIM, if it didn't show anything your SSD doesn't support TRIM. Remember that, and continue with:

Code: Select all

gksudo gedit /etc/fstab
First the easy part, at the end of this file add the following line. These change it so temporary files are stored in memory instead of on your SSD.

Code: Select all

none /tmp     tmpfs nodev,nosuid,mode=1777 0 0
Now for the hard part. Probably you have a line like something like the following in your file:
UUID=0c4de1f6-b77b-49d7-bccf-63c4268e8f43 / ext4 errors=remount-ro 0 1
You need to change the:
errors=remount-ro
To read (this disables writing to disk each time a file is read):

Code: Select all

errors=remount-ro,noatime
And if your SSD supported TRIM, instead change it to (this does the same as above, but enables TRIM use on your SSD):

Code: Select all

errors=remount-ro,noatime,discard
Finally, save & close this file. Then run the following two commands. This will reboot your system to activate all changes.

Code: Select all

sudo rm -rf /tmp/*
sudo reboot
After the rebot, you'll want to start Firefox, type in the address bar:

Code: Select all

about:config
And hit enter. Accept the warning and continue. Right click on an empty part, and select New -> String from the context menu that popped up. Enter:

Code: Select all

browser.cache.disk.parent_directory
And give it the value:

Code: Select all

/tmp
This makes the Firefox cache also be stored in memory instead of on disk. If you have 2GB or less, you might not want to do this though.

Edit: some questions answered about mounting options and scheduler, here http://forums.linuxmint.com/viewtopic.p ... 0&p=578163.
Image
Domaiv

Re: Help with ssd

Post by Domaiv »

You learn something new everyday. I learned the correct spelling of Klingon (is it considered a weakness to ask for forgiveness for my mistake?)

That all seems to have worked. Thank you for your time and help.

I also managed to turn off swap and delete the partition. Now to reallocating that free space.

QA TLHO'
User avatar
xenopeek
Level 25
Level 25
Posts: 29501
Joined: Wed Jul 06, 2011 3:58 am

Re: Help with ssd

Post by xenopeek »

buy' ngop
majQa'

Brilliant signature BTW :wink:
Image
Domaiv

Re: Help with ssd [SOLVED]

Post by Domaiv »

I'm sure your instructions will be used by many as ssd's become more popular
Domaiv

Re: Help with ssd

Post by Domaiv »

My temp files are still going to file "system/tmp"


After the first command change I get this message in the terminal:
(gedit:4862): Gtk-WARNING **: Attempting to set the permissions of `/root/.local/share/recently-used.xbel', but failed: No such file or directory
User avatar
xenopeek
Level 25
Level 25
Posts: 29501
Joined: Wed Jul 06, 2011 3:58 am

Re: Help with ssd

Post by xenopeek »

(gedit:4862): Gtk-WARNING **: Attempting to set the permissions of `/root/.local/share/recently-used.xbel', but failed: No such file or directory
You can ignore that. Gedit keeps a list of recently used files, and as you are executing commands as root it tries to update also for the root user the list of recently used files. On default install the folder /root/.local/share doesn't exist. No harm in this. But if you want to not see these errors, run:

Code: Select all

sudo mkdir -p /root/.local/share
And files will continue to go to /tmp folder, but having done all the commands I gave you the /tmp folder is no longer on your disk but is in memory. That is what the line:
none /tmp tmpfs nodev,nosuid,mode=1777 0 0
Added to /etc/fstab file does. It makes a new temporary filesystem in memory (type=tmpfs). If you doubt if it is active, after reboot on the changes do:

Code: Select all

cat /etc/mtab
Or:

Code: Select all

mount
That lists all the active filesystem mounts, and should now have a line added for /tmp as tmpfs.
Image
Domaiv

Re: Help with ssd

Post by Domaiv »

I think I understand. /tmp shows the temp files on the ssd and ram.

I think the hardest part of this is going to be forgeting about windows after 20 years of using it.
Eucalyptus

Re: Help with ssd

Post by Eucalyptus »

xenopeek wrote:First the easy part, at the end of this file add the following two lines. These change it so temporary files are stored in memory instead of on your SSD.

Code: Select all

none /tmp     tmpfs nodev,nosuid,mode=1777 0 0
none /var/tmp tmpfs nodev,nosuid,mode=1777 0 0
Hi Vincent,
I hope you won't mind if I resuscitate this post. Can you please clarify about the using the RAM for tmpfs?

On a machine having 4GB RAM and using LM13 64 bits, would there be any chance that tmpfs runs out of memory? The typical applications opened on this computer is Firefox (10 tabs in general), Virtualbox (the VM is allocated 800 MB), evince PDF Viewer, burning DVD from time to time. System monitor shows RAM usage between 1.4 to 2.0 GB.

Let's assume tmpfs doesn't have enough RAM, would there be any visible sign or would the computer hang unexpectedly?

Thanks in advance
User avatar
xenopeek
Level 25
Level 25
Posts: 29501
Joined: Wed Jul 06, 2011 3:58 am

Re: Help with ssd

Post by xenopeek »

tmpfs mounts are by default set to half your memory size. In your case, each tmpfs mount will be 2 GiB it size. That is its virtual size, it only uses as much memory as the space that it actually needs. As happens with any mount that is filling up, you will receive a warning when it is close to running out of free space.

Usually your /tmp is not needing that much space and 2 GiB will be unlikely to be used. You can check how much is being used with the command:

Code: Select all

df
Sizes shown are in KiB.

If you want, you can configure your tmpfs mount to have a different size. You can do so with the "size" option, as for example to restrict it to 25% of memory:

Code: Select all

none /tmp     tmpfs nodev,nosuid,mode=1777,size=25% 0 0
Instead of percentages, you can also give it a specific amount of bytes. Or add the suffix k, m or g to make that KiB, MiB or GiB. More details available in the kernel documentation on tmpfs: https://www.kernel.org/doc/Documentatio ... /tmpfs.txt
Image
Eucalyptus

Re: Help with ssd

Post by Eucalyptus »

Hi,

It looks like 4GB RAM is not enough for LM13 x64. After half of a day, the machine experiences little strange behavior with Firefox 13. FF 13 is slow when the window is dragged around and has experiences a perceivable reduction of responsiveness. Clicking in a folder in the FF bookmark toolbar no longer unfold the content. After a reboot, all these issues disappear and reappear a few hours later.

May be this is a FF13 specific issue. What is strange is that when I comment out the two lines related to tmpfs in fstab, there is no issue. I am going to increase the RAM on that machine to 8GB and put back the 2 lines in fstab to see if that improves the situation.

EDIT: More info a month after increasing the RAM from 4GB to 8GB, the hang up issue of Firefox 13 had disappeared. I am certain that the RAM increase was the fix. During the 1st week after increasing RAM, I didn't change anything else in the computer and the issue was occurring on a daily basis when there were 4GB. I have also set the size of the RAM disk to 25% (therefore reserving 2GB on the total 8GB).
caerolle

Re: Help with ssd

Post by caerolle »

I used this post over the weekend to set up an SSD, worked really well! The main reason I am posting is to remind anyone else who uses this post that 'gedit' is the GNOME text editor. In MATE, this has been replaced as 'pluma', so you need to use pluma in place of gedit (or just open pluma and the file from the GUI). I can't remember what text edit is used in the other DEs (Cinnamon, Xfce, and so forth), but would need to use that in place of gedit. The rest of the stuff seemed pretty DE agnostic.

Thanks for the great post, Vincent!
catch22
Level 4
Level 4
Posts: 210
Joined: Mon Oct 01, 2012 7:50 am
Location: Belgium
Contact:

Re: Help with ssd

Post by catch22 »

xenopeek wrote:...

Code: Select all

for h in /dev/sd?; do if [ `sudo hdparm -I $h | grep TRIM | wc -l` != 0 ]; then sudo hdparm -I $h | egrep "/dev/|Model"; fi; done
Did it list your SSD? ...
Since it shows "/dev/sda" I suppose it does (?), but should I be careful about the "bad/missing" messages, or can I simply proceed?

Code: Select all

for h in /dev/sd?; do if [ `sudo hdparm -I $h | grep TRIM | wc -l` != 0 ]; then sudo hdparm -I $h | egrep "/dev/|Model"; fi; done
/dev/sda:
        Model Number:       OCZ-AGILITY3                            
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
User avatar
xenopeek
Level 25
Level 25
Posts: 29501
Joined: Wed Jul 06, 2011 3:58 am

Re: Help with ssd

Post by xenopeek »

Yes, the OCZ-AGILITY3 supports trim. I'm not sure about the errors, but at least be sure that the OCZ-AGILITY3 supports trim.
Image
pjorge1036

Re: Help with ssd

Post by pjorge1036 »

Thank you for this guide!
cool_thing76

Re: Help with ssd

Post by cool_thing76 »

Thank you for the nice SSD optimization guide.
User avatar
catweazel
Level 19
Level 19
Posts: 9763
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Help with ssd

Post by catweazel »

xenopeek wrote:below I share the old way of enabling TRIM for your SSD (with the discard keyword), but it seems these days that is better done as per this article: http://www.webupd8.org/2013/01/enable-t ... rives.html[/color]
Very interesting. If I get time at work this morning I'll do a bit of research on that to find out more. Thanks for the link.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
TheForumTroll

Re: Help with ssd

Post by TheForumTroll »

I was writing a guide to post on here but I didn't finish it (it's done more or less, I just wanted to add some benchmarks but never got around to run them). Feel free to have a look.
Locked

Return to “Beginner Questions”