Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hope you are well. I am using Debian and have 320GB SATA disk. I decided to buy a new SSD 500GB and want to clone my current disk to the new one.
I did lots of research on the forums, IRC channels, etc. but no luck there is no enough information about this issue. All of them are saying you need partitioning the disk before, copying data with dd and resize/extend disk with starting/ending sectors. I am really confused.
My goal is clone current disk to a new one. I know installing a fresh OS and moving all data to the new OS but this is not in my options.
lsblk:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 298.1G 0 disk
├─sda1 8:1 0 953M 0 part
│ └─boot_crypt 254:3 0 951M 0 crypt /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 297.2G 0 part
└─sda5_crypt 254:0 0 297.1G 0 crypt
├─debian--vg-root 254:1 0 287.8G 0 lvm /
└─debian--vg-swap 254:2 0 9.3G 0 lvm [SWAP]
sr0 11:0 1 1024M 0 rom
It don't hurt to write to the new SSD, if first attempt fails, clean off the new drive's partition table and try something else. I'm not LVM experienced, but you should be able to simply dd if=/old/drive of=/new/drive bs=4k conv=notrunc from a running Linux live session. The new drive will only be 320GB like the original, remove or disable the old drive, set BIOS to boot the new drive, boot it and see if it works.
Now from either Linux live or while in the new running Debian you run fdisk /dev/<whatever> (the drive, not partitions), select "x" to go into expert mode, select "p" to print current drive structure, select "f" to fix partition order, select "p" to see what the proposed changes are, if you like what you see, select "r" to return to main menu, select "w" to write the changes. If you are doing it from the new running Debian you'll get errors because the kernel is running on the old configuration, just reboot and hopefully you have the full drive which you can now expand the LVM.
It makes no sense to clone that configuration. The extended partition, the LUKS partition, the container, the PV, the vg and the lv's will all need attention. In that order, and no mistakes.
If you have to, pre-allocate the partitions, takes that out of consideration later. Personally I would copy, not clone.
syg00 advice sounds right. I would boot off of a live usb with both source and target drives installed. Then encrypt/format/mount the target drive partitions and then open(decrypt) & mount (read only might be good) the source partitions, and then copy all of your data from source to target with rsync. Then do whatever needs to be done with your bootloader on the target drive. You are never writing to the source, so, if at first you don't succeed, try, try again.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.