LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Move OS to Another Hard Disk (https://www.linuxquestions.org/questions/linux-software-2/move-os-to-another-hard-disk-760454/)

k_oudom 10-07-2009 11:27 PM

Move OS to Another Hard Disk
 
While the data is increasing, my hard disk is going to run out of space. I want to move OS to another bigger hard disk and extend the space without having to brick my OS. Is there any solution?

wfh 10-07-2009 11:36 PM

Quote:

Originally Posted by k_oudom (Post 3711807)
While the data is increasing, my hard disk is going to run out of space. I want to move OS to another bigger hard disk and extend the space without having to brick my OS. Is there any solution?

Having done this a number of times, I can tell you that much depends on how you partitioned your disk at installation time; I'm referring to your original install. It's simpler if you broke things out into separate partitions.

Did you make partitions for home, boot, var, etc?

Can you post the result of this:

# df -h

Also, what OS? What kind of disk is it running on (i.e. SCSI, SATA, IDE, etc.) What are you running...a big web server, for instance? Do you have masses of personal data? What's important to preserve *BEFORE* you potentially brick your system : )

k_oudom 10-07-2009 11:40 PM

I only created 2 partition for CentOS 5.3. Swap and other one for all such as /, /home, /var, /tmp, ....

Wim Sturkenboom 10-08-2009 12:17 AM

Putting the OS on a bigger disk does not make sense; you should put the data on a bigger disk.
Not sure what you're all running. Assuming that this is a webserver with a MySQL database:
  1. make backups of the data that is going to be moved
  2. install new HD
  3. partition and format new HD; use a partition for webpages and a partition for mysql (as an example).
  4. modify /etc/fstab and add the new partitions so they will be mounted at boot time
  5. mount the new partitions manually
  1. stop mysql
  2. copy mysql data to the new partition allocated for mysql (make sure you preserve the permissions and ownerships of the files (e.g. cp -p -r)
  3. reconfigure the mysql datadirectory in the startup script
  4. restart mysql
  1. copy all the websites to the partition allocated to websites again making sure to preserve the permissions and ownerships
  2. not sure if there's an easy way, but you need to modify all documentroots
  3. restart apache

After everything is done, reboot. This will make sure that the new partitions will be mounted during a reboot.
Once you're happy that everything works, you can delete the originals.

Notes:
1)
I assume that your webpages are somewhere in /var. If they are in /home, the procedure for apache will be slightly different.
2)
I've done this on Slackware; not sure how it all works under Centos and where configs are stored. Therefore this is only a general description.

lutusp 10-08-2009 02:48 AM

Quote:

Originally Posted by wfh (Post 3711813)
It's simpler if you broke things out into separate partitions.

Did you make partitions for home, boot, var, etc?

No, as a matter of fact, this is a stupid practice. The number of disk-full failure modes is equal to the number of partitions. The fewer partitions, the better.

For practical reasons, about three partitions is best:

1. The system root (/), containing /var, /usr, /etc, /tmp, etc. etc. -- all the system directories.

2. Swap, twice the size of system RAM

3. Everything else.

Reasonable arguments can be made for a few more partitions, but creating partitions for each of /boot, /var, /usr, /opt, /tmp and the usual cast of characters, as is so often suggested here, is unremittingly stupid and leads to unnecessary failures as one partition inevitably fills up and kills the system while there is plenty of free space elsewhere.

k_oudom 10-08-2009 03:58 AM

Did you experience resize partition in Windows XP. That's what I want.

Wim Sturkenboom 10-08-2009 04:37 AM

First it's centos, now WinXP is added to the mix. Do you mind to elaborate? ANd maybe the output of df-h as requested by wfh might help us to advise.

k_oudom 10-08-2009 04:48 AM

Can we clone Linux OS to another Hard Disk?

Rincewind456 10-08-2009 04:57 AM

Quote:

Originally Posted by k_oudom (Post 3712061)
Can we clone Linux OS to another Hard Disk?

Yes use the dd command. Done it loads of times with Linux and winblows partitions.

k_oudom 10-08-2009 05:01 AM

Clone OS without shutting down? No way!

Rincewind456 10-08-2009 07:05 AM

Quote:

Originally Posted by k_oudom (Post 3712070)
Clone OS without shutting down? No way!

No you can't. Who said you could?

k_oudom 10-08-2009 11:04 PM

Type "dd" in command line?

Wim Sturkenboom 10-08-2009 11:27 PM

yes, and read man dd

k_oudom 10-08-2009 11:36 PM

I'm not yet turning on the OS but what I want to make sure is:
This can be use to resize of the current-use-partition just like using Partition Magic in Microsoft Windows XP, right?

Wim Sturkenboom 10-09-2009 04:41 AM

Quote:

Originally Posted by k_oudom (Post 3713029)
I'm not yet turning on the OS but what I want to make sure is:
This can be use to resize of the current-use-partition just like using Partition Magic in Microsoft Windows XP, right?

I probably missed something but what is the this in the above sentence?


All times are GMT -5. The time now is 03:45 PM.