lubuntu 18.10 x64 installed on USB stick clone to usb stick 2
up vote
1
down vote
favorite
Help!
Creating clone from a cosmic installed bootable USB stick;
I have a working running USB stick with lubuntu 18.10 cosmic on it. I installed the stick by a normal lubuntu 18.10 .iso.
Now I learned, or always understood that cloning a linux system is easy. Today and yesterday I learned in practical experience it is not. Result is a not working 2th usb stick and even partition manager doesn't like it.
What I do:
How do I use dd to clone an external USB drive installation to a local hard disk?
I use that syntax of the dd command to clone my working linux installed bootable usb stick to another usb stick. I do this by using a third lubuntu installation. In other words, I do not try to backup an active running lubuntu session itself.
Yesterday I tried backingup from the running system , it didn't work. Than I found topics stating that this method doesn't result in a readable usb clone, so today I decided to use usb stick number 3 which is starting an external Linux system so I can clone usb stick1 to usb stick number 2.
Complex? Maybe, but I wanted to be sure everything is tested out. And using this context:
sudo dd if=/dev/sdx of=/dev/sdy bs=8M && sync
Doesn't work at all.
Result: It creates a clone usb stick.
Whne I try to run it, the grub comes up, I can select lubuntu, I see it starting ,the . . . . dots come on the screen which creates hope. Than The system falls back in a initdos or puppydos prompt (or whatever it is called,) I tried to do a fsck command on the patition, rebooting, didn't work.
In fact it seems to hang on a video driver or something. But how is that possible if the system is supposed to be an exact clone of the working usb?
I can run mc midnight commander, when I type it in the prompt screen (I installed mc before backing up at the system of the original usb stick).
To complete my story I must add, that I also tried to dd backup first to the internal harddrive, before restoring it on usb stick 2. Didn't work either.....
Would there by anybody out there, whom found a way to do what I want to do for a lubuntu cosmic 18.10 USB running sytem?....
I know there are tools like clonezilla and stuff, but doing what I tried should work. Why doesn't it?
Does dd only work when you restore the backup on the same usb stick? (note that both usb devices I used are not of the same brand, but have the same size, 32gb....)
Some help required.
Thanks!
update: i forgot to mention 2 more things:
1.On the USB stick wih my working install, I have 2 partitions. A ext4 / system partition and a small 6 gb NTFS partition I use for sharing files.
I tried dd if=dev/sdd and if=dev/sdd1 , same end result.
2.The installation of the original usb stick is based on a UEFI partition table! The bios in my laptop is set on UEFI as well. Just in case it is important...
lubuntu 18.10 dd clone usb-installation
add a comment |
up vote
1
down vote
favorite
Help!
Creating clone from a cosmic installed bootable USB stick;
I have a working running USB stick with lubuntu 18.10 cosmic on it. I installed the stick by a normal lubuntu 18.10 .iso.
Now I learned, or always understood that cloning a linux system is easy. Today and yesterday I learned in practical experience it is not. Result is a not working 2th usb stick and even partition manager doesn't like it.
What I do:
How do I use dd to clone an external USB drive installation to a local hard disk?
I use that syntax of the dd command to clone my working linux installed bootable usb stick to another usb stick. I do this by using a third lubuntu installation. In other words, I do not try to backup an active running lubuntu session itself.
Yesterday I tried backingup from the running system , it didn't work. Than I found topics stating that this method doesn't result in a readable usb clone, so today I decided to use usb stick number 3 which is starting an external Linux system so I can clone usb stick1 to usb stick number 2.
Complex? Maybe, but I wanted to be sure everything is tested out. And using this context:
sudo dd if=/dev/sdx of=/dev/sdy bs=8M && sync
Doesn't work at all.
Result: It creates a clone usb stick.
Whne I try to run it, the grub comes up, I can select lubuntu, I see it starting ,the . . . . dots come on the screen which creates hope. Than The system falls back in a initdos or puppydos prompt (or whatever it is called,) I tried to do a fsck command on the patition, rebooting, didn't work.
In fact it seems to hang on a video driver or something. But how is that possible if the system is supposed to be an exact clone of the working usb?
I can run mc midnight commander, when I type it in the prompt screen (I installed mc before backing up at the system of the original usb stick).
To complete my story I must add, that I also tried to dd backup first to the internal harddrive, before restoring it on usb stick 2. Didn't work either.....
Would there by anybody out there, whom found a way to do what I want to do for a lubuntu cosmic 18.10 USB running sytem?....
I know there are tools like clonezilla and stuff, but doing what I tried should work. Why doesn't it?
Does dd only work when you restore the backup on the same usb stick? (note that both usb devices I used are not of the same brand, but have the same size, 32gb....)
Some help required.
Thanks!
update: i forgot to mention 2 more things:
1.On the USB stick wih my working install, I have 2 partitions. A ext4 / system partition and a small 6 gb NTFS partition I use for sharing files.
I tried dd if=dev/sdd and if=dev/sdd1 , same end result.
2.The installation of the original usb stick is based on a UEFI partition table! The bios in my laptop is set on UEFI as well. Just in case it is important...
lubuntu 18.10 dd clone usb-installation
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Help!
Creating clone from a cosmic installed bootable USB stick;
I have a working running USB stick with lubuntu 18.10 cosmic on it. I installed the stick by a normal lubuntu 18.10 .iso.
Now I learned, or always understood that cloning a linux system is easy. Today and yesterday I learned in practical experience it is not. Result is a not working 2th usb stick and even partition manager doesn't like it.
What I do:
How do I use dd to clone an external USB drive installation to a local hard disk?
I use that syntax of the dd command to clone my working linux installed bootable usb stick to another usb stick. I do this by using a third lubuntu installation. In other words, I do not try to backup an active running lubuntu session itself.
Yesterday I tried backingup from the running system , it didn't work. Than I found topics stating that this method doesn't result in a readable usb clone, so today I decided to use usb stick number 3 which is starting an external Linux system so I can clone usb stick1 to usb stick number 2.
Complex? Maybe, but I wanted to be sure everything is tested out. And using this context:
sudo dd if=/dev/sdx of=/dev/sdy bs=8M && sync
Doesn't work at all.
Result: It creates a clone usb stick.
Whne I try to run it, the grub comes up, I can select lubuntu, I see it starting ,the . . . . dots come on the screen which creates hope. Than The system falls back in a initdos or puppydos prompt (or whatever it is called,) I tried to do a fsck command on the patition, rebooting, didn't work.
In fact it seems to hang on a video driver or something. But how is that possible if the system is supposed to be an exact clone of the working usb?
I can run mc midnight commander, when I type it in the prompt screen (I installed mc before backing up at the system of the original usb stick).
To complete my story I must add, that I also tried to dd backup first to the internal harddrive, before restoring it on usb stick 2. Didn't work either.....
Would there by anybody out there, whom found a way to do what I want to do for a lubuntu cosmic 18.10 USB running sytem?....
I know there are tools like clonezilla and stuff, but doing what I tried should work. Why doesn't it?
Does dd only work when you restore the backup on the same usb stick? (note that both usb devices I used are not of the same brand, but have the same size, 32gb....)
Some help required.
Thanks!
update: i forgot to mention 2 more things:
1.On the USB stick wih my working install, I have 2 partitions. A ext4 / system partition and a small 6 gb NTFS partition I use for sharing files.
I tried dd if=dev/sdd and if=dev/sdd1 , same end result.
2.The installation of the original usb stick is based on a UEFI partition table! The bios in my laptop is set on UEFI as well. Just in case it is important...
lubuntu 18.10 dd clone usb-installation
Help!
Creating clone from a cosmic installed bootable USB stick;
I have a working running USB stick with lubuntu 18.10 cosmic on it. I installed the stick by a normal lubuntu 18.10 .iso.
Now I learned, or always understood that cloning a linux system is easy. Today and yesterday I learned in practical experience it is not. Result is a not working 2th usb stick and even partition manager doesn't like it.
What I do:
How do I use dd to clone an external USB drive installation to a local hard disk?
I use that syntax of the dd command to clone my working linux installed bootable usb stick to another usb stick. I do this by using a third lubuntu installation. In other words, I do not try to backup an active running lubuntu session itself.
Yesterday I tried backingup from the running system , it didn't work. Than I found topics stating that this method doesn't result in a readable usb clone, so today I decided to use usb stick number 3 which is starting an external Linux system so I can clone usb stick1 to usb stick number 2.
Complex? Maybe, but I wanted to be sure everything is tested out. And using this context:
sudo dd if=/dev/sdx of=/dev/sdy bs=8M && sync
Doesn't work at all.
Result: It creates a clone usb stick.
Whne I try to run it, the grub comes up, I can select lubuntu, I see it starting ,the . . . . dots come on the screen which creates hope. Than The system falls back in a initdos or puppydos prompt (or whatever it is called,) I tried to do a fsck command on the patition, rebooting, didn't work.
In fact it seems to hang on a video driver or something. But how is that possible if the system is supposed to be an exact clone of the working usb?
I can run mc midnight commander, when I type it in the prompt screen (I installed mc before backing up at the system of the original usb stick).
To complete my story I must add, that I also tried to dd backup first to the internal harddrive, before restoring it on usb stick 2. Didn't work either.....
Would there by anybody out there, whom found a way to do what I want to do for a lubuntu cosmic 18.10 USB running sytem?....
I know there are tools like clonezilla and stuff, but doing what I tried should work. Why doesn't it?
Does dd only work when you restore the backup on the same usb stick? (note that both usb devices I used are not of the same brand, but have the same size, 32gb....)
Some help required.
Thanks!
update: i forgot to mention 2 more things:
1.On the USB stick wih my working install, I have 2 partitions. A ext4 / system partition and a small 6 gb NTFS partition I use for sharing files.
I tried dd if=dev/sdd and if=dev/sdd1 , same end result.
2.The installation of the original usb stick is based on a UEFI partition table! The bios in my laptop is set on UEFI as well. Just in case it is important...
lubuntu 18.10 dd clone usb-installation
lubuntu 18.10 dd clone usb-installation
edited Dec 1 at 18:26
asked Dec 1 at 14:36
leeuwtje
215
215
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Cloning from one drive to another drive
What you describe in your question works in general.
sudo dd if=/dev/sdx of=/dev/sdy bs=4096 && sync
I have done it successfully with USB pendrives as well as with HDDs and SSDs.
But there are several things that can make it go wrong.
The target drive must be at least as big as the source drive. Not one single byte smaller. It is not enough that the drives have the same nominal size, for example 16 GB. You can check with
sudo parted /dev/sdx u b p
sudo parted /dev/sdy u b p
where
x
andy
should be replaced with the device letters for the source and target drives, andu b
makes the output in bytes andp
tellsparted
to print (to standard output).
If there is a GUID partition table, GPT, (and not an old style MSDOS partition table), and the drives have not exactly the same size, you must repair the backup partition table at the tail end of the drive. The previous command lines with
parted
will also show the partition table. You can usegdisk
for this repair job.If the physical sector sizes are different between the source and target drives, there will also be problems. Small and old drives have usually 512 bytes physical sectors, but some new drives (medium size and huge size) sometimes have 4096 bytes physical sectors. This can cause problems after cloning, and it is probably better the install a fresh system in the new drive and transfer the files, that you want into the new drive (copy on the file level instead of cloning on the drive level). The previous command lines with
parted
will also show the physical sector size.Both the source drive and the target drive must be healthy. If there is a bad sector (physical sector), the corresponding data cannot be transferred for that particular location, and it may cause a problem (big or small, depending on what is stored in that location).
Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file in order to clone from a drive with an installed Lubuntu system to some other drive.
No partition on the source drive and the target drive should be mounted. Unmount if some partition is mounted.
sudo umount /dev/sdxn
where
x
is the device letter andn
is the partition number.
Cloning with
dd
is risky, because it does what you tell it to do without any questions. A minor typing error is enough to make it overwrite the family pictures. For this reason it is better to use a tool which helps you identify the target drive and has a final checkpoint, where you can double-check that things will go right.
- in Linux you can use Disks alias
gnome-disks
or mkusb
- in Windows you can use Win32 Disk Imager.
- in Linux you can use Disks alias
You can also clone with Clonezilla. Boot a USB pendrive or DVD disk made from a stable
clonezilla.iso
file. This is safer thandd
because of several checkpoints and questions, and faster because Clonezilla is smart enough to only copy used blocks (and skip free blocks) of the file systems. This makes a big difference if a file system is far from full.And last but not least, you must let the process finish properly and let the system flush the buffers to the target drive. This is why it is important to run
sync
and wait until it finishes, and the terminal window returns to prompt.
Cloning via an image file
- What is described here is also relevant if you clone in an indirect way by creating an image file from the source drive and restore from the image file to the target drive.
After the cloning, connect only one drive to the computer
If there are writable file systems, you must not boot a computer with both the source and target (of the cloning) connected. These drives have identical data, and there will probably be confusion, which can destroy one or both of the drives.
So boot into either the original (source) drive or into the cloned copy (target) drive, and keep the other drive disconnected (unplugged).
Wow, thanks sudodus, for spending so much time for a technical deep explanation of what actually is happening in the dd process and a collection of problems that can occur cloning usb sticks with it. Ok. I will see what I can do with mkusb to get what I wanted. Could you describe the exact steps in the terminal prompt for the mkusb route with sync?
– leeuwtje
Dec 2 at 14:13
One more thing, about the different kind of usb drives where you refer to old and new drives. Would this also give problems in case of trying to clone a compact flash card to an new usb stick?
– leeuwtje
Dec 2 at 14:16
0. Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file, identify the source drive (for example withsudo lsblk -f
andsudo lsblk -m
); 1. Install mkusb according to the link in my answer; 2.Start mkusb-dus from the menu in Lubuntu or from the command line in a terminal windowdus <source device>
for exampledus /dev/sdx
where/dev/sdx
is the source drive. mkusb (dus) will help you identify the target drive and runsync
etc automatically.
– sudodus
Dec 2 at 15:19
3. I think it will work to clone from a compact flash card to an new usb stick.
– sudodus
Dec 2 at 15:31
1
@sudodus you don't need to "Indent each line 4 spaces in order to render the output as 'code'". Just paste in the text, select that text, then hit the{}
icon which will format it into human-readable text. If you have "preview" enabled, you can see how your question/answer will look to others.
– heynnema
Dec 4 at 14:50
|
show 8 more comments
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1097683%2flubuntu-18-10-x64-installed-on-usb-stick-clone-to-usb-stick-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Cloning from one drive to another drive
What you describe in your question works in general.
sudo dd if=/dev/sdx of=/dev/sdy bs=4096 && sync
I have done it successfully with USB pendrives as well as with HDDs and SSDs.
But there are several things that can make it go wrong.
The target drive must be at least as big as the source drive. Not one single byte smaller. It is not enough that the drives have the same nominal size, for example 16 GB. You can check with
sudo parted /dev/sdx u b p
sudo parted /dev/sdy u b p
where
x
andy
should be replaced with the device letters for the source and target drives, andu b
makes the output in bytes andp
tellsparted
to print (to standard output).
If there is a GUID partition table, GPT, (and not an old style MSDOS partition table), and the drives have not exactly the same size, you must repair the backup partition table at the tail end of the drive. The previous command lines with
parted
will also show the partition table. You can usegdisk
for this repair job.If the physical sector sizes are different between the source and target drives, there will also be problems. Small and old drives have usually 512 bytes physical sectors, but some new drives (medium size and huge size) sometimes have 4096 bytes physical sectors. This can cause problems after cloning, and it is probably better the install a fresh system in the new drive and transfer the files, that you want into the new drive (copy on the file level instead of cloning on the drive level). The previous command lines with
parted
will also show the physical sector size.Both the source drive and the target drive must be healthy. If there is a bad sector (physical sector), the corresponding data cannot be transferred for that particular location, and it may cause a problem (big or small, depending on what is stored in that location).
Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file in order to clone from a drive with an installed Lubuntu system to some other drive.
No partition on the source drive and the target drive should be mounted. Unmount if some partition is mounted.
sudo umount /dev/sdxn
where
x
is the device letter andn
is the partition number.
Cloning with
dd
is risky, because it does what you tell it to do without any questions. A minor typing error is enough to make it overwrite the family pictures. For this reason it is better to use a tool which helps you identify the target drive and has a final checkpoint, where you can double-check that things will go right.
- in Linux you can use Disks alias
gnome-disks
or mkusb
- in Windows you can use Win32 Disk Imager.
- in Linux you can use Disks alias
You can also clone with Clonezilla. Boot a USB pendrive or DVD disk made from a stable
clonezilla.iso
file. This is safer thandd
because of several checkpoints and questions, and faster because Clonezilla is smart enough to only copy used blocks (and skip free blocks) of the file systems. This makes a big difference if a file system is far from full.And last but not least, you must let the process finish properly and let the system flush the buffers to the target drive. This is why it is important to run
sync
and wait until it finishes, and the terminal window returns to prompt.
Cloning via an image file
- What is described here is also relevant if you clone in an indirect way by creating an image file from the source drive and restore from the image file to the target drive.
After the cloning, connect only one drive to the computer
If there are writable file systems, you must not boot a computer with both the source and target (of the cloning) connected. These drives have identical data, and there will probably be confusion, which can destroy one or both of the drives.
So boot into either the original (source) drive or into the cloned copy (target) drive, and keep the other drive disconnected (unplugged).
Wow, thanks sudodus, for spending so much time for a technical deep explanation of what actually is happening in the dd process and a collection of problems that can occur cloning usb sticks with it. Ok. I will see what I can do with mkusb to get what I wanted. Could you describe the exact steps in the terminal prompt for the mkusb route with sync?
– leeuwtje
Dec 2 at 14:13
One more thing, about the different kind of usb drives where you refer to old and new drives. Would this also give problems in case of trying to clone a compact flash card to an new usb stick?
– leeuwtje
Dec 2 at 14:16
0. Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file, identify the source drive (for example withsudo lsblk -f
andsudo lsblk -m
); 1. Install mkusb according to the link in my answer; 2.Start mkusb-dus from the menu in Lubuntu or from the command line in a terminal windowdus <source device>
for exampledus /dev/sdx
where/dev/sdx
is the source drive. mkusb (dus) will help you identify the target drive and runsync
etc automatically.
– sudodus
Dec 2 at 15:19
3. I think it will work to clone from a compact flash card to an new usb stick.
– sudodus
Dec 2 at 15:31
1
@sudodus you don't need to "Indent each line 4 spaces in order to render the output as 'code'". Just paste in the text, select that text, then hit the{}
icon which will format it into human-readable text. If you have "preview" enabled, you can see how your question/answer will look to others.
– heynnema
Dec 4 at 14:50
|
show 8 more comments
up vote
1
down vote
Cloning from one drive to another drive
What you describe in your question works in general.
sudo dd if=/dev/sdx of=/dev/sdy bs=4096 && sync
I have done it successfully with USB pendrives as well as with HDDs and SSDs.
But there are several things that can make it go wrong.
The target drive must be at least as big as the source drive. Not one single byte smaller. It is not enough that the drives have the same nominal size, for example 16 GB. You can check with
sudo parted /dev/sdx u b p
sudo parted /dev/sdy u b p
where
x
andy
should be replaced with the device letters for the source and target drives, andu b
makes the output in bytes andp
tellsparted
to print (to standard output).
If there is a GUID partition table, GPT, (and not an old style MSDOS partition table), and the drives have not exactly the same size, you must repair the backup partition table at the tail end of the drive. The previous command lines with
parted
will also show the partition table. You can usegdisk
for this repair job.If the physical sector sizes are different between the source and target drives, there will also be problems. Small and old drives have usually 512 bytes physical sectors, but some new drives (medium size and huge size) sometimes have 4096 bytes physical sectors. This can cause problems after cloning, and it is probably better the install a fresh system in the new drive and transfer the files, that you want into the new drive (copy on the file level instead of cloning on the drive level). The previous command lines with
parted
will also show the physical sector size.Both the source drive and the target drive must be healthy. If there is a bad sector (physical sector), the corresponding data cannot be transferred for that particular location, and it may cause a problem (big or small, depending on what is stored in that location).
Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file in order to clone from a drive with an installed Lubuntu system to some other drive.
No partition on the source drive and the target drive should be mounted. Unmount if some partition is mounted.
sudo umount /dev/sdxn
where
x
is the device letter andn
is the partition number.
Cloning with
dd
is risky, because it does what you tell it to do without any questions. A minor typing error is enough to make it overwrite the family pictures. For this reason it is better to use a tool which helps you identify the target drive and has a final checkpoint, where you can double-check that things will go right.
- in Linux you can use Disks alias
gnome-disks
or mkusb
- in Windows you can use Win32 Disk Imager.
- in Linux you can use Disks alias
You can also clone with Clonezilla. Boot a USB pendrive or DVD disk made from a stable
clonezilla.iso
file. This is safer thandd
because of several checkpoints and questions, and faster because Clonezilla is smart enough to only copy used blocks (and skip free blocks) of the file systems. This makes a big difference if a file system is far from full.And last but not least, you must let the process finish properly and let the system flush the buffers to the target drive. This is why it is important to run
sync
and wait until it finishes, and the terminal window returns to prompt.
Cloning via an image file
- What is described here is also relevant if you clone in an indirect way by creating an image file from the source drive and restore from the image file to the target drive.
After the cloning, connect only one drive to the computer
If there are writable file systems, you must not boot a computer with both the source and target (of the cloning) connected. These drives have identical data, and there will probably be confusion, which can destroy one or both of the drives.
So boot into either the original (source) drive or into the cloned copy (target) drive, and keep the other drive disconnected (unplugged).
Wow, thanks sudodus, for spending so much time for a technical deep explanation of what actually is happening in the dd process and a collection of problems that can occur cloning usb sticks with it. Ok. I will see what I can do with mkusb to get what I wanted. Could you describe the exact steps in the terminal prompt for the mkusb route with sync?
– leeuwtje
Dec 2 at 14:13
One more thing, about the different kind of usb drives where you refer to old and new drives. Would this also give problems in case of trying to clone a compact flash card to an new usb stick?
– leeuwtje
Dec 2 at 14:16
0. Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file, identify the source drive (for example withsudo lsblk -f
andsudo lsblk -m
); 1. Install mkusb according to the link in my answer; 2.Start mkusb-dus from the menu in Lubuntu or from the command line in a terminal windowdus <source device>
for exampledus /dev/sdx
where/dev/sdx
is the source drive. mkusb (dus) will help you identify the target drive and runsync
etc automatically.
– sudodus
Dec 2 at 15:19
3. I think it will work to clone from a compact flash card to an new usb stick.
– sudodus
Dec 2 at 15:31
1
@sudodus you don't need to "Indent each line 4 spaces in order to render the output as 'code'". Just paste in the text, select that text, then hit the{}
icon which will format it into human-readable text. If you have "preview" enabled, you can see how your question/answer will look to others.
– heynnema
Dec 4 at 14:50
|
show 8 more comments
up vote
1
down vote
up vote
1
down vote
Cloning from one drive to another drive
What you describe in your question works in general.
sudo dd if=/dev/sdx of=/dev/sdy bs=4096 && sync
I have done it successfully with USB pendrives as well as with HDDs and SSDs.
But there are several things that can make it go wrong.
The target drive must be at least as big as the source drive. Not one single byte smaller. It is not enough that the drives have the same nominal size, for example 16 GB. You can check with
sudo parted /dev/sdx u b p
sudo parted /dev/sdy u b p
where
x
andy
should be replaced with the device letters for the source and target drives, andu b
makes the output in bytes andp
tellsparted
to print (to standard output).
If there is a GUID partition table, GPT, (and not an old style MSDOS partition table), and the drives have not exactly the same size, you must repair the backup partition table at the tail end of the drive. The previous command lines with
parted
will also show the partition table. You can usegdisk
for this repair job.If the physical sector sizes are different between the source and target drives, there will also be problems. Small and old drives have usually 512 bytes physical sectors, but some new drives (medium size and huge size) sometimes have 4096 bytes physical sectors. This can cause problems after cloning, and it is probably better the install a fresh system in the new drive and transfer the files, that you want into the new drive (copy on the file level instead of cloning on the drive level). The previous command lines with
parted
will also show the physical sector size.Both the source drive and the target drive must be healthy. If there is a bad sector (physical sector), the corresponding data cannot be transferred for that particular location, and it may cause a problem (big or small, depending on what is stored in that location).
Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file in order to clone from a drive with an installed Lubuntu system to some other drive.
No partition on the source drive and the target drive should be mounted. Unmount if some partition is mounted.
sudo umount /dev/sdxn
where
x
is the device letter andn
is the partition number.
Cloning with
dd
is risky, because it does what you tell it to do without any questions. A minor typing error is enough to make it overwrite the family pictures. For this reason it is better to use a tool which helps you identify the target drive and has a final checkpoint, where you can double-check that things will go right.
- in Linux you can use Disks alias
gnome-disks
or mkusb
- in Windows you can use Win32 Disk Imager.
- in Linux you can use Disks alias
You can also clone with Clonezilla. Boot a USB pendrive or DVD disk made from a stable
clonezilla.iso
file. This is safer thandd
because of several checkpoints and questions, and faster because Clonezilla is smart enough to only copy used blocks (and skip free blocks) of the file systems. This makes a big difference if a file system is far from full.And last but not least, you must let the process finish properly and let the system flush the buffers to the target drive. This is why it is important to run
sync
and wait until it finishes, and the terminal window returns to prompt.
Cloning via an image file
- What is described here is also relevant if you clone in an indirect way by creating an image file from the source drive and restore from the image file to the target drive.
After the cloning, connect only one drive to the computer
If there are writable file systems, you must not boot a computer with both the source and target (of the cloning) connected. These drives have identical data, and there will probably be confusion, which can destroy one or both of the drives.
So boot into either the original (source) drive or into the cloned copy (target) drive, and keep the other drive disconnected (unplugged).
Cloning from one drive to another drive
What you describe in your question works in general.
sudo dd if=/dev/sdx of=/dev/sdy bs=4096 && sync
I have done it successfully with USB pendrives as well as with HDDs and SSDs.
But there are several things that can make it go wrong.
The target drive must be at least as big as the source drive. Not one single byte smaller. It is not enough that the drives have the same nominal size, for example 16 GB. You can check with
sudo parted /dev/sdx u b p
sudo parted /dev/sdy u b p
where
x
andy
should be replaced with the device letters for the source and target drives, andu b
makes the output in bytes andp
tellsparted
to print (to standard output).
If there is a GUID partition table, GPT, (and not an old style MSDOS partition table), and the drives have not exactly the same size, you must repair the backup partition table at the tail end of the drive. The previous command lines with
parted
will also show the partition table. You can usegdisk
for this repair job.If the physical sector sizes are different between the source and target drives, there will also be problems. Small and old drives have usually 512 bytes physical sectors, but some new drives (medium size and huge size) sometimes have 4096 bytes physical sectors. This can cause problems after cloning, and it is probably better the install a fresh system in the new drive and transfer the files, that you want into the new drive (copy on the file level instead of cloning on the drive level). The previous command lines with
parted
will also show the physical sector size.Both the source drive and the target drive must be healthy. If there is a bad sector (physical sector), the corresponding data cannot be transferred for that particular location, and it may cause a problem (big or small, depending on what is stored in that location).
Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file in order to clone from a drive with an installed Lubuntu system to some other drive.
No partition on the source drive and the target drive should be mounted. Unmount if some partition is mounted.
sudo umount /dev/sdxn
where
x
is the device letter andn
is the partition number.
Cloning with
dd
is risky, because it does what you tell it to do without any questions. A minor typing error is enough to make it overwrite the family pictures. For this reason it is better to use a tool which helps you identify the target drive and has a final checkpoint, where you can double-check that things will go right.
- in Linux you can use Disks alias
gnome-disks
or mkusb
- in Windows you can use Win32 Disk Imager.
- in Linux you can use Disks alias
You can also clone with Clonezilla. Boot a USB pendrive or DVD disk made from a stable
clonezilla.iso
file. This is safer thandd
because of several checkpoints and questions, and faster because Clonezilla is smart enough to only copy used blocks (and skip free blocks) of the file systems. This makes a big difference if a file system is far from full.And last but not least, you must let the process finish properly and let the system flush the buffers to the target drive. This is why it is important to run
sync
and wait until it finishes, and the terminal window returns to prompt.
Cloning via an image file
- What is described here is also relevant if you clone in an indirect way by creating an image file from the source drive and restore from the image file to the target drive.
After the cloning, connect only one drive to the computer
If there are writable file systems, you must not boot a computer with both the source and target (of the cloning) connected. These drives have identical data, and there will probably be confusion, which can destroy one or both of the drives.
So boot into either the original (source) drive or into the cloned copy (target) drive, and keep the other drive disconnected (unplugged).
edited Dec 4 at 13:19
answered Dec 1 at 19:34
sudodus
22.3k32872
22.3k32872
Wow, thanks sudodus, for spending so much time for a technical deep explanation of what actually is happening in the dd process and a collection of problems that can occur cloning usb sticks with it. Ok. I will see what I can do with mkusb to get what I wanted. Could you describe the exact steps in the terminal prompt for the mkusb route with sync?
– leeuwtje
Dec 2 at 14:13
One more thing, about the different kind of usb drives where you refer to old and new drives. Would this also give problems in case of trying to clone a compact flash card to an new usb stick?
– leeuwtje
Dec 2 at 14:16
0. Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file, identify the source drive (for example withsudo lsblk -f
andsudo lsblk -m
); 1. Install mkusb according to the link in my answer; 2.Start mkusb-dus from the menu in Lubuntu or from the command line in a terminal windowdus <source device>
for exampledus /dev/sdx
where/dev/sdx
is the source drive. mkusb (dus) will help you identify the target drive and runsync
etc automatically.
– sudodus
Dec 2 at 15:19
3. I think it will work to clone from a compact flash card to an new usb stick.
– sudodus
Dec 2 at 15:31
1
@sudodus you don't need to "Indent each line 4 spaces in order to render the output as 'code'". Just paste in the text, select that text, then hit the{}
icon which will format it into human-readable text. If you have "preview" enabled, you can see how your question/answer will look to others.
– heynnema
Dec 4 at 14:50
|
show 8 more comments
Wow, thanks sudodus, for spending so much time for a technical deep explanation of what actually is happening in the dd process and a collection of problems that can occur cloning usb sticks with it. Ok. I will see what I can do with mkusb to get what I wanted. Could you describe the exact steps in the terminal prompt for the mkusb route with sync?
– leeuwtje
Dec 2 at 14:13
One more thing, about the different kind of usb drives where you refer to old and new drives. Would this also give problems in case of trying to clone a compact flash card to an new usb stick?
– leeuwtje
Dec 2 at 14:16
0. Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file, identify the source drive (for example withsudo lsblk -f
andsudo lsblk -m
); 1. Install mkusb according to the link in my answer; 2.Start mkusb-dus from the menu in Lubuntu or from the command line in a terminal windowdus <source device>
for exampledus /dev/sdx
where/dev/sdx
is the source drive. mkusb (dus) will help you identify the target drive and runsync
etc automatically.
– sudodus
Dec 2 at 15:19
3. I think it will work to clone from a compact flash card to an new usb stick.
– sudodus
Dec 2 at 15:31
1
@sudodus you don't need to "Indent each line 4 spaces in order to render the output as 'code'". Just paste in the text, select that text, then hit the{}
icon which will format it into human-readable text. If you have "preview" enabled, you can see how your question/answer will look to others.
– heynnema
Dec 4 at 14:50
Wow, thanks sudodus, for spending so much time for a technical deep explanation of what actually is happening in the dd process and a collection of problems that can occur cloning usb sticks with it. Ok. I will see what I can do with mkusb to get what I wanted. Could you describe the exact steps in the terminal prompt for the mkusb route with sync?
– leeuwtje
Dec 2 at 14:13
Wow, thanks sudodus, for spending so much time for a technical deep explanation of what actually is happening in the dd process and a collection of problems that can occur cloning usb sticks with it. Ok. I will see what I can do with mkusb to get what I wanted. Could you describe the exact steps in the terminal prompt for the mkusb route with sync?
– leeuwtje
Dec 2 at 14:13
One more thing, about the different kind of usb drives where you refer to old and new drives. Would this also give problems in case of trying to clone a compact flash card to an new usb stick?
– leeuwtje
Dec 2 at 14:16
One more thing, about the different kind of usb drives where you refer to old and new drives. Would this also give problems in case of trying to clone a compact flash card to an new usb stick?
– leeuwtje
Dec 2 at 14:16
0. Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file, identify the source drive (for example with
sudo lsblk -f
and sudo lsblk -m
); 1. Install mkusb according to the link in my answer; 2.Start mkusb-dus from the menu in Lubuntu or from the command line in a terminal window dus <source device>
for example dus /dev/sdx
where /dev/sdx
is the source drive. mkusb (dus) will help you identify the target drive and run sync
etc automatically.– sudodus
Dec 2 at 15:19
0. Please do not clone the drive that you have booted from. For example, boot from a Lubuntu live drive made from a Lubuntu iso file, identify the source drive (for example with
sudo lsblk -f
and sudo lsblk -m
); 1. Install mkusb according to the link in my answer; 2.Start mkusb-dus from the menu in Lubuntu or from the command line in a terminal window dus <source device>
for example dus /dev/sdx
where /dev/sdx
is the source drive. mkusb (dus) will help you identify the target drive and run sync
etc automatically.– sudodus
Dec 2 at 15:19
3. I think it will work to clone from a compact flash card to an new usb stick.
– sudodus
Dec 2 at 15:31
3. I think it will work to clone from a compact flash card to an new usb stick.
– sudodus
Dec 2 at 15:31
1
1
@sudodus you don't need to "Indent each line 4 spaces in order to render the output as 'code'". Just paste in the text, select that text, then hit the
{}
icon which will format it into human-readable text. If you have "preview" enabled, you can see how your question/answer will look to others.– heynnema
Dec 4 at 14:50
@sudodus you don't need to "Indent each line 4 spaces in order to render the output as 'code'". Just paste in the text, select that text, then hit the
{}
icon which will format it into human-readable text. If you have "preview" enabled, you can see how your question/answer will look to others.– heynnema
Dec 4 at 14:50
|
show 8 more comments
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1097683%2flubuntu-18-10-x64-installed-on-usb-stick-clone-to-usb-stick-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown