![Debian Linux 라이브 시스템 toram: /dev/shm 장치를 열 수 없습니다.](https://linux55.com/image/229049/Debian%20Linux%20%EB%9D%BC%EC%9D%B4%EB%B8%8C%20%EC%8B%9C%EC%8A%A4%ED%85%9C%20toram%3A%20%2Fdev%2Fshm%20%EC%9E%A5%EC%B9%98%EB%A5%BC%20%EC%97%B4%20%EC%88%98%20%EC%97%86%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
Linux 시스템을 메모리에서만 실행하기 위해 하드 드라이브 설치에서 squashfs 라이브 시스템을 생성하는 쉘 스크립트를 작성했습니다.
하지만 toram 라이브 시스템을 실행하면 dmesg에서 다음 오류가 발생합니다.
systemd[1]: Failed to open /dev/shm device, ignoring: Inappropriate ioctl for device
이 오류에도 불구하고 토람 라이브 시스템은 문제 없이 실행되는 것으로 보입니다.
squashfs는 ACL을 지원하지 않지만 /media/username/ 디렉터리에는 ACL이 필요하기 때문에 이 스크립트는 설치된 Linux에서 사용자를 한 명만 생성할 때만 작동합니다.
스크립트는 다음과 같습니다.
#!/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`
편집하다:
명령을 실행하면 에 설치되어 있다고 df
표시됩니다 ./dev/shm
/run/live/medium
이 명령은 에도 설치 mount | grep medium
되었음을 알려줍니다 ./dev/shm
/usr/lib/live/mount/medium
시스템은 RAM에 squashfs가 포함된 파티션의 복사본을 보관하는 것으로 보입니다.
을(를) 제거하려고 하면 /run/live/medium
으로 인해 제거할 수 없다는 메시지가 나타납니다 the target is active
. 하지만 성공적으로 제거했습니다 /usr/lib/live/mount/medium
.
그래서 이러한 문제가 관련되어 있는지, 그리고 이를 제거할 수 있는 방법이 있는지 궁금합니다 /run/live/medium
.
답변1
/dev/shm
이는 일반적으로 tmpfs 또는 램디스크이므로 일반적이지 않은 환경에서 설치하는 것은 문제가 될 수 있습니다. systemd
전체 램디스크 환경에서는 램디스크 fs가 필요하지 않기 때문에 문제가 되지 않으므로 이를 올바르게 무시했습니다.
답변2
다음 2개의 명령을 추가하여 오류를 제거해 보십시오.# Mount Special Files Section
sudo test -L /dev/shm && sudo rm /dev/shm && sudo mkdir /dev/shm
sudo chmod 1777 /dev/shm
위 링크의 명령을 사용하여 chroot를 한 번만 입력하는 것이 좋습니다.
답변3
이는 라이브 시작의 버그로 인해 발생합니다. 오류는 다음과 같습니다업스트림이 수정되었습니다.하지만 출시에는 시간이 좀 걸릴 것입니다. 그 동안에는 오류 로그를 무시해도 됩니다(해롭지 않음). 아니면 직접 패치할 수도 있습니다.
if [ -f ${DEST}/lib/live/boot/9990-toram-todisk.sh ]; then
sed -i 's|dev="/dev/shm"|dev="tmpfs"|g' ${DEST}/lib/live/boot/9990-toram-todisk.sh
fi
버그 설명: live-boot는 tmpfs를 /dev/shm
장치 이름으로 마운트합니다. 그러나 tmpfs에는 실제로 기본 장치가 없으므로 장치 이름으로 무엇이든 사용할 수 있습니다. 일반적으로 tmpfs
사용합니다. 이를 사용 하면 systemd가 장치로 열려고 /dev/shm
시도 하지만 장치가 아니기 때문에 실패하므로 혼동됩니다./dev/shm
/dev/shm