Contents
Mount /usr in the initramfs
Introduction
Traditionally, /usr has been mounted in mountall, as for any filesystem in /etc/fstab other than the root filesystem (or special filesystems like /proc and /dev). This has several implications:
- Programs, libraries and data under /usr are not available in the early stages of booting
- Programs in /bin and /sbin can not assume /usr is available
- init scripts need to cope with /usr being unavailable in early boot
- This causes particular problems with shared libraries, PAM modules, NSS module dependencies, etc. as well as locale availability.
If /usr could be guaranteed to be available by mounting it in the initramfs, these problems can also be overcome. This permits all shared libraries, PAM modules, NSS modules etc. to function at once. It also allows locales to be used at once as well. Additionally, it is possible to use C++ (libstdc++ is under /usr), and interpreters such as perl and python, etc. In short, it makes a large number of things possible which were previously not possible, and this will both allow greater flexibility in what can run in the early stages of booting, as well as removing a large number of special cases and hairy logic which existed solely to cope with /usr not being available.
Initial implementation
In the initramfs, we check the root filesystem before mounting it. Once it is mounted, the /etc/fstab on the root filesystem can be read, and if it contains an entry for /usr, we check and mount it.
As fsck will sanity-check timestamps, we also include everything in the initramfs needed to set the system time correctly if the the RTC holds local time.
The -R option of /sbin/fsck, used to check all filesystems except the root filesystem, could be updated so that it will also ignore /usr, or else at boot the checkfs script will try to fsck a mounted /usr. Alternatively the initscripts can use the -M option.
It was proposed that the initscripts should be updated to treat /usr like the root filesystem:
- Remount r/o
- Check
- Remount r/w
- Remount r/o at shutdown and don't umount
But this doesn't work because e2fsck and probably other fsck implementations don't allow checking a filesystem mounted anywhere other than /.
Caveats
The main caveat is that if you use a separately mounted /usr, you must use an initramfs to mount it. While not using an initramfs will continue to be supported, this will only work if you have /usr on the root filesystem (i.e. it's a single mount). This is because mounting /usr in the traditional way will cause startup to fail since it's mounted too late (this will only happen once init scripts start relying on /usr to be available immediately).
|
initramfs |
No initramfs |
root only |
Supported |
Supported |
root and /usr |
Supported |
Broken |
The initramfs will support / and /usr mounts on local/local and nfs/nfs. However, it it not yet clear if this will extend to local/nfs and/or nfs/local. This will break quite a number of existing Debian installations.
Required changes
Update initramfs to fsck and mount /usr
Update initscripts to use the fsck -M option (697002)
- Update initscripts to remount r/o when shutting down
Bug reports
When filing bugs, please use
User: rleigh@debian.org Usertags: usrinitramfs
- so they are properly tagged.
Patches
initramfs-tools
Similar changes have been made in initramfs 0.117 and various regressions were fixed in 0.118. This now works with systemd, but mounting of /usr is disabled when using any other init.
initscripts (sysvinit)
TODO
