LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-23-2007, 04:54 PM   #1
agatone
LQ Newbie
 
Registered: Sep 2007
Posts: 6

Rep: Reputation: 0
Keeping old data on disk


Hello,

First I want to point out that although I have Ubuntu box for about year now I'm still newbie

After a year of runing simple web server the time came when i have to reinstall the box (clean install). Problem is that in that year i have alot of data in /var/www/ dir which i want to keep complete disk is mounted to / so i can't wipe it out so simply.

Is there any soulution to remount (and how) only certain dir that will not be formated when i run reinstall? Or is there some other approach to this problem?

thanks for any reply
 
Old 09-23-2007, 05:18 PM   #2
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687

Rep: Reputation: 61
It is possible if you have the space to shrink the / partition as it sounds like you say everything is in /. Then you can create a new partition in the free space and transfer all directories files and links from /var on the existing / partition to the new /var partition. Then you can re-install everything in that old / partition and either specify the /var partition without formatting it during the custom partitioning stage of the installation, or reset links after installation, or move everything in the new /var partition back to the /var in the / of the new installation, delete the separate /var partition and grow your / partition back to original size.
Or you can use tar and gzip to roll it all up into a ball and chuck it onto another drive/partition till the rebuild is done (minus most hidden application folders), then unroll it back in the new /var.

Below is a working method of moving the /home directory to it's own partition while keeping the file structure and links in tact. There should be no reason why it can't be adopted to move /var to it's own partition:
Code:
As root or sudo:
1: #mkdir /mnt/newhome
2: #fdisk -l   (to find device name of partition)
3: #mount -t ext3 /dev/???? /mnt/newhome (replace check marks in /dev/xxxx as per output of fdisk -l command)
4: #cd /home
5: #cp -ax * /mnt/newhome
6: #cd /
7: #rm -fr /home
8: #umount /mnt/newhome
9: #mv /mnt/newhome /home
10: #vim /etc/fstab (edit /etc/fstab with favorite editor if not vim, and add line below with proper /dev/xxxx)
11: /dev/???? /home ext3 defaults 1 2
12: re-boot
You'll need to put a line in /etc/fstab to have it mounted, you might want to investigate first and find what that line should contain.
 
Old 09-23-2007, 05:30 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 16,001

Rep: Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219
Just create a new partition and copy the data. Then update /etc/fstab to include a new line; say for example (adjust as necessary)
Code:
/dev/hda10    /var/www    ext3  defaults 0 2
This will mount everything in directories "below" as well, so be sure to copy everything over; I like to use "cp -a <target> <source>" from a liveCD (recovery mode from the boot menu should be o.k. too).
Do this on your current system to ensure nothing gets "lost".

While you're in the mood, why don't you do likewise for the /home, so you don't lose that in the upgrade.
Just did similar on a Dapper to Feisty jump, although I used a new partition for the root; I think you'll need to use the alternate CD to assign your own mountpoint(s). And you'll probably need to do the fstab change for /var/www by hand again after the new system has been installed.

Edit: Whoa, you must type fast ...
All good, I'll go back to sleep.

Last edited by syg00; 09-23-2007 at 05:41 PM. Reason: D'oh
 
Old 09-24-2007, 04:14 AM   #4
agatone
LQ Newbie
 
Registered: Sep 2007
Posts: 6

Original Poster
Rep: Reputation: 0
So I need free disk space - at least same amount as the dir i'm trying to keep. But out of 72GB disk i have no free space left.

So no free space no solution for me?

Last edited by agatone; 09-24-2007 at 04:25 AM.
 
Old 09-24-2007, 08:00 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 16,001

Rep: Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219
As Junior_Hacker said, you'll probably be able to recover space from a current partition(s). Let's see the output from this (run in a terminal)
Code:
 df -hT
 
Old 09-25-2007, 03:37 AM   #6
agatone
LQ Newbie
 
Registered: Sep 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Here you go

Code:
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/hda1     ext3     72G   66G  2.9G  96% /
varrun       tmpfs    253M  128K  252M   1% /var/run
varlock      tmpfs    253M  4.0K  253M   1% /var/lock
devshm       tmpfs    253M     0  253M   0% /dev/shm
lrm          tmpfs    253M   13M  240M   5% /lib/modules/2.6.12-9-k7/volatile
 
Old 09-25-2007, 04:52 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 16,001

Rep: Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219
Then again, maybe not.
Go buy another disk. I use 100 Gig (external) USB disks to move stuff around, but in your case you'd be better off getting another disk unless you can find something (big) to delete.
Same advice as above applies.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
floppy only reads first disk, if new disk is inserted data from first disk is shown. lakosked Debian 3 02-18-2006 09:44 PM
Keeping Data when Installing FC3 onto windows system ton_vb Fedora 3 11-22-2005 07:41 AM
Making new partition and keeping existing data SDmac Slackware - Installation 3 05-20-2005 08:14 AM
how to get the data of a disk anywhere? nice007 Linux - Newbie 1 03-24-2005 06:42 AM
Keeping data when changing platforms DaveWolles Linux - General 3 03-05-2004 09:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration