From ada35e7544bd25cb6beba9949910ed0476034152 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Aug 2013 16:30:44 +0200 Subject: [rootfs-stage32] Mount a 10G tmpfs to /tmp if no ID44 partition was found --- .../opt/openslx/scripts/systemd-setup_partitions | 136 +++++++++++---------- 1 file changed, 73 insertions(+), 63 deletions(-) (limited to 'remote/rootfs') diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions index f162ec3a..bc5ce9c1 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions @@ -17,38 +17,48 @@ # General formatter for the /tmp partition on a local harddisk diskfm () { -local target="$1" -local fs -local path -for fs in xfs ext3 ext2 ; do - unset available - case $(cat /proc/filesystems) in - *${fs}*) available=yes;; - *) modprobe "${fs}" && available=yes;; - esac - if [ -n "${available}" ]; then - unset found - if which "mkfs.$fs" ; then - found=yes - case "mkfs.$fs" in - mkfs.xfs) - fopt="-f" - mopt="-o noexec" - ;; - mkfs.ext2) - fopt="-Fq" - mopt="-o nocheck,noexec" - ;; - mkfs.reiserfs) - fopt="-f" - mopt="-o noexec" - ;; - esac - mkfs.$fs ${fopt} "${target}" - fi - [ -n "$found" ] && break - fi -done + local target="$1" + local fs + local path + for fs in xfs ext3 ext2 ; do + unset available + case $(cat /proc/filesystems) in + *${fs}*) available=yes;; + *) modprobe "${fs}" && available=yes;; + esac + if [ -n "${available}" ]; then + unset found + if which "mkfs.$fs" ; then + found=yes + case "mkfs.$fs" in + mkfs.xfs) + fopt="-f" + mopt="-o noexec" + ;; + mkfs.ext2) + fopt="-Fq" + mopt="-o nocheck,noexec" + ;; + mkfs.reiserfs) + fopt="-f" + mopt="-o noexec" + ;; + esac + mkfs.$fs ${fopt} "${target}" + fi + [ -n "$found" ] && break + fi + done +} + +function mount_temp () { + mkdir -p /tmptmp + mv /tmp/* /tmp/.* /tmptmp/ 2> /dev/null + mount $@ /tmp || return 1 + chmod a+rwxt /tmp + mv /tmptmp/* /tmptmp/.* /tmp/ + rmdir /tmptmp + return 0 } # Check for local harddisks and appropriate partitions @@ -66,46 +76,46 @@ for hdpartnr in $(sed -n -e "/ 82 /p" "/etc/disk.partition" | sed -e "s/[[:space swapon "$hdpartnr" done -# We use special non assigned partition type (id44) for harddisk scratch +# We use special non assigned partition type (id44) for harddisk scratch # space, thus no normal filesystem will be incidentally deleted or # corrupted for hdpartnr in $(sed -n -e "/ 44 /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do - # check for supported filesystem and formatter - if diskfm "$hdpartnr"; then - # echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready - echo -e "$hdpartnr\t/tmp\t\tnoauto\t\tdefaults\t 0 0" >> "/etc/fstab" - mkdir -p /tmptmp - mv /tmp/* /tmp/.* /tmptmp/ - mount "$hdpartnr" /tmp - chmod a+rwxt /tmp - mv /tmptmp/* /tmptmp/.* /tmp/ - rmdir /tmptmp - break - else - echo "formatting failed for some reason" - fi # Made this non-forking, systemd should handle it - 2013-05-28 + # check for supported filesystem and formatter + if diskfm "$hdpartnr"; then + # echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready + mount_temp "$hdpartnr" || continue + echo -e "$hdpartnr\t/tmp\t\tnoauto\t\tdefaults\t 0 0" >> "/etc/fstab" + break + else + echo "formatting failed for some reason" + fi # Made this non-forking, systemd should handle it - 2013-05-28 done # Put detected linux partitions (83) into /etc/fstab with "noauto", special # partition 45 (persistent scratch) to /var/scratch and 46 to /var/openslx for partid in 83 45 46 ; do - for hdpartnr in $(sed -n -e "/ ${partid} /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do - mkdir -p "/media/${hdpartnr#/dev/*}" - if [ "${partid}" -eq 83 ]; then - echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/fstab" - elif [ "${partid}" -eq 45 ]; then - #mount -t auto ${hdpartnr} /media/${hdpartnr#/dev/*} - #ln -sf /media/${hdpartnr#/dev/*} /var/scratch - echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab" - elif [ "${partid}" -eq 46 ]; then - # Mount a home directory to (/mnt)/var/home - #mount -t auto ${hdpartnr} /mnt/media/${hdpartnr#/dev/*} \n\ - #test -d /mnt/media/${hdpartnr#/dev/*}/home && \ - # ln -sf /media/${hdpartnr#/dev/*} /var/home - echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab" - fi - done + for hdpartnr in $(sed -n -e "/ ${partid} /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do + mkdir -p "/media/${hdpartnr#/dev/*}" + if [ "${partid}" -eq 83 ]; then + echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/fstab" + elif [ "${partid}" -eq 45 ]; then + #mount -t auto ${hdpartnr} /media/${hdpartnr#/dev/*} + #ln -sf /media/${hdpartnr#/dev/*} /var/scratch + echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab" + elif [ "${partid}" -eq 46 ]; then + # Mount a home directory to (/mnt)/var/home + #mount -t auto ${hdpartnr} /mnt/media/${hdpartnr#/dev/*} \n\ + #test -d /mnt/media/${hdpartnr#/dev/*}/home && \ + # ln -sf /media/${hdpartnr#/dev/*} /var/home + echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab" + fi + done done mount -a +# Make huge tmpfs if nothing could be mounted for /tmp +if [ "$(mount | grep -c "on /tmp ")" = "0" ]; then + mount_temp -t tmpfs -o size=10G none +fi + -- cgit v1.2.3-55-g7522