You clearly cannot clone a larger partition to a smaller partition (using dd
and the like) since there is simply not enough space.
However, if the files that are on the larger partition would also fit on the smaller partition, you could use rsync
to copy those files. The exact options to use depend on your particular use case, but to simply copy all the files the following should do:
rsync -av /mount/point/of/large/partition/ /mount/point/of/small/partition
Edit:
Once again: You cannot clone a larger partition onto a smaller partition. (But do read on, your problem can be solved yet.)
The reason is simple: your source partition is bigger than your target partition. What do you expect? Should some blocks just be dropped? Which ones? And how should dd
know? Of course, you could use dd
's bs=
and count=
options to only copy the first so-and-so-many blocks of your source partition such that it fits onto your target partition, but you will end up with a broken partition. That is certainly not what you want.
So, since you cannot clone a larger partition onto a smaller partition, the only thing you could do is to first reduce the size of your source partition to a size smaller or equal to that of your target partition with something like gparted
which is aware of the filesystem specifics, such that you do not lose data. And only then could you use dd
to clone the partition. Ideally, the new size of your source partition should be equal to the size of your target partition (and not just smaller or equal), or else you will end up with some unallocated space on your target partition after the cloning.
Please also note that you should not simply copy an MBR of a larger drive onto the MBR of a smaller drive (or vice versa, for that matter). The MBR, which has a size of 512 bytes and is the first section of your hard drive, contains information on the layout of the harddrive:
- 446 bytes - Bootstrap.
- 64 bytes - Partition table.
- 2 bytes - Signature.
(Note that 446+64+2=512
.)
If you insist on cloning the MBR, then only clone the first 446 bytes like so:
dd if=/dev/source of=/tmp/mbr.bak bs=512 count=1
dd if=/tmp/mbr.bak of=/dev/target bs=446 count=1
...replacing /dev/source
and /dev/target
with the device names of the source and target harddrives, e.g., /dev/sda
and /dev/sdb
, respectively. (More information is available here.)
However, the proper way to do it would be to do a clean Grub reinstall (or whatever you have on your MBR) on the new harddrive.
Summing up, if you want to clone a larger drive onto a smaller drive, proceed as follows:
Lay out a partition table on the target drive with as many partitions as on the source drive. There should be a one-to-one correspondence between the partitions on your source drive and the partitions on your target drive, except that (some of) the partitions on the target drive can be smaller than their corresponding partitions on the source drive. Use a tool such as fdisk
or cfdisk
for that.
For each partition on the target drive which is smaller than its corresponding partition on the source drive, reduce the size of this corresponding partition on the source drive to match the size of the partition on the target drive. Use a tool such as gparted
for that.
For each partition on the source drive, issue the command
dd if=/dev/sdaX of=/dev/sdbY
... to clone the partition /dev/sdaX
from the source drive to the corresponding partition /dev/sdbY
on the target drive (replace the device names appropriately, of course.)
If you insist on also cloning the MBR, use the two dd
commands written further above in this post (those with the /tmp/mbr.bak
stuff). However, keep in mind that a clean Grub re-install would be better.
Best Answer
In my case I not have enough space for my Ubuntu system drive which is I frequently use.
So I want more space and want to back up to avoid anything wrong with my data.But I not have any other storage device to backup.
First Step:- By using
![delete partition](https://i.stack.imgur.com/xTu9E.png)
second Step:- I restart Computer. And start
![dd command](https://i.stack.imgur.com/baO60.png)
Disk Utility
, I delete My Scientific Linux drive. For get extra 30 GB space. and make partition 53.GBBOSS Linux
.3rd Step:- RUN DD command into BOSS Linux to make clone of Ubuntu Drive.
Before restart PC I install
Then Start
![gparted utility](https://i.stack.imgur.com/QOYXm.png)
GRUB loder
intoBOSS Linux
.Ubuntu 14.04
then One problem occurred their. 53GB drive only shows 20GB space.Then I use
Gparted utility
to solve it. Again one problem occurred.solve it run command into terminal.
I try make
re-size
the drive and re-size successfully. After that I restart again my PC and start Ubuntu for check problem.Again start BOSS Linux to format old Ubuntu drive. Restart PC and select Ubuntu 14.04 and finally install Grub into Ubuntu.And it solve my problem without any other external or internal extra storage devices.
NOTE:- But its better and strongly recommend that keep back-up before do it.
You can be able do it by using Live CD or boot repair disk. For that I so much thankful of edward-torvalds and Helio without their valuable info, guidance, and reference it is impossible to solve it for me. Thanks.