Score:0

What's the best means to clone the root linux hard drive to a new drive?

za flag

I bought a new enterprise grade SSD to replace my Samsung SSD. It was $500, not cheap. Anyway, the purpose is to have a more reliable and longer-lasting root hard drive, since a non-enterprise drive is effectively a ticking time bomb.

My system is CentOS 7 x64. My server is a dedicated server (not a virtual machine or VPS).

My server is live. It would take more time than I have to set up a new drive from scratch and copy everything over, because the last time it took me weeks, and I didn't also have a full time job like I do now. So it isn't feasible.

Instead I want to clone the drive to the new one, which is larger than the old one.

Although my server is live, I am willing to take it offline for a couple hours if need be to do the clone. But the less time it's offline the better, of course. I have a lot of sites on there.

How can I clone the old drive to the new drive? What do I use to do the clone?

I cannot go in person, it's way too far away. I also do not have access to a windows system.

I could dd the whole live drive to the new one, but I read online that there could be errors if I tried that. They said it's best to take it offline and mount it as read only first and then clone the drive to the new one.

So, how exactly do I do this? Is dd the right solution? Do I mount both onto a second server so I can ssh into a second server to mount the two drives? Or what is the best way in this scenario?


Server details

CentOS 7 x64 (dedicated server)

#lsblk

NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0  10.9T  0 disk
└─sda1            8:1    0  10.9T  0 part /mnt/home1
sdb               8:16   0  10.9T  0 disk
└─sdb1            8:17   0  10.9T  0 part /mnt/home2
sdc               8:32   0 931.5G  0 disk
├─sdc1            8:33   0     4G  0 part /boot
└─sdc2            8:34   0 927.5G  0 part
  ├─centos-root 253:0    0 911.5G  0 lvm  /
  └─centos-swap 253:1    0    16G  0 lvm  [SWAP]
sdd               8:48   0  16.4T  0 disk
└─sdd1            8:49   0  16.4T  0 part /mnt/home3
loop0             7:0    0     4G  0 loop /home/virtfs/[removed]/var/tmp
in flag
Copy partition tables using sfdisk, then use cpio or tar to copy all files over.
serveraddict avatar
za flag
While server is live? Or how exactly? Your answer is unclear
Nikita Kipriyanov avatar
za flag
`dd` *might be* the right tool, or might not. It depends. Devil in the details. Do you have a volume manager (LVM), RAID? Show at least `lsblk` of your server for us to understand the storage of the system which you want to clone. // @NiKiZe's comment is not an answer, it's a suggestion in which way to proceed. It is "unclear" because your question is unclear. It is impossible to give a proper answer with that little information. You tell how the system is important to you and how far it is and mentioned your expenses, but you told absolutely nothing about the system itself.
Nikita Kipriyanov avatar
za flag
Also `df -h` to consider the amount of data to transfer. And, remember, the *best* way is available when your system was built in the way to be easily moved; [for example](https://unix.stackexchange.com/questions/679870/grub2-install-throws-various-errors-instead-of-installing-how-to-proceed), this is how I did exactly that three days ago.
serveraddict avatar
za flag
Can you summarize what it is you're referring to in the "for example" link, Nikita? Because that link is a question about errors, so I'm not sure what you're referring to.
serveraddict avatar
za flag
Added `lsblk`. Note that only sdc, which is the root drive, needs to be cloned. You can ignore the other drives.
Nikita Kipriyanov avatar
za flag
The error is resolved there. If you consider the question and the answer together, the link servers as a detailed step-by-step guide how to migrate a system with almost no downtime... if it was installed on the MD RAID.
serveraddict avatar
za flag
I'm not using RAID.
serveraddict avatar
za flag
no response. ok. still don't have the answer.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.