{"id":526,"date":"2011-09-27T21:40:32","date_gmt":"2011-09-28T03:40:32","guid":{"rendered":"https:\/\/www.galador.org\/blog\/?p=526"},"modified":"2011-09-27T21:40:32","modified_gmt":"2011-09-28T03:40:32","slug":"moving-between-two-freebsd-servers","status":"publish","type":"post","link":"https:\/\/www.galador.org\/blog\/moving-between-two-freebsd-servers\/","title":{"rendered":"Moving Between Two FreeBSD Servers"},"content":{"rendered":"<p>Due to various reasons, I&#8217;ve had to move the VPS that hosts my website and other things two different times now, and I&#8217;ve compiled a basic list of things you need to do to create a complete copy of the old server to the new one.<\/p>\n<p>When you perform these steps, the it would be best to disable as many services as you can on the old server (so that some services doesn&#8217;t write a new file while you&#8217;re copying things over).<\/p>\n<p>This is, of course a basic list of things to do, but it has done me good thusfar.  There will be a few times where you may have to &#8220;go it on your own&#8221; (looking at KERNCONFs, here), but you should be able to figure that out yourself using <a href=\"http:\/\/www.google.com\/\">Online Documentation<\/a>.<\/p>\n<p>Here we go!  All these steps are stated as though you&#8217;re performing this on server 2, which is the one you&#8217;re <b>moving <i>to<\/i><\/b>, unless noted otherwise.<\/p>\n<pre lang=\"bash\">\r\n#Install rsync\r\nportsnap fetch\r\nportsnap extract\r\ncd \/usr\/ports\/net\/rsync\r\nmake install clean\r\n\r\n#Copy users and groups over\r\nscp -r root@server.one:\/usr\/home\/* \/usr\/home\/\r\nscp root@server.one:\/etc\/passwd \/etc\/\r\nscp root@server.one:\/etc\/group \/etc\/\r\nscp root@server.one:\/etc\/master.passwd \/etc\/\r\n\r\n#Copy \/etc , \/usr, \/root, \/var to new server\r\nrsync -vrplogDtH root@server.one:\/var\/db\/ \/var\/db\r\nrsync -vrplogDtH --exclude 'bin' --exclude 'lib' --exclude 'lib32' --exclude 'libexec' root@server.one:\/usr\/ \/usr\r\nrsync -vrplogDtH root@server.one:\/root\/ \/root\r\npwd_mkdb -p \/etc\/master.passwd \r\n\r\n#Update Kernel  ->  http:\/\/www.freebsd.org\/doc\/handbook\/makeworld.html\r\ncsup \/root\/supfile\r\n###check \/usr\/src\/UPDATING\r\n###check \/etc\/make.conf\r\n#Update files in \/etc\r\ncd \/usr\/src\/usr.sbin\/mergemaster\r\n.\/mergemaster.sh -p\r\n#Drop to single-user mode\r\nshutdown now\r\n#From here, you should be able to hit enter to get a \/bin\/sh in recovery mode\r\nfsck -p\r\nmount -u \/\r\nmount -a -t ufs\r\nswapon -a\r\nadjkerntz -i  #If hw clock is set to local time.  `date` will show incorrect time and zone\r\n\r\n#remove files from \/usr\/obj\r\ncd \/usr\/obj\r\nchflags -R noschg *\r\nrm -rf *\r\n\r\n#Save compile output\r\nscript \/var\/tmp\/build.log\r\n\r\n#Compile base system\r\ncd \/usr\/src\r\nmake -j6 buildworld\r\n\r\n#compile kernel  -- You should create your own KERNCONF here, or use GENERIC\r\nmake buildkernel KERNCONF=GALLY\r\nmake installkernel KERNCONF=GALLY\r\n\r\n#Reboot the machine into single-user mode and ensure kernel works\r\nshutdown -r now\r\n### Option 4 at the FreeBSD boot loader\r\n### Remount drives\r\nfsck -p\r\nmount -u \/\r\nmount -a -t ufs\r\nswapon -a\r\n\r\n#Install new system binaries if kernel is working correctly.\r\ncd \/usr\/src\r\nmake installworld\r\n\r\n#Run mergemaster again \r\n\/usr\/sbin\/mergemaster\r\n\r\n#New kernel and world are now installed.  Reboot into your new system\r\nshutdown -h now\r\n\r\n#Re-install ports\r\nportmaster --list-origins > \/root\/installed-port-list  ## Perform this step on server 1\r\nscp root@server.one:\/root\/installed-port-list \/root\/\r\nportsnap fetch update\r\nportmaster -y --clean-distfiles\r\nportmaster --check-port-dbdir\r\nportmaster -Faf\r\npkg_delete '*'\r\nrm -rf \/usr\/local\/lib\/compat\/pkg\r\n#check \/usr\/local to make sure that only config files, etc are still installed\r\nrm -rf \/var\/db\/pkg\r\n#install portmaster again\r\ncd \/usr\/ports\/ports-mgmt\/portmaster && make install clean\r\nportmaster -D --update-if-newer `cat \/root\/installed-port-list`\r\n\r\n###  Do minor manual configurating.\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Due to various reasons, I&#8217;ve had to move the VPS that hosts my website and other things two different times now, and I&#8217;ve compiled a basic list of things you need to do to create a complete copy of the old server to the new one. When you perform these steps, the it would be &hellip; <a href=\"https:\/\/www.galador.org\/blog\/moving-between-two-freebsd-servers\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Moving Between Two FreeBSD Servers<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[60],"tags":[],"class_list":["post-526","post","type-post","status-publish","format-standard","hentry","category-freebsd"],"_links":{"self":[{"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/posts\/526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/comments?post=526"}],"version-history":[{"count":2,"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/posts\/526\/revisions"}],"predecessor-version":[{"id":528,"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/posts\/526\/revisions\/528"}],"wp:attachment":[{"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/media?parent=526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/categories?post=526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/tags?post=526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}