How can I move /var to another harddrive?

7,082

The quick and easy way would be to edit your /etc/fstab file and add an entry similar to the one that you should see for the / partition and just put the necessary pointers such as the fs type, ext4 and point it to /dev/sdb5. Reboot and it should work. I would mount it to a temporary mount point and recursively copy or rsync it to that filesystem to ensure that you do not loose any data first.

Share:
7,082

Related videos on Youtube

user2437305
Author by

user2437305

Updated on September 18, 2022

Comments

  • user2437305
    user2437305 over 1 year

    I've put a new SSD as /dev/sda, the old HD as /dev/sdb. And done a fresh installation as one partition on /dev/sda1.

    The main quirk in my set-up is that I don't want to repartition the old HD, since it's got lots of data on it.

    Since I had a swap partition on the HD before, I've put that into fstab. I've also mounted the HD. And /tmp (and /tmp/var) are in tmpfs.

    But, how can I go about moving /var to the HD? I can junk the old one (currently sitting under root at /dev/sdb5, and /mnt/hd).

    Doing a simple ln -s /mnt/hd/var /var doesn't seem to work. Is this something I need to do with mount -o bind? I'm asking because the "attempt, fail, recover" cycle time is pretty long.

    • Mark Russell
      Mark Russell over 12 years
      Why do you want to preserve the old var? Or if not preserve... why have /var on your HDD? It's written to pretty frequently, I'd much rather have it on my SSD. I don't think having it on a separate drive (from /) makes up for the HDD speed and latency hit.
    • user2437305
      user2437305 over 12 years
      But I've seen many recommendations on the net to keep /var off the SSD, simply because it gets written to a lot... And I'm trying to avoid excessive wear on the SSD.
  • user2437305
    user2437305 over 12 years
    But doesn't mounting /dev/sdb5 as /var declare the whole partition as /var? I have other directories on that partition (such as my old /home/...)
  • Justin Andrusk
    Justin Andrusk over 12 years
    Yes, so you would need to do some cleanup so that /var only has data specific to /var.