Olaf Hering
2021-Sep-15 10:58 UTC
[Libguestfs] [PATCH v1] appliance: reorder mounting of special filesystems in init
Make sure proc and dev are available early. No change in behavior intended. Signed-off-by: Olaf Hering <olaf at aepfle.de> --- appliance/init | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/appliance/init b/appliance/init index cdc39c3b9..7076821d2 100755 --- a/appliance/init +++ b/appliance/init @@ -27,12 +27,12 @@ for d in /lib64 /lib; do fi done -mkdir -p /sysroot - -# Mount /proc. -if [ ! -d /proc ]; then rm -f /proc; fi -mkdir -p /proc +mkdir -p /proc /sys mount -t proc /proc /proc +mount -t sysfs /sys /sys +# devtmpfs is required since udev 176 +mount -t devtmpfs /dev /dev +ln -s /proc/self/fd /dev/fd # Parse the kernel command line early (must be after /proc is mounted). cmdline=$(</proc/cmdline) @@ -54,34 +54,28 @@ if [[ $cmdline == *guestfs_boot_analysis=1* ]]; then guestfs_boot_analysis=1 fi -# Mount the other special filesystems. -if [ ! -d /sys ]; then rm -f /sys; fi -mkdir -p /sys -mount -t sysfs /sys /sys +mkdir -p /dev/pts /dev/shm +mount -t devpts /dev/pts /dev/pts +mount -t tmpfs -o mode=1777 shmfs /dev/shm + +mkdir -p /sysroot + # taken from initramfs-tools/init --Hilko Bengen mkdir -p /run mount -t tmpfs -o "nosuid,size=20%,mode=0755" tmpfs /run mkdir -p /run/lock ln -s ../run/lock /var/lock +if [[ $cmdline == *selinux=1* ]]; then + mount -t selinuxfs none /sys/fs/selinux +fi + # On Fedora 23, util-linux creates /etc/mtab in %post .. stupid # and e2fsprogs fails if the link doesn't exist .. stupid stupid if ! test -e /etc/mtab; then ln -s /proc/mounts /etc/mtab fi -# devtmpfs is required since udev 176 -mount -t devtmpfs /dev /dev -ln -s /proc/self/fd /dev/fd -mkdir -p /dev/pts -mount -t devpts /dev/pts /dev/pts -mkdir -p /dev/shm -mount -t tmpfs -o mode=1777 shmfs /dev/shm - -if [[ $cmdline == *selinux=1* ]]; then - mount -t selinuxfs none /sys/fs/selinux -fi - # Static nodes must happen before udev is started. # Set up kmod static-nodes (RHBZ#1011907).
Richard W.M. Jones
2021-Sep-15 11:39 UTC
[Libguestfs] [PATCH v1] appliance: reorder mounting of special filesystems in init
On Wed, Sep 15, 2021 at 12:58:23PM +0200, Olaf Hering wrote:> Make sure proc and dev are available early. > No change in behavior intended. > > Signed-off-by: Olaf Hering <olaf at aepfle.de>Thanks - I pushed both patches. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top