Opened 3 months ago

Closed 2 months ago

#4848 closed task (fixed)

make /lib, /bin, /sbin symlinks to their conterpart in /usr

Reported by: Xi Ruoyao Owned by: Douglas R. Reno
Priority: normal Milestone: 11.0
Component: Book Version: git
Severity: normal Keywords:
Cc:

Description (last modified by Xi Ruoyao)

Support of "split-usr" configuration is deprecated in systemd-248, and likely to be removed in systemd-249.

Fedora and Arch have already made the move.

Specific to LFS, the main advantage of the move is we can delete all mv /usr/lib/libfoo.so.* /lib && ln -sfv ../../lib/$(...) /usr/lib/libfoo.so stuff. The main disadvantage is we'll have to use an initramfs if /usr is somewhere on network (but I doubt if there is really someone using LFS/BLFS this way).

It's planned to make the move for both sysv and systemd. The steps:

  • [x] rewrite section 4.2 and section 7.5. In section 4.2 we'll set up {/usr,}/{lib,bin,sbin}, and the references to them should be removed in 7.5.
  • [x] modify section 4.3 for the changes of 4.2
  • [x] remove -Dsplit-usr=true in systemd
  • [x] remove all mv /usr/lib/libfoo.so.* /lib ... commands in LFS
  • [ ] build and test LFS
  • [ ] remove all mv /usr/lib/libfoo.so.* /lib ... commands in BLFS

Change History (14)

comment:1 by Xi Ruoyao, 3 months ago

Description: modified (diff)

comment:2 by Xi Ruoyao, 3 months ago

Description: modified (diff)

Initial changes are staged in branch xry111/usr-move now.

I think we can keep options like --libdir=/lib or --bindir=/bin there. Removing them for only systemd will cost too much work, and won't give significant improve (to readers) like removing explicit mv -vs.

I'll rebuild the system as a test, when GCC 11 is released.

And I hope I didn't introduce something breaking jhalfs...

comment:3 by Xi Ruoyao, 3 months ago

A clarification: systemd stops to support split-usr does *not* mean you can't use a separate partition for /usr. It means /bin, /sbin, /lib, and /lib64 have to be a symlink to its counterpart in /usr, to be supported.

If you want a separate /usr partition, you can use an initramfs anyway.

For example, "ProtectSystem=true" makes systemd bind-mounts /usr, /bin, /sbin, /lib, and /lib64 for a service. In future systemd releases it will only consider /usr, so if /bin or /lib is not a symlink to /usr/bin or /usr/lib, its content will *not* be protected anymore.

comment:4 by Xi Ruoyao, 3 months ago

Another clarification: it won't break any scripts hardcoding /usr/bin or /bin. Every utilitiy is in /usr/bin, and /bin is a symlink to /usr/bin. So you can use the utilities with both path.

comment:5 by Xi Ruoyao, 3 months ago

Description: modified (diff)
Summary: make /lib, /lib64, /bin, /sbin symlinks to their conterpart in /usrmake /lib, /bin, /sbin symlinks to their conterpart in /usr

We'll keep /lib64 there: the existence of /usr/lib64 causes meson trying to install every library into it.

As /lib64 only contains two symlinks, it should be OK.

comment:6 by Bruce Dubbs, 3 months ago

The following pages move libraries to /lib:

chapter08/zlib.xml
chapter08/xz.xml
chapter08/libcap.xml
chapter08/readline.xml
chapter08/shadow.xml
chapter08/ncurses.xml
chapter08/file.xml
chapter08/acl.xml
chapter08/procps.xml
chapter08/attr.xml
chapter08/dbus.xml
chapter08/zstd.xml

The following page moves an executable to /sbin:

chapter08/inetutils.xml

The following pages move an executable to /bin:

chapter08/bash.xml
chapter08/xz.xml
chapter08/coreutils.xml {3 places)
chapter08/psmisc.xml (2 places)
chapter08/shadow.xml
chapter08/findutils.xml
chapter08/gzip.xml
chapter08/inetutils.xml (2 places)

comment:7 by Xi Ruoyao, 3 months ago

A modified LFS book is staged in xry111/usr-move branch. It can be viewed at https://www.linuxfromscratch.org/~xry111/lfs-usr-move-ga68ea9a1c-systemd/.

comment:8 by Xi Ruoyao, 3 months ago

Description: modified (diff)
Version: systemdgit

Now for both sysv and systemd.

comment:9 by Xi Ruoyao, 3 months ago

Description: modified (diff)

usr-move branch updated for both sysv and systemd. Rendered version can be viewed at https://www.linuxfromscratch.org/~xry111/usr-move/.

sysv is not tested yet.

And there are still cleanups not done yet: some --bindir=/bin, --libdir=/lib, --sbindir=/sbin or --exec-prefix= can be removed in theory.

comment:10 by Bruce Dubbs, 3 months ago

Milestone: 10.211.0

Milestone renamed

comment:11 by Douglas R. Reno, 3 months ago

Owner: changed from lfs-book to Douglas R. Reno
Status: newassigned

comment:12 by Xi Ruoyao, 3 months ago

Some new commits added. The rendered version (r10.1-89) is in https://www.linuxfromscratch.org/~xry111/usr-move/.

comment:13 by Douglas R. Reno, 3 months ago

I've got those in my sandbox now. I should be able to commit these sometime over the next day or so. Please let me know before you commit anything else to that branch

comment:14 by Douglas R. Reno, 2 months ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.