Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating a home server. After successfully installing Ubuntu Server, I realized I mounted a partition on /var.. how to I unmount it and make it use the main bootable partition instead? I wanted the partition currently mounted on /var to be a samba share, so I made a folder in /media called share and mounted it to that as well for now.. is that the right way to do it?

share|improve this question
up vote 1 down vote accepted

The simplest and most portable way is to edit /etc/fstab. It'll be a little trickier because you shouldn't yank /var out from under the feet of a running system. It's probably easiest to do from a live/install/rescue CD, but it might be possible to wing it on a running system as well. I get the feeling that you are relatively new to Linux though, so you probably shouldn't go that route. Rather, use the rescue mode of the installation media you used to install the system (it can be selected on the boot menu you get when you boot from the CD).

  • Boot into rescue mode (might be referred to by some other name on other distributions), and mount your root partition
    for example, mount /dev/sda1 /mnt will mount /dev/sda1 under /mnt; you'll find there's an empty /var directory there (it's the mount point for the file system)
  • Mount the installed system's /var at some other location
    for example, if you put /var on /dev/sda3, mkdir /installedvar && mount /dev/sda3 /installedvar
  • Move the files: shopt -s dotglob && mv /installedvar/* /mnt/var/ and verify that /installedvar is now empty (use ls -A, find or something else that also shows dotfiles) and that /mnt/var looks sane
  • Edit /mnt/etc/fstab (I think nano is available in the Ubuntu rescue CD environment, in which case nano -w /mnt/etc/fstab will be helpful), removing or commenting out the entry for /var or change it to use some other mount point (just make sure no separate file system gets mounted on /var)
    Take care to not introduce any linebreaks that aren't already there! To nano, -w turns off word wrapping.
  • Unmount everything and reboot

The system should come up just fine, and you now have a spare partition that used to be /var. Depending on how you edited your fstab, it may be mounted somewhere else or not.

share|improve this answer
Thanks very much for the reply, I'll give this a shot – bruchowski Aug 3 '13 at 9:11
@bruchowski Just take it nice and slow; it isn't really difficult. The most important thing to remember is that what you are used to as being / becomes /mnt/. – Michael Kjörling Aug 3 '13 at 9:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .