Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I installed Debian Squeeze on a 1.5 TB harddrive. But later found out that there is a smaller, 250 GB drive around here.

So, I need to move the installation (maybe around 40-50 GB in total) from bigger HD to a smaller one.

How this can be accomplished?

Thanks in advance!

share|improve this question
    
In short you just have to shrink you partition to a size inferior to your future drive and then use partimage/clonezilla to image the whole disk. After restoring it on the smaller drive you can expand the partition again if you will to fit exactly to the drive. –  Shadok May 11 '12 at 14:31
    
OK, I got your point. Can I do shrinking with gpartd? –  B.I. May 11 '12 at 15:15
    
Gparted supports shrinking partition, yes, but you have to make you filesystem supports it to as some of them don't (XFS and JFS for example), hopefully for you most of them do (ext2/3/4 ; reiserFS) –  Shadok May 14 '12 at 8:32

3 Answers 3

Shadok, thank you very much.

I did it. Below is short description.

There was 1500 GB drive with 60 GB data and 7GB swap. Quite regular setup, ext3 system Linux Debian Squeeze.

I wanted to swap this big drive to a 250 GB drive.

  1. I downloaded and burned The Parted Magic distro LiveCD. This distro contains Gparted (partition tool) and Clonezilla. Though I used only Gparted.
  2. Connected both drives and booted from LiveCD.
  3. Opened partition tool (Gparted) and shrinked the main partition on source drive from something 1500 GB to 100 GB. (It takes time). And there was swap partition, we will come back later.
  4. Deleted all partitions from destination (250 GB) drive.
  5. Copied and pasted data partition from source disk to destination disk. Applied changes.
  6. Created extended partition on destination. Just a little bigger than actual swap partition and aligned it to right.
  7. Moved swap from source to destination, into extended that partition, again with right alignment.
  8. Shrinked extended partition to fully contain swap, without empty space. Applied changes.
  9. Than enlarged main data partition from 100 GB to contain empty space of the disk. Applied changes.

So, basically, I just moved all partitions from drive to drive.

But then came problems with Master Boot Sector. Gparted didn't copy them. So:

  1. I found the original disk from which I installed this Debian 6 version and reloaded from it into rescue mode. At this point I already disconnected source hard drive. So when I loaded rescue mode, there was only destination disk present.
  2. There was an option of MBR repair. Entered into it.
  3. Assigned data partition as a root partition and then selected "repair" (or similar) option.

That's it.

share|improve this answer
    
No problem :) A detail: I think your post would be better as an edit of your question rather than as an answer, if you have doubt ask on the chat chat.stackexchange.com/rooms/118/root-access –  Shadok May 16 '12 at 15:48

You just have to shrink you partition to a size inferior to your future drive and then use partimage/clonezilla to image the whole disk.
After restoring it on the smaller drive you can expand the partition again if you will to fit exactly to the drive.

Gparted does support shrinking partition, but you have to make sure your filesystem itself supports it, as some of them don't: XFS and JFS for example.
Hopefully ext2/3/4 which are highly common support it.

ReiserFS can be shrunk too but note that it may take a few hours to complete, depending on the size of data to move to the beginning of the partition.

share|improve this answer
  1. Install the old and the new drive in the computer.
  2. Boot using Knoppix7 from a USB or CD drive.
  3. Go to preferences and start Gparted
  4. Create a partition table on the new drive
  5. Select the old drive
    • right click on the 1st partition
    • select copy
  6. Select new drive
    • select Paste on the empty partition
  7. Copy all your partitions excepted the swap that you will create.
  8. Use dd to copy the boot sector.

You are done!

share|improve this answer
    
How should the OP copy the boot sector with dd? –  BenjiWiebe Jun 11 at 0:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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