0

I have a CentOS system I'm tying to duplicate. I can't use dd or cat over SSH from the source server so I have to initiate the command from the target server.

My first choice is to duplicate each partition individually using dd then restore those partitions to a test box once it's already formatted and set up with CentOS.

When I created the new partitions on the target server using the partition tool that comes with CentOS's installer, the partition for /home gets moved to /dev/hda2 by default. The original server has it on /dev/sda3. I tried deleting the partition and recreating it so it will match the original server, but no dice. Each time it gets created on the target server the part editor keeps "promoting" it to /dev/hda2. Both servers are using SATA disks but the original server labels its disc /dev/sda and the target server is /dev/hda. I'm not really concerned about this being a problem, I'm just curious as to why it's doing this since I am explicitly telling the partition tool how to create the partitions.

Does anyone have an explanation for why this is happening? Again, I'm just curious.

For reference, here are the partition tables: Original server:

  • /dev/sda2 / 97 GB
  • /dev/sda1 /boot 100 MB
  • /dev/sda3 /home 352 GB

Target server:

  • /dev/hda1 /boot 100 MB
  • /dev/hda2 /home 352 GB
  • /dev/hda3 / 97 GB

Swap is 2 GB on each device.

strugee
  • 14,951
Tensigh
  • 341
  • use gdisk, please. – mikeserv Apr 14 '14 at 02:57
  • if you compare gdisk -l /dev/hda or /dev/sda on both servers - what it shows. Just curious, you can dd partitions, but can't dd /dev/sda as example ? – MolbOrg Apr 14 '14 at 06:52
  • 1
    @mikeserv Why do you think that the new server uses GPT partitioning? – Gilles 'SO- stop being evil' Apr 14 '14 at 22:12
  • 2
    I don't understand why the partition number is a problem, nor what software you're doing this partition creating is. Nor why the corporate firewall has anything to do with duplicating partitions vs duplicating the whole disk. And by the way, use cat, not dd. – Gilles 'SO- stop being evil' Apr 14 '14 at 22:14
  • @Gilles - why wouldnt it? If not, then fdisk. Learning to use either will help to ensure that youre doing it correctly. – mikeserv Apr 15 '14 at 00:19
  • @mikeserv why wouldn't it? uh, maybe because the server is older than a couple years and came preconfigured with an MBR, so no one bothered to change it? – strugee Apr 15 '14 at 01:15
  • @strugee - ok. In that event, as i said, use fdisk. though if youre repartioning the disk, nows the time to go GPT. Also, disks partitioned with gdisk also have MBRs – mikeserv Apr 15 '14 at 01:20
  • @Gilles - I would use "dd if=/dev/sda | ssh user@newserver "dd of=/dev/sda", except that we're banned from an outside source initiating a connection. That's what I meant. – Tensigh Apr 15 '14 at 01:38
  • @Tensigh Open the connection the other way around and use ssh port tunneling. – phemmer Apr 15 '14 at 12:43
  • @Tensigh But if you have a way to duplicate the partitions, why not use that method on the disk instead? (And, again, drop dd: in your example this is just a complex, error-prone way of writing ssh root@newserver 'cat >/dev/sda' </dev/sda). – Gilles 'SO- stop being evil' Apr 15 '14 at 17:48
  • @Gilles - does cat work better than dd? I've used dd in the past without any issues. – Tensigh Apr 16 '14 at 01:56
  • 1
    @Tensigh http://unix.stackexchange.com/questions/121865/create-random-data-with-dd-and-get-partial-read-warning-is-the-data-after-the – Gilles 'SO- stop being evil' Apr 16 '14 at 01:58
  • @Gilles - Okay, thanks, that helps. So now I have 2 questions: 1. I need to run this command on the target server. If I read your command correctly, it ssh's to the source server and cats /dev/sda to the target server's /dev/sda, correct? Also, was my question unclear? I wanted to know why the partition tool changed partitions when I didn't tell it to. Is the original question really unclear? – Tensigh Apr 16 '14 at 02:20
  • @Tensigh What is not clear about your question is 1. what you did inside the installer (so we can't tell you how to use the installer differently); 2. why it matters to solve your overall problem (so we can't tell you what to change in your solution). – Gilles 'SO- stop being evil' Apr 16 '14 at 08:50
  • @Gilles - thank you. First of all, can you answer my question about using cat? If what you suggested is better I'll try it, but I need to know for sure if it will work. Second, it's cool that you know so much more about Linux than I do, but I just asked a question as to why the installer chose a different partition. I did say what I did using the installer if you read the question. I asked out of curiosity and I was afraid that /dev/sda2 on the original disk and /dev/sda3 on the target disk might cause problems. A simple "that won't cause problems" would have been enough. :) – Tensigh Apr 16 '14 at 13:13
  • 2
    If you have doubts about an internet stranger's recommendation, experiment. Also - you should not get so hung up on which kernel name udev chooses for your disks, especially if you are not explicitly specifying the partition order yourself and instead rely on the behavior of an automated tool to do so for you - which can easily vary by version or by hardware since the original server was apparently SATA or SCSI and you're now working with IDE. Use udev rules to specify aliases or disk labels or UUIDs as appropriate. I do not think this is the problem you think it is. – mikeserv Apr 16 '14 at 14:02
  • @mikeserv, Thank you. Yes, obviously, I would experiment but it doesn't hurt to ask the person directly if that option exists. Second, I wasn't so sure it was a problem, I was just curious. Gilles was the only person who seemed to think my asking about it was a problem, but I digress. Third, most Linux distributions see IDE/SATA drives as /dev/sdX now, don't they? Finally, thank you for FINALLY answering my original question rather than chide me for asking it! Seriously, I appreciate the answer. – Tensigh Apr 16 '14 at 22:39
  • Not ide. Pata will be hda. And @Gilles was the most accomodating of all as far as i could tell. He tried to find out what you were about - more than once - offered advice when that info wasn't forthcoming, and even provided a link for you to research. Mine was the first comment here, and i kinda told you to get bent. Sorry for that. – mikeserv Apr 16 '14 at 23:59
  • In fact i only came back today because @Gilles asked in the chatroom if anybody could figure out what you might need. He genuinely tried to help. – mikeserv Apr 17 '14 at 00:04
  • @mikeserv and Gilles I apologize if I was rude. I've had my share of replies on sites that are the typical "RTFM" or "why do you want to do that?" comments so I might have overreacted. I didn't know if it would be a problem to have /home on another partition. I was mostly curious as to why the partition tool was selecting that one when I specifically created other partitions first. I didn't realize it would cause the controversy that it did. Anyway, thanks to both Gilles and mikeserv for your thoughtful help. Again, sorry if I caused any problems. – Tensigh Apr 17 '14 at 04:42
  • Nah. No problems to me - im just blunt. And i doubt you did so for @Gilles either. I just thought it was a little illogical that you thought he had a problem with your asking questions. I mean, the guy has answered like 500000 questions - its kinda what he does. Anyway, seriously - use gdisk please. – mikeserv Apr 17 '14 at 04:47

0 Answers0