Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I accidentlly deleted /var folder form my ubuntu istalltion. Can it be restored somehow, without loosing the installation? Please suggest what options I do have?

share|improve this question
    
Isn't that exactly what backups are for? –  David Schwartz Nov 9 '11 at 9:33

2 Answers 2

I know this is old but... This problem happened to me yesterday and I found this ubuntu forum topic, it was very usefull.

I accidentaly erased my /var folder... sudo nautilus is not a good idea I suppose... Ooops, my fault.

I just created an Ubuntu VM (same version) in other computer, copied the /var folder from this clean installation and paste it in the computer (HDD) where I erased the /var folder.

There are a couple of things that happened to me, maybe of interest:

I could start ubuntu without the /var folder, but without the GUI (Unity/Gnome) only using the console (Like when you press ctrl+alt F1 or something like that) and for some reason the flashdrives were not recognized.

From the ubuntu's LiveCD the flashdrives were readable (and writable). So my solution was to open a terminal and using "sudo cp" to copy the "clean /var directory" into the HDD

Now I am available to start ubuntu "normally" and even run every program, like GGTS (an eclipse derived), pgAdmin, firefox... except tomcat Everything seems to work as before erasing the /var folder, but I plan to reinstall Ubuntu in the moment I can, just to be sure.

NOTE: The harddrive when booting from livecd is in /media/

I was using Ubuntu 12.04

share|improve this answer

/var contains some important folders which hold the state for programs (in /var/lib). Your program state (dpkg) has gone too, so you will end up with a reinstallation of programs anyway.

Since /var/log has gone too, you cannot analyse /var/log/apt/history.log either so you have to rely on your memory to know which programs you've installed. After restoring the dpkg and packages database (probably by sudo install -D -m755 /var/lib/dpkg && sudo apt-get update), you can use dpkg -S /path/to/file to get the package for a given path.

That said, a reinstallation would be the easiest way. Make a backup of /home (and possibly /etc if you changed system-wide settings or users/groups) and do a reinstall. If your /home was on a separate partition, it's even easier: mark that partition as /home in the installer, but do not tick "format".

share|improve this answer
1  
I don't understand: if he lost /var, how can he look at /var/log/apt/history.log? –  Lohoris Nov 9 '11 at 9:20
1  
@Lohoris: well, that's technically possible since /var/log could be a separate mount point. Updated answer with for a more likely situation. –  Lekensteyn Nov 9 '11 at 9:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.