Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am getting a larger hard drive and would like to copy root directory to it. The partition for root is 20G. I would like to make it larger on the new drive. I also would like to copy /home to a larger partition on the new drive.

  1. Could I use dd to copy the partition or is there a better way to copy the partition?

  2. Should I format the new drive before copying the partition?

  3. What else will I need to do beside sudo update-grub to show I will be using the new drive?

  4. I know it subjective but I've found 20G a little low for a root partition if you add a lot of programs. Would 40G be large enough or would a larger partition be better?

share|improve this question
    
Are you exchanging drives or adding another one? And get a bootable livecd like systemrescuecd for the duration of the root transfer. http://www.sysresccd.org/Download –  Manwe Oct 10 '12 at 16:29
    
@Manwe Added a new one. Much larger. Thanks for the suggestion. I will try this. Partitioned only so far. –  Timothy Oct 11 '12 at 17:41
add comment

1 Answer 1

First let's partition the new drive. As it's going to be a second drive in the system we just set it up like we want. If you're unsure about size requirements of your partitions use LVM. (I'm not going to cover it here.) This will hopefully give you enough pointers to figure out what to do.

  1. Don't use dd unless you're making an identical copy of the old (let's say swapping disk to a faster, but of the same size). First partition new drive, then format the partition (for example ext4). Then the actual copy can be done with: tar -c --one-file-system -f - . | (cd /newPartitionMountPoint/; tar -xvf -)
  2. New drive: no, Using dd for partition: No, After parted: Yes (unless that formats the partition automatically)
  3. Well when you're change partitions that existed before, you also have to edit /etc/fstab use blkid to see new and old UUID + LABELS and change fstab accordingly. If you had /boot on separate partition on /dev/sda that's most of it.
  4. Partition size for root is subjective. I've actually never needed bigger than 20G root, but that means I have separate partitions for /var/lib (if database is needed), /data for my generic data needs and of course /home

Moving system around harddrives is easier in linux than in windows, but the most difficult move is moving '/' and '/boot'. I'd say a lot easier for you would be to check where you're using your space with: du -hsc /* Then create a partition for the largest folder (like /usr) /dev/sdb1 20G LABEL=myusr /dev/sdb2 100G LABEL=myhome

Then create usrtmp folder and sync old usr there: Please note that this is advanced stuff and might screw up your system even if everything worked ok. Basically, if you knew how to do this then go a head. If you did not know.. then I would not do this...

mkdir /usrtmp
mount LABEL=myusr  /usrtmp
cd /usr
tar -c --one-file-system -f - . | (cd /usrtmp/; tar -xvf -)
# this might be dangerous so I would do it with livecd myself..
# If you're feeling risky do this:
cd /
mv /usr /usr_old && mv /usrtmp /usr
## Now you can edit /etc/fstab to mount LABEL=myusr to /usr
## if you forget this but you did the mv then you won't be able to use your system
## Reboot, if everything is okay, you can remove /usr_old
## Repeat the same for home, but change labels accordingly
share|improve this answer
add comment

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.