LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 07-22-2003, 06:32 AM   #1
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Rep: Reputation: 30
Exclamation Emergency - New Harddisk to transfer old data


Hello I'm relatively new to installing new harddisks in Linux.

I have a Linux system on a single harddisk. Now I have a directory in /var/mydir which grows a lot, since it serves for authentication of new users in my gaming server. anyways.. I want to mount this directory on a new harddisk.

Here come the problems -

(1) Do I need to format the harddisk using mke2fs or do I need to do cfdisk and just plug it in to the mother board? Can I format the harddisk on another computer using the windows fdisk utility for example, and then plug this new harddisk to the Linux server?

(2) What do you suggest, to move the /var/mydir on my new directory or mount it to the new harddisk? this directory contains logs which are appended, so I need these logs in the new harddisk

(3) What do i need to include in the /etc/fstab file to cater for the new harddisk/mount of new directory?

PS: The /var/mydir contains important information, so I need to choose between the most efficient method to transfer data and keep priveleges on the new harddisk.

Another thing - LVM is not in my agenda to use it as a solution.

Regards,
Ganni.
 
Old 07-22-2003, 06:38 AM   #2
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 64
First up, Welcome to LQ

Second, check this link, I'm sure it will help with the process:
http://p-two.net/hard-drive/hard-drive.html

Third, let's answer your questions:

1. You will need to create at least 1 partition on the drive, this partition can be the entire hard drive, or just a portion, you can decide. Yes you can use other fdisk applications but I strongly suggest that if it's possible to work your way through linux's fdisk as it's MUCH more versatile and powerful than DOS fdisk. Afterwards you will need to use mke2fs on the partition if you want to create an ext3 filesystem on it. the command would be something like:
mke2fs -j /dev/hdx
Where /dev/hdx is the partition you create with fdisk. The hard drive will likely (unless on a controller of some sort) be:
hda, hdb, hdc OR hdd Depending on it's location on the motherboard. hda and hdb are primary slot, and hdc and hdd are secondary. hda and hdc are set for Master on the jumper and hdb and hdd are slave.

2. You can copy them straight to the disk. Mount up your new disk (follow those directions in the link, but here's a quickie just for the idea) like so:
mount -t ext3 /dev/hdx /mnt/newdrive
Now simply copy the data over:
cp -a /mnt/mydata /mnt/newdrive

3. Your new entry in fstab should look something like:
/dev/hdx /var/mydir ext3 defaults 2 1

Again, hdx is just a representation of the partition you create with fdisk.

HTH

I'll be happy to clarify ANYTHING should it be confusing.

Cool
 
Old 07-22-2003, 07:19 AM   #3
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
Hi MasterC thanks for the quick response! That helped me a lot to clarify a lot of things!! However, my problem is that I want to retain links to /var/mydir. So I wondered whether I can first rename /var/mydir to /var/mydir_original and then mount the new harddisk to /var/mydir and finally copy the files using the cp -a /var/mydir_original /var/mydir

Ganni.

PS: Sorry for posting the last message on two forums - my mistake!
 
Old 07-22-2003, 07:21 AM   #4
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
By the way, I'm trying to create the effect of "swapping" one partition with another, to put the /var/mydir on a bigger harddisk sort of...

Ganni.
 
Old 07-22-2003, 08:00 AM   #5
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 64
So let me try to re-itterate what you have said above to clarify it:
You want to place this disk in the system, have it boot up and do all the transferring during runtime while files are still being logged?



I am thinking it will be a lot easier to add this hard drive by first going down to runlevel 1 (as should be in that how-to up there):
telinit 1

Log back in as root, then mount up the new hd after partitioning and formatting at any given location, I prefer /mnt/newdrive simply for ease of understanding (you will have to make that directory first:
mkdir /mnt/newdrive)
Now to mount it:
mount -t ext3 /dev/hdx /mnt/newdrive
Then you copy the data from /var/mydir to /mnt/newdrive and since we are in init 1 now, we will use mv instead of cp:
mv /var/mydir/* /mnt/newdrive
This will in essence put all the data from /var/mydir onto the new hardrive at it's root, but it's root is at /mnt/newdrive (which can be confusing, but will make sense in a minute hopefully).

So now we have a bunch of files in /mnt/newdrive and they were in /var/mydir before. Now we need to umount the newdrive:
umount /mnt/newdrive
And mount it up at the mount point /var/mydir which will place the data right back where it was as if it never left, but with MUCH more room and dedicated specifically to that drive:
mount -t ext3 /dev/hdx /var/mydir

Now if you ls the files at /var/mydir it should appear that they never moved

You can move back to your previous runlevel:
telinit x
where X is your previous runlevel, probably 3 or 5.

And to have these changes be set in stone on reboots you will add this to your fstab:
/dev/hdx /var/mydir ext3 defaults 2 1

HOWEVER....

After all that, if you just wanna symlink it all, you could very well:
cp -a /var/mydir/* /mnt/newdrive (I'd pick a more permanent mount point than this though since it will be living at it from now on)
And then remove the directory /var/mydir:
rm -r /var/mydir
And make a symlink:
ln -sf /mnt/newdrive /var/mydir
And this will make it look like /mnt/newdrive is actually /var/mydir for your applications.

Your choice really, the second allows more "use" of the drive should you want to do other things with it (such as add other directories around it and such).

Cool
 
Old 07-22-2003, 08:03 AM   #6
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
One last thing, something about the fdisk.. Since I will only use the new harddisk to place the /var/mydir directory only, should I assign the partition number to 1, and leave the first and last cylinders as default?
 
Old 07-22-2003, 08:08 AM   #7
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 64
If you are going to dedicate the entire HD to the single directory, then yes, you want to use the default values (which are normally the entire disk) and yes, you will want to leave it as Primary Partition 1.

Cool
 
Old 07-22-2003, 10:35 AM   #8
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
You wrote:
-----------------------------
After all that, if you just wanna symlink it all, you could very well:
cp -a /var/mydir/* /mnt/newdrive (I'd pick a more permanent mount point than this though since it will be living at it from now on)
And then remove the directory /var/mydir:
rm -r /var/mydir
And make a symlink:
ln -sf /mnt/newdrive /var/mydir
And this will make it look like /mnt/newdrive is actually /var/mydir for your applications.
-----------------

Yes I actually prefer the symbolic link option. Thanks for your solutions, both of them make sense.

Ganni.
 
Old 07-22-2003, 12:10 PM   #9
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 64
You're welcome. Glad I could help

Cool
 
Old 07-23-2003, 02:21 AM   #10
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
Following a discussion with my friend, is it possible in solution 1 to do a cp -a like in the second solution instead of running level 1 and then using mv as suggested? I haven't yet grasped the concept of doing a mv while in level 1, if that still doesn't preserve the original permissions.

Ganni
 
Old 07-23-2003, 09:20 AM   #11
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 64
The difference being that with mv the data that is currently in /var/mydir will be gone, and you are then mounting on an empty directory as you should be. If you cp -a and then mount upon the directory containing all that data, it's not proper and sometimes won't work right.

The mv in rl 1 is simply to stop all writing and reading to/from that directory. It ensure no errors will take place from the mv and that you don't have to reboot to make things happen.

Cool
 
  


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
Data Transfer Dharma_bum07 Linux - Newbie 11 11-26-2004 02:57 PM
harddisk disassembly to get data eantoranz Linux - Hardware 8 10-10-2004 12:20 PM
Low Harddisk space. Can I just transfer the entire Linux to a bigger harddisk? davidas Linux - Newbie 12 04-13-2004 03:03 AM
No data transfer ! shaahul Linux - Hardware 3 09-16-2003 03:08 AM
Emergency - New H/D to transfer growing data which doesn't fit anymore in old H/D ganninu Linux - Hardware 1 07-22-2003 06:39 AM


All times are GMT -5. The time now is 02:35 AM.

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