LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Making a drive image (https://www.linuxquestions.org/questions/linux-general-1/making-a-drive-image-274076/)

pcdude 01-05-2005 05:30 AM

Making a drive image
 
Hi

At our company we have a mandrake system (9.1) which originally only had a 40 GB hardrive. Later we bough a another 80GB drive.

Problem is that the 40GB with the / and home partitions is now getting rather full. The 80BG drive contains mostly backups. What I would like to do is to swap the contents of the drives around. That is putting the / and home directorties on the 80GB and put backups on the 40GB.
So I guess I'll need to make an image of the drive and place that image on the 80GB drive.

First of all, I would like to know if this is possible and safe?
Second, what tools can be used to do this?

Thanks in advance

rjlee 01-05-2005 06:15 AM

This is possible and (at least theoretically) safe.

You will need to look closely at the partitions of both drives. This is something that must be done on a partition-by-partition basis, not a drive-by-drive basis.

First of all, create a rescue disk and make sure that you can boot into it.

Next, I would recommend finding out how to reinstall your bootloader; this is something that you will need to do after moving partitions around so it's probably easiest to do it first. For lilo this is as simple as typing
Code:

/sbin/lilo
Now boot off the rescue disk; you can't create a reliable image of a partition if it's already mounted, and you get various problems if things like the active /sbin/ directory suddenly moves. So you don't want to do this on a live system.

Take a backup of your system, in case you delete something you shouldn't.

gnuparted would be a useful program here, as it lets you resize and copy partitions without deleting their contents. Use this rather than fdisk.

To create an image of a partition, you can use
Code:

cat /dev/device | bzip2 > image.bz2
You can then restore that image onto another partition of the same size using
Code:

bzcat image.bz2 > /dev/device
You can also copy files using
Code:

cp -dprx /path-from /path-to
Linux doesn't have any special immovable files like Windows does, so this will always work. It's a good way to copy a partition's contents to a bigger or smaller directory. The x flag means to stay on one partition.

After changing the partitions around, you will need to update the /etc/fstab file to point to the new locations of each mount-point.

I would advice making a written plan of how you want to do this before you start in case you end up overwriting something you shouldn't.

You will probably have at least one swap partition; this can be safely deleted. You can create a new swap partition using
Code:

mkswapfs /dev/device

pcdude 01-05-2005 06:23 AM

Thanks for your reply.

It seems that this is much easier than it would be on a windows box ;-)

I'll try it soon.
Cheers

Travers 01-05-2005 09:20 PM

Hm, I would wipe the 80 Gig, make a e3fs, copy everything over using rsync, write a new fstab and bootloader config, install the boot loader, and physically swap the drives, just incase something is pointing to /dev/hda when it is on /dev/hdb. This way you don't have to mess with any of the partions, which is really scary. Atleast you're not wiping the 40 gig so if you fsck up, you will be ok. =)


All times are GMT -5. The time now is 03:58 AM.