Current Installation: CentOS 7.1503 with SerNet Samba 4 ver. 4.1.17 configured as Active Directory Domain Controller. Current Installation: HP Workstation with dual Xeon quadcore cpu's and 4 x SATA hard drives NOT configured in RAID array. New Installation: CentOS 7.1503 minimal install New Installation: SuperMicro with single Xeon quadcore cpu and 4 x SATA hard drives configured in two pairs of RAID 1. The Current Install is about 3.5 GB's and has my Samba 4 setup all solid and working well. I want to know if it's possible to simply: - tar up the whole root partition - put it on a USB drive - boot the New server with a livecd - chroot into / partition - unpack the tar'ed root (/) from the USB drive into the New server root (/). Both installs used the automatic partitioning from anaconda, so /boot is on a separate partition. Each server has an initrd and kernel that works from /boot partition. Both CentOS installs are setup using the xfs filesystem on the root (/) partition. I saw someone do this successfully once but they left out certain directories like /srv , /tmp , and /var. But I'm not 100% certain which directories need to be left out of the tarball. Has anyone done this before? Do you know if it's doable? Thanks for reading.
m.roth at 5-cent.us
2015-Jun-29 18:45 UTC
[CentOS] Tar CentOS installation and transfer it to new server
Mike wrote:> Current Installation: CentOS 7.1503 with SerNet Samba 4 ver. 4.1.17 > configured as Active Directory Domain Controller. > Current Installation: HP Workstation with dual Xeon quadcore cpu's and 4 x > SATA hard drives NOT configured in RAID array. > > New Installation: CentOS 7.1503 minimal install > New Installation: SuperMicro with single Xeon quadcore cpu and 4 x SATA > hard drives configured in two pairs of RAID 1. > > The Current Install is about 3.5 GB's and has my Samba 4 setup all solid > and working well. I want to know if it's possible to simply: > > - tar up the whole root partition > - put it on a USB drive > - boot the New server with a livecd > - chroot into / partition > - unpack the tar'ed root (/) from the USB drive into the New server root > (/). > > Both installs used the automatic partitioning from anaconda, so /boot is > on > a separate partition. Each server has an initrd and kernel that works > from > /boot partition. Both CentOS installs are setup using the xfs filesystem > on the root (/) partition. > > I saw someone do this successfully once but they left out certain > directories like /srv , /tmp , and /var. > But I'm not 100% certain which directories need to be left out of the > tarball. > > Has anyone done this before? > Do you know if it's doable? > > Thanks for reading.What we've done a good bit of, to upgrade one server from another that's already where we want it to be, is this: 1. On the target machine, mkdir /new /boot/new 2. rsync -HPavx <sourceserver>:/boot/. /boot/new/ 3. rsync -HPavx -exclude=/old -exclude=/var/log/wtmp <sourceserver>:/. /new/ (exclude anything else you want) 4. Copy /etc/fstab, /etc/sysconfig/network, /etc/sysconfig/network-scripts/ifcfg-e*, /boot/grub/device.map, and /etc/exports, if any, to /boot/new and /new/etc/ 5. Deal with /new/etc/udev.d/rules/70-persistant-net.rules 6. copy /etc/ssh/ssh_host* /new/etc/ssh/ 7. IF THE NEW HARDWARE IS DIFFERENT THAN THE OLD, make a new initrd. mount --bind /dev /new/dev mount --bind /sys /new/sys mount --bind /proc /new/proc mount --bind /boot/new /new/boot chroot /new cd /lib/modules VER=$(ls -rt1 | tail -1) echo $VER mkinitrd X $VER mv X /boot/initrd-$VER.img exit 8. I haven't been able to do the next in bash, my preferred shell, so: zsh zmodload zsh/files cd /boot mkdir old mv * old mv old/lost+found . mv old/new/* . # Root partition. cd / mkdir old mv * old mv old/lost+found . #mv old/root . -- WHY? mv old/scratch . mv old/new/* . sync sync 9. touch /.autorelabel reboot And you can always go back via a rescue boot and a few moves. mark
Thanks Mr. Roth! That's nice and methodical. I do like how you can revert by simply remounting the previous directories. I'm going to try both. I'm still hopeful that a simple tar -xf server.tgz into the chrooted "/" is possible. At linuxquestions.org, one user suggests it can be done by exempting the following: /proc /sys /dev /tmp /var I'm thinking the tarball thing may work due to the following: There's only one posix user account besides root, thus almost all files on the system are user: root group: root. I'll be using the same version of tar on both the Current Installation and the New Installation. All other user data will be mounted on the other set of hard drives and not a part of the base installation I'm un-tarring into (/). I'll also update each server install prior to transfer so all base packages on both servers match x.y.z to x.y.z. Mike On Mon, Jun 29, 2015 at 2:45 PM, <m.roth at 5-cent.us> wrote:> Mike wrote: > > Current Installation: CentOS 7.1503 with SerNet Samba 4 ver. 4.1.17 > > configured as Active Directory Domain Controller. > > Current Installation: HP Workstation with dual Xeon quadcore cpu's and 4 > x > > SATA hard drives NOT configured in RAID array. > > > > New Installation: CentOS 7.1503 minimal install > > New Installation: SuperMicro with single Xeon quadcore cpu and 4 x SATA > > hard drives configured in two pairs of RAID 1. > > > > The Current Install is about 3.5 GB's and has my Samba 4 setup all solid > > and working well. I want to know if it's possible to simply: > > > > - tar up the whole root partition > > - put it on a USB drive > > - boot the New server with a livecd > > - chroot into / partition > > - unpack the tar'ed root (/) from the USB drive into the New server root > > (/). > > > > Both installs used the automatic partitioning from anaconda, so /boot is > > on > > a separate partition. Each server has an initrd and kernel that works > > from > > /boot partition. Both CentOS installs are setup using the xfs filesystem > > on the root (/) partition. > > > > I saw someone do this successfully once but they left out certain > > directories like /srv , /tmp , and /var. > > But I'm not 100% certain which directories need to be left out of the > > tarball. > > > > Has anyone done this before? > > Do you know if it's doable? > > > > Thanks for reading. > > What we've done a good bit of, to upgrade one server from another that's > already where we want it to be, is this: > > 1. On the target machine, mkdir /new /boot/new > 2. rsync -HPavx <sourceserver>:/boot/. /boot/new/ > 3. rsync -HPavx -exclude=/old -exclude=/var/log/wtmp <sourceserver>:/. > /new/ (exclude anything else you want) > 4. Copy /etc/fstab, /etc/sysconfig/network, > /etc/sysconfig/network-scripts/ifcfg-e*, /boot/grub/device.map, and > /etc/exports, if any, to /boot/new and /new/etc/ > 5. Deal with /new/etc/udev.d/rules/70-persistant-net.rules > 6. copy /etc/ssh/ssh_host* /new/etc/ssh/ > 7. IF THE NEW HARDWARE IS DIFFERENT THAN THE OLD, make a new initrd. > mount --bind /dev /new/dev > mount --bind /sys /new/sys > mount --bind /proc /new/proc > mount --bind /boot/new /new/boot > chroot /new > cd /lib/modules > > VER=$(ls -rt1 | tail -1) > echo $VER > > mkinitrd X $VER > mv X /boot/initrd-$VER.img > > exit > > 8. I haven't been able to do the next in bash, my preferred shell, so: > zsh > zmodload zsh/files > > cd /boot > mkdir old > mv * old > mv old/lost+found . > mv old/new/* . > > # Root partition. > cd / > mkdir old > mv * old > mv old/lost+found . > #mv old/root . -- WHY? > mv old/scratch . > mv old/new/* . > > sync > sync > > 9. touch /.autorelabel > > reboot > > And you can always go back via a rescue boot and a few moves. > > mark > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >
Seemingly Similar Threads
- Tar CentOS installation and transfer it to new server
- Tar CentOS installation and transfer it to new server
- Tar CentOS installation and transfer it to new server
- Crazy thought about upgrading to new major release
- Crazy thought about upgrading to new major release