Results 1 to 6 of 6

Thread: Moving the swap, /tmp and /var back to main drive

  1. #1
    Join Date
    Jan 2006
    Beans
    272
    Distro
    Ubuntu

    Question Moving the swap, /tmp and /var back to main drive

    I installed Ubuntu 16.10 on an SSD (sda) drive and moved the /var, /tmp and swap to a hard drive (sdd) but would like for them to reside on the SSD (sda) again.

    I am unsure how to get started, previous attempts at moving these partitions have failed and I ended up having to reinstall Ubuntu. I'd like to prevent that this time around and learn something in the process.

    Will simply removing the mount points from fstab cause Ubuntu to automatically mount these folders on the SSD (sda) again after restarting?

    disks.jpg
    fstab.jpg

  2. #2
    Join Date
    Apr 2007
    Beans
    3,114
    Distro
    Ubuntu

    Re: Moving the swap, /tmp and /var back to main drive

    /var and /tmp indeed will automatically reside on sda again. Swap is not a file, but a partition. If you want to move swap back to the ssd, you need to have a swap partition on that drive, and then fill out the UUID of that drive in fstab so that the system can pick than one up on the next boot.

  3. #3
    Join Date
    Nov 2015
    Beans
    26

    Re: Moving the swap, /tmp and /var back to main drive

    To avoid a re-installation you should copy the contents of your existing /var, /tmp et al to your root partition (the folders should already be in place) using a live USB/CD which will preserve permissions

    Code:
    # cp -rp /dev/sd_OLD_PART/{var,tmp}/* /dev/sda_ROOT_PART/{var,tmp}/*
    Not copying the existing contents, and their permissions, of the moved folders would have been the cause of your previous issues.

  4. #4
    Join Date
    Jan 2006
    Beans
    272
    Distro
    Ubuntu

    Re: Moving the swap, /tmp and /var back to main drive

    I successfully moved the swap partition but I am having trouble copying the contents of the /var and /tmp folder. It says that /dev/sdb5 and /dev/sdb6 are not folders when I execute the copy command.

    Would mounting these partitions as folders first and then copying their contents achieve my goal?

  5. #5
    Join Date
    Aug 2011
    Location
    52.5° N 6.4° E
    Beans
    6,822
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Moving the swap, /tmp and /var back to main drive

    /dev/whatever is not the thing you want to copy. Those contain the raw bytes as present on the hard drive, not the directories and files when these bytes are interpreted as a file system. So boot from a live disk, mount the old /var partition and the root partition of the installed system and copy the files:
    Code:
    sudo rsync -aXS /mnt/oldvar/. /mnt/root/var/.
    assuming you mounted them at /mnt/oldvar and /mnt/root.

    Then edit the fstab of your installed system and delete the line mounting /var. You can do the same for /tmp, but on most systems /tmp is wiped on every boot, so there may not be anything worth saving there.

  6. #6
    Join Date
    Jan 2006
    Beans
    272
    Distro
    Ubuntu

    Re: Moving the swap, /tmp and /var back to main drive

    Quote Originally Posted by Impavidus View Post
    /dev/whatever is not the thing you want to copy. Those contain the raw bytes as present on the hard drive, not the directories and files when these bytes are interpreted as a file system. So boot from a live disk, mount the old /var partition and the root partition of the installed system and copy the files:
    Code:
    sudo rsync -aXS /mnt/oldvar/. /mnt/root/var/.
    assuming you mounted them at /mnt/oldvar and /mnt/root.

    Then edit the fstab of your installed system and delete the line mounting /var. You can do the same for /tmp, but on most systems /tmp is wiped on every boot, so there may not be anything worth saving there.
    That did the trick, thank you very much!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •