1

I need to replace the HDD on a single disk system used as a pbx (CentOS-6 based FreePBX). The existing partition structure is:

ls -l /dev/sd*
brw-rw---- 1 root disk 8, 0 Apr 17  2018 /dev/sda
brw-rw---- 1 root disk 8, 1 Apr 17  2018 /dev/sda1
brw-rw---- 1 root disk 8, 2 May 25 14:12 /dev/sda2

parted /dev/sda print
Model: ATA ST3500418AS (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size   Type     File system  Flags
 1      1049kB  525MB  524MB  primary  ext4         boot
 2      525MB   500GB  500GB  primary               lvm

parted /dev/sda1 print
Model: Unknown (unknown)
Disk /dev/sda1: 524MB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End    Size   File system  Flags
 1      0.00B  524MB  524MB  ext4

parted /dev/sda2 print
Error: /dev/sda2: unrecognised disk label 

I need to transfer the entire system to a new HDD. Ideally I would like to transfer the entire thing (boot-loader, OS, and filesystems) over the network to a larger disk temporarily installed on a separate host, that is not necessarily running CentOS, and then swap the drives. Is this possible?

I am guessing that with lvm in the mix this is a non-starter. But in case it is not then this scenario is the ideal.

Is this possible and how is it best accomplished?

Further information:

df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/vg_voinet01-lv_root
                      64376668   5057112  56042756   9% /
tmpfs                  1952596         0   1952596   0% /dev/shm
/dev/sda1               487652     55768    406284  13% /boot
/dev/mapper/vg_voinet01-lv_home
                       3159816    246372   2749604   9% /home
/dev/mapper/vg_voinet01-LogVol04
                     322407500 134244852 171778648  44% /var
/dev/mapper/vg_voinet01-lv_log
                       9545056    390052   8663484   5% /var/log
/dev/mapper/vg_voinet01-lv_spool
                      65924860  32354984  30214852  52% /var/spool

vgs;lvs
  VG          #PV #LV #SN Attr   VSize   VFree
  vg_voinet01   1   6   0 wz--n- 465.27g 9.91g
  LV       VG          Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  LogVol04 vg_voinet01 -wi-ao---- 312.50g                                                    
  lv_home  vg_voinet01 -wi-ao----   3.12g                                                    
  lv_log   vg_voinet01 -wi-ao----   9.38g                                                    
  lv_root  vg_voinet01 -wi-ao----  62.50g                                                    
  lv_spool vg_voinet01 -wi-ao----  64.00g                                                    
  lv_swap  vg_voinet01 -wi-ao----   3.86g 
James B. Byrne
  • 317
  • 4
  • 14
  • It is possible and lvm can in some cases make it easier. Can you do this "offline" - ie using a boot disk? If so its fairly straightforward to just dump the disk as a file to the remote system (and vv) If not you need to work out how to contend with changes to the disk while you are writing. LVM snapshots can help here, but that still leaves the boot/root partition. – davidgo May 26 '20 at 09:10
  • Why is this tagged FreeBSD? – Rob May 26 '20 at 09:42
  • @Rob a error possibly, the OP is using FreePBX, correcting the tag – yagmoth555 May 26 '20 at 12:16
  • @davidgo: Pardon my ignorance but what does `vv` refer to? – James B. Byrne May 26 '20 at 13:28
  • VV = vice versa, ie in the opposite way as well. – davidgo May 26 '20 at 19:13
  • Can you add the output of "df" and "vgs;lvs" so we can see if you have unused (or reclaimable) space on LVM and also this disk layout. Can you confirm the OS of the target system (ie is it a variant of Unix) – davidgo May 26 '20 at 19:20

1 Answers1

0

To keep it simple I would use a cloning utility.

Most utility allow booting on a media and clone the disk to a new's one from there.

yagmoth555
  • 16,300
  • 4
  • 26
  • 48
  • I downloaded clonezilla live and attempted to clone one single drive system to a spare hhd on another over the local network. The source was 500GB and the destination was 1000Gb (1T). The the transfer took a considerable time, as expected. The transfer completed whith the following problems: 1. The boot block either was not transferred or was corrupted. I had to use gpart to install one on the destination HDD. 2. The resulting HDD was sized to 500 Gb. – James B. Byrne May 27 '20 at 13:21
  • `gpart show => 40 1953525095 ada0 GPT (932G) 40 1024 1 freebsd-boot (512K) 1064 984 - free - (492K) 2048 4194304 2 freebsd-swap (2.0G) 4196352 484200448 3 freebsd-zfs (231G) 488396800 1465128335 - free - (699G)` – James B. Byrne May 27 '20 at 13:24
  • Getting the boot code loaded was not a problem since both the source and the target hosts are running FreeBSD on ZFS. However, the CentOS based FreePBX host is the last CentOS host that we have. The partition size problem is due to the fact that ZFS is not supported by clonezilla so it uses dd with the expected result that the destination is a blockwise copy of the source, including size. – James B. Byrne May 27 '20 at 13:27
  • @JamesB.Byrne In some tool you can tell to ignore bad sectors to continue, it's really longer, but can help to bypass such problem – yagmoth555 May 27 '20 at 13:29
  • Clonezilla does that. It just cannot do it for file systems that it does not support ((4) UFS of FreeBSD, NetBSD, and OpenBSD) . Of which ZFS does not appear to be one. This was a trial to see how things worked using spare equipment that does not exactly match what the live system uses. But it sufficed to work out the procedural issues, like network cloning requiring two copies of clonezilla live, one for each host. – James B. Byrne May 27 '20 at 14:31