Sample Header Ad - 728x90

Debian Linux live system toram: Failed to open /dev/shm device

1 vote
3 answers
863 views
I have written a shell script to create a squashfs live system from a hard drive installation, in order to have a linux system running only in ram. But when I run the toram live system, I have the following error in the dmesg: systemd: Failed to open /dev/shm device, ignoring: Inappropriate ioctl for device Despite this error, the toram live system seems to work without problems. The script works only if only one user is created on the installed Linux, because ACL are not supported by squashfs, but needed for the directory /media/username/. Here is the script:
#!/bin/bash
    
    # Destination directory:
    DEST=$HOME/squashfs
    
    sudo mkdir -p ${DEST}
    
    # Copying installation in destination directory:
    sudo rsync --progress --specials --perms -av -lXEog --delete / ${DEST} --one-file-system \
    --exclude=/proc/* --exclude=/tmp/* --exclude=/dev/* \
    --exclude=/sys/* --exclude=/boot/* \
    --exclude=/etc/mtab --exclude=${DEST}
    
    # Make /media/username ownership to the user, because squashfs doesn't support ACL
    MEDIA="$USER:$USER $DEST/media/$USER"
    sudo chown $MEDIA
    
    # Remove links to mounted drives in destination directory /media/username/:
    MEDIA="$DEST/media/$USER"
    sudo rm -f $MEDIA/*
    
    # Remove unwanted entries in fstab of the future live system: 
    sudo sed -i '/\/boot\/efi/d' ${DEST}/etc/fstab 
    sudo sed -i '/swap/d' ${DEST}/etc/fstab 
    sudo sed -i '/UUID=.*\ \/\ /d' ${DEST}/etc/fstab
    
    # Mount special files in order to chroot:
    sudo mount -o bind /proc ${DEST}/proc
    sudo mount -o bind /dev ${DEST}/dev
    sudo mount -o bind /dev/pts ${DEST}/dev/pts
    sudo mount -o bind /sys ${DEST}/sys
    sudo cp /etc/resolv.conf ${DEST}/etc/resolve.conf
    
    # upgrade the chrooted system, and install live-boot package 
    # as well as the lastest kernel: 
    sudo chroot ${DEST} apt-get update
    sudo chroot ${DEST} apt-get upgrade
    sudo chroot ${DEST} apt-get remove linux-image*
    sudo chroot ${DEST} apt-get install live-boot
    sudo chroot ${DEST} apt-get install linux-image-amd64
    sudo chroot ${DEST} apt-get clean
    sudo chroot ${DEST} apt clean
    
    # Umount the special files:
    sudo umount ${DEST}/proc
    sudo umount ${DEST}/dev/pts
    sudo umount ${DEST}/dev
    sudo umount ${DEST}/sys
    
    # Delete unwanted files:
    [ -n "$DEST" ] && sudo find ${DEST}/var/mail ${DEST}/var/lock ${DEST}/var/backups ${DEST}/var/tmp -type f -exec rm {} \;

    # Delete only OLD log files:
    [ -n "$DEST" ] && sudo find ${DEST}/var/log -type f -iregex '.*\.[0-9].*' -exec rm -v {} \;
    [ -n "$DEST" ] && sudo find ${DEST}/var/log -type f -iname '*.gz' -exec rm -v {} \;
    
    # Clean current log files:
    [ -n "$DEST" ] && sudo find ${DEST}/var/log -type f | while read file; do echo -n '' | sudo tee $file; done
    
    # Clean Pakcage cache:
    [ -n "$DEST" ] && sudo rm -v ${DEST}/var/cache/apt/archives/*.deb
    
    # Remove old kernel and initrd in the partition where will be installed the live system: 
    sudo rm -f /media/$USER/LIVE/live/initrd.img*
    sudo rm -f /media/$USER/LIVE/live/vmlinuz*    
    
    # Copy new kernel and initrd in the partition where will be installed the live system: 
    sudo mv -f ${DEST}/boot/initrd.img* /media/$USER/LIVE/live/initrd.img
    sudo mv -f ${DEST}/boot/vmlinuz* /media/$USER/LIVE/live/vmlinuz
    
    # Remove old shquashfs in the partition where will be installed the live system: 
    sudo rm -f /media/$USER/LIVE/live/filesystem.squashfs
    
    # Make the new squashfs:
    sudo mksquashfs ${DEST} /media/$USER/LIVE/live/filesystem.squashfs -xattrs -processors 4 -noappend -always-use-fragments

/media/$USER/LIVE/ is where the live system partition is mounted.
   
Then I boot the live system placed on a partition with the kernel options: toram boot=live
Edit: When I run df command, it tells me that /dev/shm is mounted on /run/live/medium. The command mount | grep medium tells me that /dev/shm is also mounted on /usr/lib/live/mount/medium. It seems the system keeps in RAM a copy of the partition where is the squashfs. When I want to umount /run/live/medium, it tells me that it is impossible because the target is active. But I have successfully umounted /usr/lib/live/mount/medium. So I wonder if these problems are linked and if there is a way to umount /run/live/medium ?
Asked by Bertrand125 (1070 rep)
Feb 10, 2024, 04:08 PM
Last activity: Apr 10, 2024, 09:16 PM