Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
Copying System
-
- Posts: 11
- Joined: 2022-11-19 18:49
Copying System
Hello
I was wondering if it's possible to copy a complete Linux system?
Have all my settings and such available on another machine?
I'm a bit afraid to mess things up, that's why I'm asking it here first.
I was wondering if it's possible to copy a complete Linux system?
Have all my settings and such available on another machine?
I'm a bit afraid to mess things up, that's why I'm asking it here first.
-
- Emeritus
- Posts: 2435
- Joined: 2010-12-07 19:55
- Has thanked: 14 times
- Been thanked: 54 times
-
- Posts: 24
- Joined: 2023-01-24 22:12
- Has thanked: 3 times
Re: Copying System
The dd command is what you are looking for i think. but always use this command with the highest caution, because if you use it wrong it can quickly lead to data loss.
With the dd command you can copy whole disks 1:1 or create .img (exact disk images) files and also load them back to the disk (recommended if you want to make backups) as well as create .iso files from disks, and much more.
If you want to copy your current system 1:1, you can theoretically do this from the system itself, but this can lead to problems because while the system is running, changes are constantly being made to certain files. It is recommended to copy the system from a life system, for example you can load a Debian live system [1] or other live systems like Knoppix on a usb stick.
The dd command is as said dangerous, if you use for example as input path an external disk and as output path your disk on which your system is running, your system disk (whether the system is running or not) will be overwritten with what is on the external disk. If this is too dangerous for you, you can use clonezilla [2] for example, with this tool you can also delete disks by mistake, but it has a graphical structure in the terminal where you can see better what you are doing.
The dd command needs an input path (if=) and an output path (of=) to determine from where it should copy the data to where. As an example I can give you this:
**Edited**
dd if=/dev/sdx of=/dev/sdx status=progress
in this case it would copy the data 1:1 from the disk sdx to sdy.
To find out the name of the disk you want to copy you can use the command lsblk.
You should get such an output when you run it. sda, sdb, sdc are the disks themselves and e.g. sda1 would be a partition.
So if i wanted to copy my main disk sda to my other internal disk sdb, so i would have to replace sdx with sda and sdy with sdb in the command I gave above.
But if you are unsure about the dd command better ask first or use clonezilla [2] as an alternative, also, as arochester mentioned above, it would be important to know if the hardware of the other computer changes, because then driver problems could occur.
-------
[1] https://www.debian.org/CD/live/
[2] https://packages.debian.org/buster/clonezilla
With the dd command you can copy whole disks 1:1 or create .img (exact disk images) files and also load them back to the disk (recommended if you want to make backups) as well as create .iso files from disks, and much more.
If you want to copy your current system 1:1, you can theoretically do this from the system itself, but this can lead to problems because while the system is running, changes are constantly being made to certain files. It is recommended to copy the system from a life system, for example you can load a Debian live system [1] or other live systems like Knoppix on a usb stick.
The dd command is as said dangerous, if you use for example as input path an external disk and as output path your disk on which your system is running, your system disk (whether the system is running or not) will be overwritten with what is on the external disk. If this is too dangerous for you, you can use clonezilla [2] for example, with this tool you can also delete disks by mistake, but it has a graphical structure in the terminal where you can see better what you are doing.
The dd command needs an input path (if=) and an output path (of=) to determine from where it should copy the data to where. As an example I can give you this:
**Edited**
dd if=/dev/sdx of=/dev/sdx status=progress
Code: Select all
dd if=/dev/sdx of=/dev/sdy status=progress
To find out the name of the disk you want to copy you can use the command lsblk.
Code: Select all
someone@onepc:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 476,9G 0 disk
├─sda1 8:3 0 512M 0 part /boot
├─sda2 8:4 0 1K 0 part
├─sda3 8:5 0 472,4G 0 part /
└─sda4 8:6 0 4G 0 part [SWAP]
sdb 8:16 0 1,8T 0 disk
└─sdb1 8:17 0 1,8T 0 part
sdc 8:32 0 1,8T 0 disk
└─sdc1 8:33 0 1,8T 0 part
sr0 11:0 1 1024M 0 rom
So if i wanted to copy my main disk sda to my other internal disk sdb, so i would have to replace sdx with sda and sdy with sdb in the command I gave above.
But if you are unsure about the dd command better ask first or use clonezilla [2] as an alternative, also, as arochester mentioned above, it would be important to know if the hardware of the other computer changes, because then driver problems could occur.
-------
[1] https://www.debian.org/CD/live/
[2] https://packages.debian.org/buster/clonezilla
Last edited by only_someone on 2023-02-05 23:12, edited 1 time in total.
- sunrat
- Administrator
- Posts: 6498
- Joined: 2006-08-29 09:12
- Location: Melbourne, Australia
- Has thanked: 118 times
- Been thanked: 476 times
Re: Copying System
Err, no it wouldn't. Should be:only_someone wrote: ↑2023-02-05 21:26in this case it would copy the data 1:1 from the disk sdx to sdy.Code: Select all
dd if=/dev/sdx of=/dev/sdx status=progress
Code: Select all
dd if=/dev/sdx of=/dev/sdy
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ” Remember to BACKUP!
Those who have lost data
...and those who have not lost data YET ” Remember to BACKUP!
-
- Posts: 24
- Joined: 2023-01-24 22:12
- Has thanked: 3 times
Re: Copying System
oh, sorry I mistyped that onesunrat wrote: ↑2023-02-05 22:29Err, no it wouldn't. Should be:only_someone wrote: ↑2023-02-05 21:26in this case it would copy the data 1:1 from the disk sdx to sdy.Code: Select all
dd if=/dev/sdx of=/dev/sdx status=progress
Code: Select all
dd if=/dev/sdx of=/dev/sdy
Well at least this is now the perfect example of how quickly you can lose your data !
-
- Global Moderator
- Posts: 2716
- Joined: 2018-06-20 15:16
- Location: Colorado
- Has thanked: 41 times
- Been thanked: 201 times
Re: Copying System
To avoid mistake you can use the other designates in /dev/disk like .../by-label etc.
I usually don't go device to device so I'm only 99% sure qemu-img would do the job. I use by-label as often as possible, and take the step to label all.
I forward-up instead of backing up so go from disk to image, from that image to new disk. This condenses verifying things to part of the process. When new disk is successful and from the image now known as the tested good backup.
qemu-img is from qemu-utils. It may pull in libaio and libfuse3-3 for about 7MB's.
It is basically a dd -extra. In a similar way it operates on unmounted devices. It offers sparseness, compression, and the qcow2 format which has many advantages.
I usually don't go device to device so I'm only 99% sure qemu-img would do the job. I use by-label as often as possible, and take the step to label all.
I forward-up instead of backing up so go from disk to image, from that image to new disk. This condenses verifying things to part of the process. When new disk is successful and from the image now known as the tested good backup.
qemu-img is from qemu-utils. It may pull in libaio and libfuse3-3 for about 7MB's.
It is basically a dd -extra. In a similar way it operates on unmounted devices. It offers sparseness, compression, and the qcow2 format which has many advantages.
-
- Global Moderator
- Posts: 3049
- Joined: 2017-09-17 07:12
- Has thanked: 5 times
- Been thanked: 132 times
Re: Copying System
No you can't. It will lead to problems as the result will be corrupted. A read-write mounted filesystem is in an inconsistent ("dirty") on-disk state by design and becomes consistent again only when cleanly unmounted or remounted read-only.only_someone wrote: ↑2023-02-05 21:26 If you want to copy your current system 1:1, you can theoretically do this from the system itself, but this can lead to problems because while the system is running, changes are constantly being made
-
- Posts: 24
- Joined: 2023-01-24 22:12
- Has thanked: 3 times
Re: Copying System
p.H wrote: ↑2023-02-08 20:44No you can't. It will lead to problems as the result will be corrupted. A read-write mounted filesystem is in an inconsistent ("dirty") on-disk state by design and becomes consistent again only when cleanly unmounted or remounted read-only.only_someone wrote: ↑2023-02-05 21:26 If you want to copy your current system 1:1, you can theoretically do this from the system itself, but this can lead to problems because while the system is running, changes are constantly being made
I admit that my choice of the word "can" was inaccurate, as there is a very high probability that files will be damaged. I used the "can" to refer to that the copied system may or may not work afterwards.only_someone wrote: ↑2023-02-05 21:26 If you want to copy your current system 1:1, you can theoretically do this from the system itself, but this can lead to problems because while the system is running, changes are constantly being made to certain files. It is recommended to copy the system from a life system, for example...
Years ago I tried to copy my GNU/Linux system from my internal HDD to an external HDD to test if I could use it as a portable system. I used the dd command to copy my HDD where the system was running at that moment. I was aware that it was not a good idea but it worked without the copied system causing errors, at least I could not see any error messages in any log file nor was any error visible when using the system. On the 3 attempt it then caused errors when starting the copied system, so it may work but does not have to and it is not recommended as I wrote.
I'm sorry, I was over-motivated in answering.