LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Steps to increase /home partition to new hard disk (https://www.linuxquestions.org/questions/linux-software-2/steps-to-increase-home-partition-to-new-hard-disk-602031/)

gargvipul 11-24-2007 12:05 AM

Steps to increase /home partition to new hard disk
 
I have my Linux server disk configuration as follows:
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.7G 2.7G 6.5G 30% /
none 1013M 0 1013M 0% /dev/shm
/dev/sda2 51G 45G 4.4G 92% /home
/dev/sda3 4.9G 42M 4.6G 1% /tmp

I wish to increase the partition size of /home to a new disk space. I wish to know the steps in detail to achieve the desired result.

The /home partition has my database and application stored and wish to be intact while increasing the partition. In case I need to take a backup then do let me know the command to achieve the desired backup.

Warm regards,
Vipul

jschiwal 11-24-2007 01:04 AM

You only need to create a partition & file system on the new disk and mount it under a temporary name like /home-new and copy the files. Use the "-a" archive option. You could also use the tar command. The info manual has an example of copying a partition.

Another thing you might consider is creating an LVM volume of the new drive. Then create a /home-new partition on the volume and copy the files over. If the files copy over fine, you can edit your /etc/fstab file to mount the LVM volume on /home instead. Later you can add /dev/sda2 to the volume and increase your new /home by 45G if you wished.

gargvipul 11-24-2007 01:22 AM

Thank you for the suggestion. I essentially understand from your suggestion that the existing /home partition data need to be copied to the new disk using cp or tar command. Is there any possibility to increase the partition size without copying the data, that is, adding the new disk space to existing /home partition.

Also I would like to know that I have Oracle database installed in /home partition. Will copying the data to the new disk maintain the database integrity.

jschiwal 11-24-2007 02:46 AM

I misread "new disk space" as "new disk". If the next partition is temp, you could recreate it, moving the start of the partition up, leaving room to grow the home partition.

I would recommend backing up the data in any case. I think the best way to do that is to use an external drive formatted in a Linux filesystem. Then either copy the files over or use tar to create a tarball. It would be best if the /home partition were off line. That way files won't be altered when copying them over. Some distro's have a partitioner program that can expand the filesystem without losing data, but you want to back up the contents just in case.

gargvipul 11-24-2007 05:25 AM

You read it correctly. It is new disk, that is, additional disk. I was curious to know that can a partition span to multiple disks or not. For example in my case the /home has 51GB space on disk1. I want the /home partition to increase by 140GB on disk2.

That is, /home = 51GB on disk1 + 140GB on disk2. Is such scenario possible?

jschiwal 11-24-2007 09:30 PM

Yes, that is what LVM does. You can add new disks to an LVM volume. In your /etc/fstab file, insead of a disk partition device like (/dev/sda2), you will use the LVM device name.
example from Fedora Core 6 Laptop:
Code:

/dev/VolGroup00/LogVol00 /                      ext3    defaults        1 1
This laptop has a single partition for the system (/); /home is a directory.
Fedora core uses LVM by default. It has a graphical LVM manager to add disks to an LVM volume. On SuSE, you can do the same thing using their partitioner program. You can also do it from the console. The first step would be installing the LVM package. Read the README and any howto's installed with the package. The LVM package installs several programs. For example, suppose you had a 10GB disk. You want to replace it with an 80GB disk. You could migrate the contents from the 10GB volume member, remove it from the volume, replace it with the 80GB disk, and add that one to the volume.

I'm not certain whether you can add the old /home partition nondestructively. In my first post I suggested creating an LVM volume, and mounting it as /home-new. Then copy the contents over from /home to /home-new. Now you can edit /etc/fstab and mount the LVM volume (it using the new disk(s)) as /home. You can use the old space from the old /home partition and add it to the volume. So now the LVM volume consists of the new disks plus the partition you were using previously for /home.


All times are GMT -5. The time now is 05:00 AM.