LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Move an existing partition to a new hard drive? (https://www.linuxquestions.org/questions/linux-hardware-18/move-an-existing-partition-to-a-new-hard-drive-186099/)

vdemuth 05-26-2004 11:44 AM

Move an existing partition to a new hard drive?
 
Hello everyone,
My current /usr partition is begining to fill up, and I want to move it to my second hard drive. What is the easiest non-destuctive way to do this. I have discovered that I can't have 2 partitions both named /usr, and so am getting out of my depth here.

TIA

aikempshall 05-28-2004 08:46 AM

Well. I would -

1.
create a new partition;

2.
do a cp -a from the existing /usr to the new partition;

3.
amend my /etc/fstab to point to the new partition;

4.
if you've labeled the partitions may cause a problem all my partitions are unlabeled so I use /etc/fstab to ecxplicitly point to the appropriate directories;

5.
reboot.

Goala 05-28-2004 10:56 AM

hi vdemuth

I would do:

1) Use cfdisk to create the partition in the new disk (call it emmmmm.... /dev/hd??)
2) mkfs.ext3 /dev/hd?? to create a ext3 file system in the new partition (you can use ext2, reiserfs... of course).
3) mkdir a new directory in your system... call it emmm... /usr_new
5) mount -t ext3 /dev/hd?? /usr_new
4) cd /usr && tar cvf /usr_new/usr_new.tar * (with tar you keep the symbolic links)
5) cd /usr_new && tar xvf usr_new.tar && rm usr_new.tar
6) vi /etc/fstab and change the line with /usr bla,bla,bla with /usr /dev/hd??.
7) reboot


Bye.

vdemuth 05-28-2004 11:15 AM

OK, aikempshall I intend to give that a go. I take it then that if I wanted to do the same with say my /home partition, I just follow the same procedure.(using the correct names of course).
Could I then, ask you a second question? If I were to carry this out succesfully, then resize my now defunct partitions, and then transfer back again. Am I able then to keep my partitions as they are?
And could ypou please explain about the reference you made to labeling.
Thanks.

Oh, thanks to too goala for his suggestion.

aikempshall 05-29-2004 03:42 AM

The steps outlined by Goala is the standard textbook approach. Where I've departed from this approach is to use "cp -a" instead of tar.

Yes to your second question. What you appear to intend to do is to use the new partition as effectively a temporary back up device whilst insreasing the size of the existing partition.

In cfdisk you can assign a label to a partition and use that label in fstab to mount the partition. Some time ago I spent a little time trying to work out why my system wouldn't boot cleanly after moving partitions around following my ditching of redhat and fedora. I removed the label via cfdisk and haven't looked back since. Labeling of partitions probally makes life a little easier in a large installation where life is organised.

Regards

vdemuth 06-02-2004 07:18 AM

Thanks to everyone who helped me out with this problem. After following the suggestions outlined, I have successfully managed the task, and learned a bit more at the same time.

Goala 06-03-2004 03:16 AM

that's the idea :

solve a problem and learn a lot!

congratulations!

vdemuth 06-03-2004 05:12 AM

Thanks goala, but here's another quick question for you. Everything appears OK. CFDISK shows my new partitions at the right sizes, as does qtparted, fdisk,lsparts and diskdrake, but the command df shows the partition /dev/hda1 as only being 738Mb when it's 3.9Gb (as shown by cfdisk).
Any idea what might have caused this?

Goala 06-03-2004 09:28 AM

have yoy tried?

df -k (show the sizes in kbytes)
df --block-size=1M (Sizes in megabytes)

vdemuth 06-04-2004 02:29 AM

Solved,
Turns out that the resizing script in Mandy is flawed, and it doesn't run the resize_reiserfs command. Ran that command, gave it the partition size, even though the doc's say it doesn't need it to grow, and df now reads space correctly.
All of the above incidentally done under pclinux2k4 live CD, as it's the closest next distro to mandy, and therefore very familiar to use.


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