/ on SSD, should I put /var on a HDD?

17,797

Solution 1

That's a bad idea. If you put the installed applications on the SSD you'll get a more stable operating system and better performance. You've got a 120GB SSD, so you should not hesitate to use it for your installed applications.

Your 750GB hard drive is certainly not there for nothing. Here is my suggestion for how to use the 750GB hard drive optimally. Install Ubuntu on your SSD, including your /home directory, everything goes on your SSD. Then use your 750GB hard drive as a data drive to store your personal files. No matter what happens to your operating system, your personal files will be protected and accessible on the 750GB hard drive. Even if your operating system becomes completely unusable or if you do a fresh install of Ubuntu, all of your personal files will still be there intact on the 750GB hard drive.

You don't need to worry about your 120GB SSD being too small. A 120GB SSD has more than enough space to install Ubuntu in this way. In fact even a 60GB partition has more than enough space for Ubuntu and a lot of installed applications.

On my Ubuntu there are a few files that I use regularly. In order to improve performance and open these files fast, I keep these files on my SSD too in my /home directory. I don't have many of these files, so my /home directory is quite small.

Solution 2

Ok, first, the answers I have seen do not address the 2 most important issues.

First, although I applaud your diving in and trying something, the reason you have run into problems is due to an incomplete understanding of the linux directory structure. Please confirm what follows before blindly following my advice as I am not a regular user of the *buntu flavors of linux, but...

Applications are not (in my experience) generally found in /var, (there are exceptions), most applications are found below the /usr directory, /var is (in ubuntu) used for server related files, logs and caches. also things which would be lost on reboot if stored in /tmp.

There is a tradeoff to be made. /var on a fast drive (such as an ssd) will improve system performance, but due to specifics of ssd drives, may reduce (somewhat) the life of the drive due to more frequent writes.

Nutshell, faster performance, /var on ssd, longer drive life, /var on your 750GB drive.

For reference, all of my system files (openSUSE 13.1) and the whole system directory structure (including /var) exist on a single 64GB ssd.

Karel's information about your data is a little misleading (I believe), in that your data and /home directory are closely tied. My suggestion, mount /home on a partition on the 750GB Drive. This will simplify file management in the long run.

My data and website are the only things not on the ssd, my data (/home, /srv/http are kept on separate drives to ease upgrades or moving to other distributions. (I have files in my /home directory that were created in 1998)

I will answer how to move /var in a post that follows

Solution 3

Me again, BTW I do agree w/ Karel that doing your base install to the ssd is the best option. I also recommend reading a few other tutorials before following my directions.

NOTE: it is much easier to configure your system during a fresh install,

Now if you do wish to create a new mount point for /var there are numerous things to consider.

Some directories will be harder to move because files may be in use, /var is one of these problem children. Anytime your system is active it is likely that data is being written to /var

Another consideration is maintaining the correct file attributes, copy will not do this without the proper flags.

these links could help get you started,

http://lists.opensuse.org/opensuse/2001-11/msg01343.html

http://dev.digi-corp.com/2009/09/moving-opt-data-to-new-partition-in-linux-due-to-low-disk-space

NOTE: I prefer using tar over cp, it is faster and I know it will preserve my file attributes, something like the following (a quick example, some steps have been left out for simplicity)

DO NOT FOLLOW THESE DIRECTIONS WITHOUT UNDERSTANDING WHAT IS BEING DONE

  • Boot from live USB.
  • Use fdisk and mkfs, to create and format a new partition on your 750GB drive, 50GB should be plenty.
  • Mount the new directory.

Like this

mkdir /mnt/var2
mount -a /dev/sdxx /mnt/var2

(replace sdxx with the 50 GB partition you created for your new /var, for example /dev/sdb1)

mount your ssd as /mnt/oldroot

mkdir /mnt/oldroot
mount -a /dev/sdxx /mnt/oldroot

(here /dev/sdxx is the / partition on your ssd, probably /dev/sda1 or similar) You should be able to navigate your old filesystem now, starting at /mnt/oldroot

now you will copy the files from the old /var directory to the new one

cd /mnt/oldroot/var
tar cSpf - . | (cd /mnt/var2 ; tar xvSpf - )

when the copying finishes, compare the 2 directories, if everything looks good rename the old /var directory

mv /mnt/oldroot/var /mnt/oldroot/var.0ld
mkdir /mnt/oldroot/var

All that is left is to edit /mnt/oldroot/etc/fstab to add the new partition as the mountpoint for /var (I will leave this to your imagination)

then

umount /mnt/var2
umount /mnt/oldroot
reboot

If all went well, when you reboot the new partition should be mounted as /var

Share:
17,797
Taerus
Author by

Taerus

Updated on September 18, 2022

Comments

  • Taerus
    Taerus over 1 year

    I've recently just installed Ubuntu 14.04 and I'm still very new to Linux/Ubuntu. I've got a laptop in which I have installed an 120GB SSD and a 750GB HDD.

    Currently, I have Ubuntu installed on the SSD and mounted the HDD through fstab to /mnt/var. Now I want to have programs installed on the HDD and keep the SSD clean for Ubuntu.

    As far as I understand, programs are installed in the /var directory, and so I have been trying to copy the current data from /var to /mnt/var and then edit fstab to mount the HDD to /var.

    Whenever I reboot, though, I get a lot of different issues: First, it said it couldn't find some drivers. Then, after another try doing it a bit differently it couldn't find /var.

    My question is, and I'm sorry if this has been asked before but I followed a bunch of different guides and none worked for me, how do I properly set it up they way I want?

    • Taerus
      Taerus almost 10 years
      Hmm, it just feels like the 750gb drive is there for nothing than. The way i used to manage my stuff on windows was to put everything i don really use often and uses alot of space on the HDD and the stuff i used regularly and wanted to be fast on the SSD. Is there no way to manage my stuff the same way on ubuntu?
    • Taerus
      Taerus almost 10 years
      Also, my drive might get filled up really fast. It's only 120gb. How would i use the 750GB optimally?
    • bain
      bain almost 10 years
    • A.L
      A.L almost 10 years
      Do you use another OS on your SSD? If you only use Ubuntu on the SSD, you will have lot of free space. My full installation of Ubuntu only uses 6 GB (my /home/ has its own partition).
    • karel
      karel almost 10 years
      @bain I suggest giving Taerus a chance to decide for himself if storing /var on a separate partition is the best way for him to do it before the question is flagged as a possible duplicate.
    • bain
      bain almost 10 years
      @karel Sure, but the question currently reads as "I want to store /var on a different drive, how do i properly set it up they way I want?" If the question is instead "Is it a good idea to put /var on a different drive?", then perhaps it should be reworded.
    • nyxee
      nyxee about 7 years
      I'm having this issue too right now. Putting something on a different partition on the same hdd is different from putting something on a partition on a different hdd (in the same computer in all cases hopefully)
  • Taerus
    Taerus almost 10 years
    Thanks for the advice, and i will stick to this. Maybe in the future somewhere when i have more expertise with Ubuntu/Linux i might reconsider this. Although if disk space issues will not arise i probably will stick to it forever. Thanks again, highly appreciated.
  • Deepak Verma
    Deepak Verma almost 10 years
    What I do is to put my home directory on the SSD, but I put documents, downloads, music, video, etc on the larger hard drive, and just add links to the home directory. I will probably try mounting them instead of using links, but I've been doing it this way for a long time, and it works. Also, if I install another OS, I can share the media files easily.
  • Taerus
    Taerus almost 10 years
    Hah, just so happens to be i just did the same :-) You can edit their folder paths somewhere in /home/user/.config/user-dirs.dirs.
  • Rinzwind
    Rinzwind almost 10 years
    @MartyFried I am with you there. I symlimk the directories in /home/ to my 2nd disc.
  • Deepak Verma
    Deepak Verma almost 10 years
    @Taerus - Yeah, I learned about that; but I also learned that if you delete, then add the link right away, it's not necessary. I also realized that symlinks might be better than mounting, because my backup automatically does not follow them, so I can backup the media separately.
  • Matt Nordhoff
    Matt Nordhoff almost 10 years
    You're right. I'd add that software is also installed in other places (/bin, /lib, /opt, &c.). They commonly store things like database files in /var, though. "your data and /home directory are closely tied" Sure, but you can be more flexible, and put stuff outside it. (Or symlink/bind mount so you can use another device but it still looks like it's inside ~.)
  • Braiam
    Braiam almost 10 years
    Why two answers?
  • nyxee
    nyxee about 7 years
    it's definitely good to know about the effects on disk life. So, basically, as of 2017, its better to install the system on an NVMe PCIe SSD, put /var and a few others on another cheap ssd, if possible, and put the rest of rarely used files on a Hard Disk, yeah..
  • Aureliano Guedes
    Aureliano Guedes over 2 years
    I don't see why keep home in SSD. It must not give too much performance for most of cases. Put it in HDD and keep fast access to the necessary data without need mount all the time. If have binaries in home, just link from SSD adding permissions.