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.

On the same physical machine, the partitions of / and /home are both not large enough. I cannot extend the two partitions directly, since they are the last two partitions. I deleted the two partitions and allocated two larger partions.

Can I use cp to backup the two partitions and then recover them to the new / and /home? I use a USB disk to store and restore the backup file.

share|improve this question

migrated from stackoverflow.com Apr 21 '13 at 7:48

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

2  
Yes you can, but there are better backup utilities. –  Basile Starynkevitch Apr 21 '13 at 7:29
add comment

4 Answers 4

Yes you can do this.

If you wish to use cp, use the -R flag for recursive copy and -p to preserve file attributes (mode, ownership, timestamps)

share|improve this answer
add comment

Yes, you can but with a word of caution

  • Use -p (Otherwise permissions will mess things up)
  • Use -f for safety
  • You may require to update grub (sudo update-grub) to get things working after you copy stuff back. (This will be the case if you are using the backed up grub.cfg file for boot)

Alternative: You could use Disk Utilities like GParted (sudo apt-get install gparted) to move partitions too. Just empty some space before / & /home and ask GParted to extend backwards (Ref: GParted Manual Page)

share|improve this answer
add comment

I suggest to use a dedicated Live distro.

The tools that I usually use for these purposes are Gparted and Clonezilla, which are available both stand-alone or included in specialized distros like Parted Magic.

I suggest you to use the latter option because along Clonezilla and Gparted has a lot of other useful disk and system maintenance tools.

share|improve this answer
add comment

The filesystem on your USB drive should be a Unix filesystem so you'll keep all your files attribute (permissions, owner, group, ...).

Then the cp command has an --archive (-a) option which will preserve the attributes. Ideally, you can add the --one-file-system (-x) option so you won't backup other filesystems like /proc, /sys, or others.

shell# cp --archive --one-file-system /home <DESTINATION>
shell# cp --archive --one-file-system / <DESTINATION>

There you are. For restoration you'll do:

shell# cp --archive <ROOT_BACKUP>/* /
shell# cp --archive <HOME_BACKUP>/* /home 
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.