The beginning of something new...
This commit is contained in:
62
ipk-source/sdxlemur-mount-fix/mount-fix-sdxlemur
Executable file
62
ipk-source/sdxlemur-mount-fix/mount-fix-sdxlemur
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
|
||||
newroot() {
|
||||
/bin/echo "Begin mount fix process to make a usable userspace"
|
||||
|
||||
# Forcefully unmount /etc
|
||||
/bin/echo "Unmounting the bind at /etc"
|
||||
/bin/umount -lf /etc
|
||||
|
||||
# Remount root filesystem as read-write
|
||||
/bin/echo "Remounting / as read-write"
|
||||
/bin/mount -o remount,rw /
|
||||
|
||||
# Make mount namespaces private
|
||||
mount --make-rprivate /
|
||||
mount --make-rprivate /usrdata
|
||||
|
||||
# Ensure necessary directories exist for overlay and pivot_root
|
||||
/bin/echo "Creating new overlay system"
|
||||
if [ ! -d /data/rootfs ]; then
|
||||
mkdir -p /data/rootfs
|
||||
fi
|
||||
if [ ! -d /data/rootfs-workdir ]; then
|
||||
mkdir -p /data/rootfs-workdir
|
||||
fi
|
||||
if [ ! -d /rootfs ]; then
|
||||
mkdir -p /rootfs
|
||||
fi
|
||||
|
||||
# Mount the new overlay filesystem
|
||||
/bin/mount -t overlay overlay -o lowerdir=/,upperdir=/data/rootfs,workdir=/data/rootfs-workdir /rootfs
|
||||
|
||||
# Create the real_rootfs directory in the new root
|
||||
if [ ! -d /rootfs/real_rootfs ]; then
|
||||
mkdir -p /rootfs/real_rootfs
|
||||
fi
|
||||
|
||||
# Pivot root to the new root
|
||||
/bin/echo "Pivoting Root / to /rootfs; Be back soon!!"
|
||||
/sbin/pivot_root /rootfs /rootfs/real_rootfs >/dev/null 2>&1
|
||||
|
||||
# Move the mounted filesystems to the new locations
|
||||
/bin/mount --move /real_rootfs/sys /sys
|
||||
/bin/mount --move /real_rootfs/proc /proc
|
||||
/bin/mount --move /real_rootfs/tmp /tmp
|
||||
/bin/mount --move /real_rootfs/dev /dev
|
||||
/bin/mount --move /real_rootfs/firmware /firmware
|
||||
/bin/mount --move /real_rootfs/persist /persist
|
||||
/bin/mount --move /real_rootfs/cache /cache
|
||||
/bin/mount --move /real_rootfs/data /data
|
||||
/bin/mount --move /real_rootfs/run /run
|
||||
/bin/mount --move /real_rootfs/etc/machine-id /etc/machine-id
|
||||
/bin/mount --move /real_rootfs/var/volatile /var/volatile
|
||||
/bin/mount --move /real_rootfs/systemrw /systemrw
|
||||
|
||||
echo "Complete"
|
||||
}
|
||||
|
||||
newroot
|
||||
|
||||
Reference in New Issue
Block a user