3

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.

1
  • 2
    Yes you can, but there are better backup utilities. Apr 21, 2013 at 7:29

4 Answers 4

2

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)

2

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 
1
  • Do not restore on your current "/". Boot from a live distro, mount the local drive to "/mnt/local_driver", and restore there.
    – mike
    Nov 3, 2015 at 9:13
0

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)

1
  • gparted and other alternatives are nice, but cannot yet deal with btrfs , however.
    – ivo Welch
    Sep 1, 2014 at 22:30
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .