This might have interesting tidbits. It’s a draft from June 2020 where I was renaming filesystems when booting from a live thumbdrive.
I am replacing one zroot with another because of missing binaries and suspect layout. The existing zroot is an old system predating current zroot layouts.
I have already copied over some filesystems via zfs send | zfs recv over ssh.
I will now try renaming the filesystems on the new drives and retain a able system.
This work is being performed on a test system (that link is not safe for young eyes).
In this post:
- FreeBSD 12.1
- mfsBSD 12.1
About this thumb drive
I wrote about burning a thumb drive image to a USB drive.
I’ve booted the test system from that thumbdrive.
Next, I will manipulate those new drives.
Logging into mfsBSD
One of the lovely features of mfsBSD is it allows me to ssh as root for this task. This is not something one should normally do, but this is not a normal circumstance.
$ ssh root@10.0.0.247 The authenticity of host '10.0.0.247 (10.55.0.247)' can't be established. ECDSA key fingerprint is SHA256:8ysqgLdw3eU29srXdNlyze6QqF5ztkKq4HwaucLO/Z8. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.0.0.247' (ECDSA) to the list of known hosts. Password for root@mfsbsd:
The password is: mfsroot.
Before we get started
I started down a rabbit-hole, got confused, and started again another day.
I kept what I wrote, because it might contains stuff which might help you.
The rabbit hole starts here
Looking around
Let’s see what we have:
root@mfsbsd:~ # zfs list no datasets available
This is also good. Nothing to conflict with.
Import without mounting
I want to import zroot without mounting any of the filesystems. If I were to mount it, things would get overlaid on top of the existing mfsBSD filesystem. I don’t want that. I just want to rename stuff, set properties, perhaps delete some stuff.
From man zpool, I want -N:
root@mfsbsd:~ # zpool import -N zroot root@mfsbsd:~ # zfs list NAME USED AVAIL REFER MOUNTPOINT zroot 8.63G 197G 88K /zroot zroot/ROOT 757M 197G 88K none zroot/ROOT/default 479M 197G 477M / zroot/ROOT/default1 278M 197G 275M /zroot/default1 zroot/tmp 1.26M 197G 88K /tmp zroot/usr 625M 197G 88K /usr zroot/usr/home 188K 197G 124K /usr/home zroot/usr/local 625M 197G 625M /usr/local zroot/usr1 1.26G 197G 1.26G /zroot/usr1 zroot/var 3.73M 197G 88K /var zroot/var/audit 88K 197G 88K /var/audit zroot/var/crash 88K 197G 88K /var/crash zroot/var/log 776K 197G 172K /var/log zroot/var/log1 2.48M 197G 2.48M /var/log1 zroot/var/mail 144K 197G 88K /var/mail zroot/var/tmp 104K 197G 88K /var/tmp zroot/var1 6.01G 197G 6.01G /zroot/var1 root@mfsbsd:~ #
Yes, that looks right.
rename, move, etc
Let’s rename some stuff, moving the original stuff out of the way and moving in the old stuff.
root@mfsbsd:~ # zfs create zroot/original root@mfsbsd:~ # zfs rename zroot/ROOT/default zroot/original/default root@mfsbsd:~ # zfs rename zroot/usr zroot/original/usr root@mfsbsd:~ # zfs rename zroot/var/log zroot/original/log root@mfsbsd:~ # zfs rename zroot/var zroot/original/var
Let’s see:
NAME USED AVAIL REFER MOUNTPOINT zroot 8.63G 197G 88K /zroot zroot/ROOT 278M 197G 88K none zroot/ROOT/default1 278M 197G 275M /zroot/default1 zroot/original 1.08G 197G 88K /zroot/original zroot/original/default 479M 197G 477M / zroot/original/log 776K 197G 172K /zroot/original/log zroot/original/usr 625M 197G 88K /usr zroot/original/usr/home 188K 197G 124K /usr/home zroot/original/usr/local 625M 197G 625M /usr/local zroot/original/var 2.98M 197G 88K /var zroot/original/var/audit 88K 197G 88K /var/audit zroot/original/var/crash 88K 197G 88K /var/crash zroot/original/var/log1 2.48M 197G 2.48M /var/log1 zroot/original/var/mail 144K 197G 88K /var/mail zroot/original/var/tmp 104K 197G 88K /var/tmp zroot/tmp 1.26M 197G 88K /tmp zroot/usr1 1.26G 197G 1.26G /zroot/usr1 zroot/var1 6.01G 197G 6.01G /zroot/var1 root@mfsbsd:~ #
Let’s fix up that var anomaly shall we?
root@mfsbsd:~ # zfs rename zroot/var1 zroot/var root@mfsbsd:~ # zfs rename zroot/original/var/audit zroot/var/audit root@mfsbsd:~ # zfs rename zroot/original/var/crash zroot/var/crash root@mfsbsd:~ # zfs rename zroot/original/var/log1 zroot/var/log root@mfsbsd:~ # zfs rename zroot/original/var/mail zroot/var/mail root@mfsbsd:~ # zfs rename zroot/original/var/tmp zroot/var/tmp root@mfsbsd:~ # zfs list NAME USED AVAIL REFER MOUNTPOINT zroot 8.63G 197G 88K /zroot zroot/ROOT 278M 197G 88K none zroot/ROOT/default1 278M 197G 275M /zroot/default1 zroot/original 1.08G 197G 88K /zroot/original zroot/original/default 479M 197G 477M / zroot/original/log 776K 197G 172K /zroot/original/log zroot/original/usr 625M 197G 88K /usr zroot/original/usr/home 188K 197G 124K /usr/home zroot/original/usr/local 625M 197G 625M /usr/local zroot/original/var 88K 197G 88K /var zroot/tmp 1.26M 197G 88K /tmp zroot/usr1 1.26G 197G 1.26G /zroot/usr1 zroot/var 6.01G 197G 6.01G /zroot/var zroot/var/audit 88K 197G 88K /zroot/var/audit zroot/var/crash 88K 197G 88K /zroot/var/crash zroot/var/log 2.48M 197G 2.48M /zroot/var/log zroot/var/mail 144K 197G 88K /zroot/var/mail zroot/var/tmp 104K 197G 88K /zroot/var/tmp root@mfsbsd:~ #
Next up, usr:
root@mfsbsd:~ # zfs rename zroot/usr1 zroot/usr root@mfsbsd:~ # zfs rename zroot/original/usr/home zroot/usr/home root@mfsbsd:~ # zfs list NAME USED AVAIL REFER MOUNTPOINT zroot 8.63G 197G 88K /zroot zroot/ROOT 278M 197G 88K none zroot/ROOT/default1 278M 197G 275M /zroot/default1 zroot/original 1.08G 197G 88K /zroot/original zroot/original/default 479M 197G 477M / zroot/original/log 776K 197G 172K /zroot/original/log zroot/original/usr 625M 197G 88K /usr zroot/original/usr/local 625M 197G 625M /usr/local zroot/original/var 88K 197G 88K /var zroot/tmp 1.26M 197G 88K /tmp zroot/usr 1.26G 197G 1.26G /zroot/usr zroot/usr/home 188K 197G 124K /zroot/usr/home zroot/var 6.01G 197G 6.01G /zroot/var zroot/var/audit 88K 197G 88K /zroot/var/audit zroot/var/crash 88K 197G 88K /zroot/var/crash zroot/var/log 2.48M 197G 2.48M /zroot/var/log zroot/var/mail 144K 197G 88K /zroot/var/mail zroot/var/tmp 104K 197G 88K /zroot/var/tmp root@mfsbsd:~ #
Then much more happened…
Nope, not going to show my work
This is getting complex in my head and I’m having trouble keeping it straight *and* documenting it at the same time.
Instead, I will work on it and show my work later.
The rabbit hole ends here
This is what I have now
This is what I have now
After sitting down and quietly thinking about where things were, I have this:
root@mfsbsd:~ # zpool import -o altroot=/import zroot root@mfsbsd:~ # zfs list NAME USED AVAIL REFER MOUNTPOINT zroot 8.63G 197G 96K /import/zroot zroot/ROOT 278M 197G 88K none zroot/ROOT/default 278M 197G 275M /import zroot/original 481M 197G 88K none zroot/original/default 480M 197G 477M none zroot/original/log 776K 197G 172K none zroot/original/usr 88K 197G 88K none zroot/original/var 88K 197G 88K none zroot/tmp 1.11M 197G 88K /import/tmp zroot/usr 1.87G 197G 1.26G /import/usr zroot/usr/home 188K 197G 124K /import/usr/home zroot/usr/local 625M 197G 625M /import/usr/local zroot/var 6.01G 197G 6.01G /import/var zroot/var/audit 88K 197G 88K /import/var/audit zroot/var/crash 88K 197G 88K /import/var/crash zroot/var/log 2.63M 197G 2.52M /import/var/log zroot/var/mail 144K 197G 88K /import/var/mail zroot/var/tmp 112K 197G 88K /import/var/tmp root@mfsbsd:~ #
I have compared various things between the old drives and the new drives. This includes directory listings for:
- /
- /etc
- /usr
- /usr/local
- /usr/local/etc
- /usr/local/etc/rc.d
I also visually compared /etc/rc.conf on both sets of drives.
I want to try booting from the new drives first. I can’t do that until later today.
Things left to do
I need to do another round of zfs send | zfs recv before this goes live.
Add a different IP address so this doesn’t boot and conflict with the production server. I thought I might be able to use /etc/rc.conf.local to override settings within /etc/rc.conf. Then I realized there were 36 ifconfig_ix2_alias entries to change… I didn’t bother.
Instead, I saved the original rc.conf away, and created a temporary one.
# cat /import/etc/rc.conf
defaultrouter=”10.0.0.1″
ifconfig_ix2=”inet 10.0.0.56 netmask 255.255.255.0″
hostname=”newslocum.int.unixathome.org”
#gateway_enable=”YES”
ntpd_enable=”YES”
ntpd_flags=”-L”
daily_ntpd_leapfile_enable=”YES”
daily_ntpd_avoid_congestion=”YES”
keymap=”us”
sshd_enable=”YES”
zfs_enable=YES
First boot attempt
The first boot failed. Nothing in /dev. Here’s a couple of screen shots I took. This is an aging but useful monitor. Please forgive the haziness of the top few lines.
I rebooted into mfsBSD, imported the zpool (with an altroot) and found:
root@mfsbsd:~ # zpool import -o altroot=/import zroot root@mfsbsd:~ # cd /import/dev root@mfsbsd:/import/dev # ls -l total 1 lrwxr-xr-x 1 root wheel 12 Jun 14 16:36 log -> /var/run/log -rw-r--r-- 1 root wheel 0 Jun 15 21:08 null
Oh. Damn.
And that’s where I stopped.