LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 01-02-2004, 10:17 AM   #1
pearlr
LQ Newbie
 
Registered: Jul 2003
Distribution: Redhat 9.0
Posts: 1

Rep: Reputation: 0
Question Need to replace full harddrive with new, larger harddrive


Hi there! I am a relative newbie to Linux and have what I hope is a basic question. I have a server running Redhat 9.x with two harddrives, hda and hdb, partitioned as seen below:


Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda1 295564 277892 2412 100% /
/dev/hda7 72919708 129252 69086272 1% /home
/dev/hdb1 59106972 56025800 78628 100% /home2
none 127644 0 127644 0% /dev/shm
/dev/hda6 497829 8859 463268 2% /tmp
/dev/hda2 2522076 2284252 109708 96% /usr
/dev/hda3 2016044 395748 1517884 21% /var


As you can see, /dev/hdb1 is very close to full. I want to replace this drive with a bigger one, but I am unsure of what might be the best way to migrate the data to this new drive.

What I have done under Windows environments is to add this new, bigger drive as an additional drive and then copy data from the old drive to the new drive, then remove the old drive and place the new drive in the physical location of the old. This allows me to keep the existing drive letter after the migration is complete and the data migration was done via a simple file copy.

Is there a way for me to do the same thing under Linux or is there another way that I need to do this?

Thanks in advance for your help.

 
Old 01-02-2004, 12:59 PM   #2
fancypiper
LQ Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 60
I would tar it over, then edit /etc/fstab to reflect changes, then umnount partitions, then mount /home2 and you are done.

# Clone a distro to another drive or move directories around
Install drive in box (assuming IDE1 slave for examples) and ensure BIOS can detect it. Boot into Linux and login to your user's account. Open an x terminal and partition and format the new drive as you wish
Code:
[fancy@tinwhistle fancy]$ su -
Password: 
[root@tinwhistle root]# fdisk /dev/hdb
Exit with w to write the partition table.

Format the partitions with the chosen filesystems:
mke2fs /dev/hdbX -> ext2
mke2fs -j /dev/hdbX -> ext3
mkswap -> swap
mkreiserfs -> reiserfs
mkfs.xfs -> xfs

Make directories for source and destination mount points. You need these to keep out of an endless loop of copying itsself over and over.
Code:
[root@tinwhistle root]# mkdir /mnt/source
[root@tinwhistle root]# mkdir /mnt/destination
Mount your os partitions that you want to clone on /mnt/source
Mount your partitions on the new drive, making directory entries for your separate partitions (/boot, /home, /var etc.). If you are just copying a directory such as var, just cd to the directory you wish to copy instead of mounting partitions on /mnt/source.

Now, cd to /mnt/source and pipe it over with tar
Code:
[root@tinwhistle root]# cd /mnt/source
[root@tinwhistle source]# tar cf - . | (cd /mnt/destination && tar xBfp -)
Edit /etc/fstab as needed, install the boot loader if you moved a whole distro, and it should work when it is installed in it's final position.
 
  


Reply



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
A harddrive failed in my raid array, how do I replace it? abefroman Linux - Hardware 2 09-23-2005 04:02 PM
Installing linux on 2nd harddrive(dual boot) windows on seperate harddrive lysol Linux - Software 25 08-03-2004 09:33 AM
Making space on harddrive (its full!) robson8112 Linux - General 4 01-20-2004 11:52 AM
Need to replace HDD with a larger drive gvi Linux - Hardware 7 01-20-2004 10:20 AM
min. harddrive size full install MD Linux Kdiver58 Linux - Newbie 1 01-18-2003 12:59 PM

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

All times are GMT -5. The time now is 02:03 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
Open Source Consulting | Domain Registration