L'il gotchas and headscratchers

Just recently, in my job - I’ve had to re-jig filesystems on servers where everything is on “/” (this is what I do on desktops - but it’s far from ideal on servers)…

So - the general procedure is boot from an ISO (in all recent cases it’s been virtual servers in VMware ESX or HyperV [groan! jeez I detest HyperV - it’s a steaming pile of cr@p]) and select “rescue” mode - most of the distros have this option on boot from ISO, Debian, CentOS, Ubuntu etc, eventually you end up in a busybox “shell”… Stripped down version of a shell with inbuilt UNIX programs…

Anyway - one “old trick” a more experienced UNIX user showed me over 20 years ago to “bullet proof” copying of files/folders :

cd {src}
tar -cvfp - * | ( cd {dest} ; tar -xvfp -)

The “hyphen” after “-cvfp” means STDIN/OUT - so we’re tarring to STDIN, then tarring out from STDOUT after the pipe…

Anyway - couple of peeves about Busybox on Ubuntu and Debian - it DOES NOT have vi! So I have to use nano, and I hate nano (which Debian and Ubuntu force you to use for “visudo” - so I have to “export EDITOR=vi” to use vi) - and I just discovered today (and first happened to me last week) - the version of “tar” compiled into Busybox (at least on Debian based distros) is fussy about the order of arguments to tar (on the previous case, I ended up using “cp -x” to copy the data - from the old /var/ to a new Logical Volume for /var mount - because I coudn’t figure out why tar -cvfp wasn’t working).

I’ve been using “tar -cvfp” and “tar -xvfp” for decades, since Solaris was SunOS and based on BSD, and most times I don’t even prefix the arguments with a hyphen - so just :
tar czvfp /var/tmp/bkup-opt.tar.gz /opt

Anyway - tar in busybox doesn’t like “p” at the end after “f”… so have to :
tar -cvpf {output} {src}

Had me scratching my head for sure!