Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Possible Duplicate:
Repartitioning two disks without a loss of data

I am interning at a software company and I have hit somewhat of a brick wall. Here is the deal:

The Problem: We have some boxes around here that were incorrectly partitioned for 2 x 500 GB drives. The actual drives are 2 x 1 TB drives. These are essentially machines with only half of their available disk space being used. I am tasked with writing a script to re-partition these drives.

Solution Thus Far: I have a script that disables all process and reboots, and then another script that fixes the partitions. The problem is that there is a loss of data.

What I'm Looking For: I need a solution that does this but saves all the data. My first though would be to just grow the partitions to their appropriate size, but I'm not sure if that is possible. The other solution is to copy all data onto Disk2, partition Disk1, move data back to Disk1, and finally partition Disk2. The problem is that I am pretty new to Linux and I don't really know how to do it. I have access to the fdisk utility and the parted utility.

share|improve this question

migrated from stackoverflow.com Oct 28 '11 at 2:08

This question came from our site for professional and enthusiast programmers.

marked as duplicate by sysadmin1138 Nov 17 '11 at 21:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

This almost certainly can be done, but one biggie is the need to know what filesystem you're dealing with. Please report back with that -- it'll be shown by way of the "mount" command, and will dictate what approach/utility is to be used.

share|improve this answer
    
The file system is ext3. There is also proc, sysfs, devpts, and nfsd, but I think that none of those matter because they are mounted on /sys and /proc –  Grav3mind Oct 27 '11 at 17:40
1  
Okay; ext3 should be a no-brainer. Honestly, probably the easiest way to go about this is to download a live CD (I know the Ubuntu one will do the job), and fire up "gparted", a partition editor/resizer akin to Partition Magic. You simply boot your system to the CD, run gparted, and change both the partition size, as well as the filesystem size. (One sits atop the other; they both need to be modified.) I've had trouble with gparted supporting some filesystems in the past (e.g., xfs), but ext3 is fully supported. –  ravenpi Oct 27 '11 at 17:46
    
@user1016991 : Welcome to stackoverflow and thanks for particpating right out of the box with an answer. Unfortunately your response would normally be considered a comment, as you are looking to clarify with the OP information that you need to help solve the problem. In the future, please post a comment and encourage the OP to edit their original question with the info you need. Thanks and good luck to all! ;-) –  shellter Oct 27 '11 at 17:51
    
Yes I think that it would be simple to do that, however this is going to be applied to hundreds of machines so it needs to be scripted. It's not really the scripting that I need help with, I can figure out syntax. The problem is that I need to do it without losing data. I also have make2fs on all of these system as well. –  Grav3mind Oct 27 '11 at 17:52
    
@shellter since he is new and only has 1 rep point he cant post comments. i myself stumbled uppon that problem a few days ago –  weberik Oct 27 '11 at 22:21

The safest and fastest way of dealing with the task is to format the unused 500 as a separate partition, then edit /etc/fstab and changing the mounting point of some of the directories to the new partition.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.