1

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.

Grav3mind
  • 9
  • 1

2 Answers2

1

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.

  • 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 –  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. –  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. –  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 –  Oct 27 '11 at 22:21
  • @weberik : thanks for the reminder! Good luck to all. – shellter Oct 27 '11 at 22:53
1

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.