LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using DD to transfer one partition to another different size partition (https://www.linuxquestions.org/questions/linux-newbie-8/using-dd-to-transfer-one-partition-to-another-different-size-partition-893430/)

zemir 07-24-2011 05:27 AM

Using DD to transfer one partition to another different size partition
 
Hi, i am newbie about this forum and i hope to stay with you for many time ;-)....... i have a problem, i think very common, but i am not able to find a right solution:
i have got an old computer with some partition and one have linux slackware installed; it is all included there (root and a swap file); its size is almost 4 gb. Now i have a new laptop and i do not really want to reinstall linux on it; simply i want to transfer all things from old on new computer. The size of new hd is almost 12 Gb and i want to use entire with linux slackware. I will recompile new kernel on old computer for the new. Now, i think to use dd to make one image, this follow command may be good, i think:
"dd if=/dev/hda3 of=./linux_slackaware.img bs=4096 conv=noerror"
I use zipslack on msdos partition (hda2) to run this command; it will make a 4 gb file image partition;
Now i ask you:
it is possible to transfer and to adapt this image partition on a different size image partition?
The new is 12 gb size.........what are the right dd command parametres?

tommylovell 07-24-2011 08:05 AM

Quote:

Originally Posted by zemir (Post 4423753)
it is possible to transfer and to adapt this image partition on a different size image partition?

Yes, I think it is possible to do this. Whether it is advisable is another question. (And I'm not sure I'd use 'conv=noerror'.)

Quote:

The new is 12 gb size.........what are the right dd command parametres?
You just want to do the reverse of your original 'dd' command.

You didn't say, so I'm assuming your filesystem is ext2/3/4; and I'm also assuming you have already partitioned the new laptop, and /dev/hda1 is the partition that is to receive the old filesystem. (If it's not hda, then it may be sda.)

Then this would work.
Code:

dd of=/dev/hda1 if=<correct_path_to>/linux_slackaware.img bs=4096
You'd now have a /dev/hda1 that showed 12GB in fdisk; and your filesystem would be reported as 4GB with 'df -h'.

To remedy this and grow the filesystem out to the size of the partition use 'resize2fs' (again assuming ext2/3/4).
Code:

resize2fs /dev/hda1
As others may report as well, copying a system installed on one system to another with dissimilar hardware may not be advisable. It may not work at all, depending on specialized drivers that may be required on the new machine. (I've had mixed results doing this in the past.)

And don't forget that once your filesystem is moved to the new machine you will have to write a bootloader to the MBR. (Being Slackware I think that still means lilo, not Grub.)

Good luck.

p.s. I think most people would use 'tar' to perform this task.

zemir 07-24-2011 12:58 PM

Thanks tommylovell
Quote:

Originally Posted by tommylovell (Post 4423813)
You didn't say, so I'm assuming your filesystem is ext2/3/4;

of course, it is ext2
Quote:

Originally Posted by tommylovell (Post 4423813)
You'd now have a /dev/hda1 that showed 12GB in fdisk; and your filesystem would be reported as 4GB with 'df -h'.

To remedy this and grow the filesystem out to the size of the partition use 'resize2fs' (again assuming ext2/3/4).
Code:

resize2fs /dev/hda1

I have not used very often "DD" and "Resize2fs" therefore i have asked about.

Quote:

Originally Posted by tommylovell (Post 4423813)
As others may report as well, copying a system installed on one system to another with dissimilar hardware may not be advisable. It may not work at all, depending on specialized drivers that may be required on the new machine. (I've had mixed results doing this in the past.)

It is a good choice, especially when you do not really want to reinstall a new system. I will recompile a monolitic kernel (2.4 version) in the old pc therefore i will install it in the new, no more drivers i will need.

Quote:

Originally Posted by tommylovell (Post 4423813)
And don't forget that once your filesystem is moved to the new machine you will have to write a bootloader to the MBR. (Being Slackware I think that still means lilo, not Grub.)

I will start the new sistem with loadlin from ms-dos startup usb pen therefore i will install lilo from the working new linux system. It is very simple.
Quote:

Originally Posted by tommylovell (Post 4423813)
Good luck.

Thanks!

markush 07-24-2011 02:04 PM

Hello zemir,

you can also use the tar command to create an archive of the whole Linux-system. Then create a filesystem on the new Laptop and extract the archive there. I would do both with a live-CD or USB.

Be aware that there you may expect difficulties with the hardware, for example the devicenodes in the /dev directory

Actually a complete new Slackware-installation is done within 10 Minutes. Could you please provide more information about the hardware of the new laptop.

Markus

zemir 07-24-2011 02:58 PM

Quote:

Originally Posted by markush (Post 4424037)
Hello zemir,

you can also use the tar command to create an archive of the whole Linux-system. Then create a filesystem on the new Laptop and extract the archive there. I would do both with a live-CD or USB.

Be aware that there you may expect difficulties with the hardware, for example the devicenodes in the /dev directory

Actually a complete new Slackware-installation is done within 10 Minutes. Could you please provide more information about the hardware of the new laptop.

Markus

Hi Markush and thanks. 10 minutes to install but i think more, very more, to change the scripts, files config, home files, etc.... and much more things. I have a very minimal system that does not occupies than 250/300 mb and to make another time the same result i do not really want. About devices, i think to remove or to make them; in the case i will have problems, quickly i will inform you. I will try the "dd" way and the "tar" way then i will inform you about, in august, i think.
However, thanks!

markush 07-24-2011 03:17 PM

Quote:

Originally Posted by zemir (Post 4424069)
...10 minutes to install but i think more, very more, to change the scripts, files config, home files, etc.... and much more things.

No, this isn't the case, nowadays (with Slackware 13.37) with Slackware everything works out of the box. If you're not very experienced, you will have less difficulties with a new installation on a new computer.

Markus

zemir 07-25-2011 04:18 AM

Quote:

Originally Posted by markush (Post 4424079)
No, this isn't the case, nowadays (with Slackware 13.37) with Slackware everything works out of the box. If you're not very experienced, you will have less difficulties with a new installation on a new computer.

Markus

I am not very expert but i am not newbie about slackware, too; then i know what i do; i have not a slackware standard release, i install and upgrade only my necessary package; in some cases i do not install standard packages and i prefer to install binaries or recompile sources. I have changed some shell scripts. My system is unique. The two computers (the old and the new) are very similar. However in case of problem, i will inform you.
Thanks again!

zemir 07-30-2011 06:46 AM

Solved with TAR........


All times are GMT -5. The time now is 04:48 PM.