Improving Repair Ability of the FreeBSD Installer
Student: ChunChengYeh (leafoliage@FreeBSD.org)
Mentor: PierrePronchery, LiWenHsu (lwhsu@FreeBSD.org)
Project description
This project aims to improve the FreeBSD installer in three aspects: adding a repair menu, adding an upgrade menu and modifying the liveCD environment to facilitate pkg install. The repair menu would allow users to choose existing partitions in a computer to mount and access for further inspection and repair. The upgrade menu would allow users to choose existing systems to upgrade to newer version. Lastly, the liveCD would be modified to allow pkg installation within out of the box.
Approach to solving the problem
Repair Menu
- Use gpart to filter root partition
- Write a script to list partitions and mount them for access upon selection
Upgrade Menu
- Write a fully/partially automatic upgrade script
- Write a script to list existing systems to upgrade
Pkg Installation Support
- specify a tmpfs as /usr/local to be included in /etc/fstab
- Modify /tmp size
- configure dhcp in startbsdinstall
Deliverables
- A repair menu listing partitions to mound and access
- An upgrade menu listing systems to upgrade
- Allow pkg install in LiveCD out of the box
Milestones
Repair Menu
- Grep and mount file systems manually
- Add a bsdinstall menu button: Repair
- Implement script that lists mountable partitions, and mounts partition upon select
Upgrade Menu
- Write an automatic update script
- Add a bsdinstall menu button: Update
- Implement script that lists updatable partitions, and updates it upon select
Pkg Installation Support
- Mount /usr/local tmpfs upon selecting live environment
- Configure network with either bsdconfig/bsdinstall/dhcp
- Configure pkg so that it works out of the box
Test Plan
- Test out repair menu with one/several system with zfs/ufs (if it can correctly identify partitions and mount)
- Test out upgrade menu with one/several system (if it can correctly identify systems and upgrade smoothly)
- Test out pkg install once boot into the LiveCD environment
Project Work Result
Repair Menu
I implemented a menu that looks for freebsd-ufs partitions and zfs pools. They are listed out so that users can choose which partition to mount. After choosing, users can decided whether they want to perform inspections, such as fsck or mtree, with another menu.
The repair menu can deal with systems that has ufs or zfs installed in the officially recommended way. For a ufs installed system, it mounts the selected partition at /mnt. For a zfs installed partition, it imports the selected pool at the mountpoint /mnt. In both cases, the selected inspection is run one by one after they're chosen.
Upgrade Menu
This menu looks for partitions to upgrade. It utilizes the released files tarball and a pre-built etcupdate tree included in the installer to compare with the existing system and upgrade.
The upgrade menu and script prepares an etcupdate tree of the new release in advance and mount the selected partitions at /mnt/system. It compares base.txz and kernel.txz archive contents with /mnt/system directory contents to decide whether a file should be added, modified or removed, and install the changes accordingly. It then runs etcupdate with the pre-built tree to update etc files, and runs pkg upgrade to upgrade packages.
Pkg Installation Support
Network configuration and pkg bootstrapping is called upon exiting into live environment. A tmpfs is mounted under /usr/local where pkgs are extracted.
What's left to do
For the repair menu, there isn't a comprehensive way to detect existing freebsd partitions so that any customly installed system can be detected. Also, there are currently only 2 inspection options for ufs and zfs each, so any suggestion for inspecting partitions is encouraged.
For the upgrade menu, the script lacks a comprehensive ability to detect existing system. The upgrade process itself requires more testing to rule out any error it might cause, and its efficiency of installing modified changes should be improved.
For both parts, unit testing and end-to-end testing are still unsupported and encouraged to be implemented.
The Code
Here is the pull request of my work: freebsd/freebsd-src - GSoC 2024-Improving Installer with Repair and Upgrade Ability
How to run this code
Apply the changes to the corresponding files in /usr/src according to this PR
cd /usr/src
make clean and then make cdrom (or make memstick)
Installation would be built under /usr/obj
Status Report
Date |
Description |
|
6/14 |
Added /usr/local tmpfs. Tried grepping and mounting ufs and zfs partition. |
|
6/26 |
Added network setting in live environment. Added repair menu listing ufs partitions and zpools. |
|
7/3 |
Added pkg bootstrap option in live environment. Added simple repair script (fsck, mtree) after target repairing partition mounted. |
|
7/10 |
Added a selection menu for the repair script to select which repairing commands to use. |
|
8/1 |
Tried out several approaches to see if I can upgrade a system with base.txz and kernel.txz in the installer. |
|
8/8 |
Reference freebsd-update and build from source update to devise a prodedure to upgrade with installer. |
|
8/15 |
Studied freebsd-update and etcupdate, and modified upgrade script. |
|
8/23 |
Fixed upgrade scriptto avoid excessive memory usage. Wrapped up GSoC work. |