DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 6 Days Ago
bradley bradley is offline
Port Guard
 
Join Date: Jul 2020
Posts: 32
Default Changing FFS1 to FFS2 on OpenBSD - Steps

25 years OpenBSD was just celebrated! As we can see time flies like an arrow! I'm mentioning this because FFS2 is using 64 bit timestamps, but not FFS1.

It means we may not forget the year 2038 problem, meaning the seconds counting from January 1, 1970 00:00:00 UTC will exceed after 19 January 2038 03:14:07 UTC the maximum 32 bit value. I often see people asking about FFS2 and for myself thinking about this issue every time I sleep in the coming less than twenty years is just waaay too much pressure. This is why I decided to change the file system right now on my desktop machine and wrote down the steps.
-------------------------------------------------------------------------------------------------------------------------------
FFS1 -> FFS2

In general the process is about creating a .dump file for every partition, format those partitions as FFS2 and recover the partitions using the .dump files. Before doing this task it's important to understand all the steps, the syntax and - as always - making a backup of the system.


You can check the file system type on OpenBSD using:
Code:
doas dumpfs /home | head -1
or for root:
Code:
doas dumpfs / | head -1
In the process I created the .dump file for /home on the /var partition (I had enough free space there):
Code:
doas dump -0a -f /var/home.dump /home
I did this because it made me possible to restore /home later in the process from that partition. Same for the other partitions but I used /home (NOT the User directory!) for .dump files:
Code:
doas dump -0a -f /home/root.dump /
doas dump -0a -f /home/tmp.dump /tmp
doas dump -0a -f /home/usr.dump /usr
doas dump -0a -f /home/X11R6.dump /usr/X11R6
doas dump -0a -f /home/local.dump /usr/local
doas dump -0a -f /home/var.dump /var
At the boot prompt if you boot with 'boot -s' into single user mode, it won't be possible to change the file system for root (because it will be mounted), only for all the other partitions. If you use the ramdisk kernel via bsd.rd at the boot prompt, it will be possible to work on the root file system too.

So at the boot prompt using
Code:
bsd.rd
brings us a shell.

Here I checked the available devices via
Code:
sysctl hw.disknames
and also the cryptodrive (obviously it's only required if the system is on encrypted softraid):
Code:
bioctl softraid0
It's sd1 for me, using it requires:
Code:
chmod +x /dev/MAKEDEV
/dev/MAKEDEV sd1
Also might be required:
Code:
sh MAKEDEV sd1
Partitions should be available:
Code:
disklabel sd1
Next step is mounting the /home partition to /mnt:
Code:
mount /dev/sd1k /mnt
The .dump files in /mnt should be there.

Format the root partition (newfs requires a different syntax for the raw partition):
Code:
newfs -O2 /dev/rsd1a
Mount the newly formatted partition to /mnt2:
Code:
mount /dev/sd1a /mnt2
Cd into the folder:
Code:
cd mnt2
Restore the root partition via .dump file:
Code:
restore -rf /mnt/root.dump
That was it for root, cd back and umount the partition:
Code:
umount /mnt2
It was the same process for the other partitions, except /home (as the home.dump file was in my case on /var). After formatting the /var partition (for me it's on 'e', but ymmv):
Code:
newfs -O2 /dev/rsd1e
Mounted it:
Code:
mount /dev/sd1e /mnt2
Cd into mnt2:
Code:
cd mnt2
Restore:
Code:
restore -rf /mnt/var.dump
Cd back:
Code:
cd ..
Umount:
Code:
umount /mnt2
Also umount /home:
Code:
umount /mnt
Mount /var to /mnt, so home.dump will be available:
Code:
mount /dev/sd1e /mnt
Format the /home partition:
Code:
newfs -O2 /dev/rsd1k
Mount the newly formatted /home partition to /mnt2:
Code:
mount /dev/sd1k /mnt2
Cd into the folder:
Code:
cd mnt2
Restore:
Code:
restore -rf /mnt/home.dump
Cd back, umount and reboot:
Code:
cd ..
umount /mnt2
umount /mnt
reboot
fstab does NOT require changes as ffs there works fine for ffs2 too.

After reboot the file systems can be checked as before:
Code:
doas dumpfs / | head -1
If everything is fine, the .dump files from /home and /var can be removed.
Reply With Quote
  #2   (View Single Post)  
Old 5 Days Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,121
Default

Nice writeup! A couple of notes:
  • newfs(8) option -O 2 is now the default.
  • Reformatting and restoring the root partition can be done. For many, reinstalling will be easier. One must a) boot the RAMDISK kernel (/bsd.rd), b) select the shell, c) mount the partition containing the dump(8) file, d) mount a /tmp partition, because the RAMDISK /tmp is too small for restore(8), d) newfs(8) the "a" partition [1], e) restore(8) the filesystem, and f) install the boot blocks with installboot(8).
[1] This is where the admin first takes a deep calming breath, because there is no recovery except a bare-metal restore.
Reply With Quote
  #3   (View Single Post)  
Old 4 Days Ago
bradley bradley is offline
Port Guard
 
Join Date: Jul 2020
Posts: 32
Default

Thank you for the notes, @jggimi. For root I did use the mentioned steps a) - c) [see above, root.dump was on /home, which was mounted to /mnt with 'mount /dev/sd1k /mnt'], without the (first) d) - it did work for me without mounting a /tmp partition. The manual for restore(8) says there won't be rstmode* and rstdir* created in /tmp, if -r is used (and incremental restore doesn't play a role). newfs and restore - (second) d) and e) - are there (as pointed out -O2 is actually not needed):

Code:
newfs -O2 /dev/rsd1a
mount /dev/sd1a /mnt2
cd mnt2
restore -rf /mnt/root.dump
I cannot comment on f) regarding the boot blocks as I use grub and simply chainload OpenBSD. It was useful checking the manual as I forgot to mention that the 'restoresymtable' files, which appeared on the partitions, can be removed (if incremental restores do not play a role or the last incremental has been restored).
Reply With Quote
  #4   (View Single Post)  
Old 3 Days Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,121
Default

Thanks for clarifying.

I recommend everyone practice their full-restoration procedures at least once per year. Just in case. We backup our data due to fear ... but we restore in a panic, and it's better to practice those restoration procedures while we're in a calmer state.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ffs2 knasbas OpenBSD General 5 29th September 2012 01:07 PM
Advantages of FFS2 for /home on OpenBSD drm OpenBSD Installation and Upgrading 4 13th September 2012 08:25 PM
first steps toward an OpenBSD Apache server .. daemonfowl OpenBSD General 10 23rd February 2012 06:52 PM
First steps in Web Development Daffy Programming 1 26th November 2010 04:01 PM
FFS2 in OpenBSD, what do you need? Sunnz OpenBSD General 0 5th May 2008 08:05 AM


All times are GMT. The time now is 09:02 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick