LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-24-2019, 04:22 AM   #1
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Sometimes lxc-slackware breaks due to erroneously created ${DEV}/null file


Some packages may redirect stderr to /dev/null during container creation. When the script tries to execute
Code:
mknod -m 666 ${DEV}/null c 1 3
in the configuration stage it will abort with an error. This patch mitigates the problem.
Code:
--- lxc-slackware.org   2019-11-24 10:50:33.428626035 +0100
+++ lxc-slackware.mod   2019-11-24 11:02:37.717571177 +0100
@@ -90,6 +90,12 @@
 # http://www.vislab.uq.edu.au/howto/lxc/MAKEDEV.sh
 DEV=$rootfs/dev
 mkdir -p ${DEV}
+
+# Some install scripts may have redirected stderr to
+# /dev/null and thus created a file named /dev/null.
+# It must be removed before attempting to create
+# the device /dev/null.
+[[ -e ${DEV}/null ]] && rm -rf ${DEV}/null
 mknod -m 666 ${DEV}/null c 1 3
 mknod -m 666 ${DEV}/zero c 1 5
 mknod -m 666 ${DEV}/random c 1 8
PS:
I am aware that the test '[[ -e ${DEV}/null ]]' is probably redundant and that I am overly cautious here.

Last edited by crts; 11-24-2019 at 04:27 AM.
 
Old 11-24-2019, 11:00 PM   #2
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 2,494

Rep: Reputation: 8437Reputation: 8437Reputation: 8437Reputation: 8437Reputation: 8437Reputation: 8437Reputation: 8437Reputation: 8437Reputation: 8437Reputation: 8437Reputation: 8437
Fixed, thanks.
 
2 members found this post helpful.
Old 01-02-2020, 01:41 PM   #3
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Original Poster
Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
More issues came up which required some more modifications:

Code:
--- lxc-slackware.orig  2020-01-01 22:22:21.504770334 +0100
+++ lxc-slackware.new   2020-01-01 22:29:30.263410113 +0100
@@ -90,25 +90,48 @@
 # http://www.vislab.uq.edu.au/howto/lxc/MAKEDEV.sh
 DEV=$rootfs/dev
 mkdir -p ${DEV}
+
+# some install scripts may redirect stderr to /dev/null
+# if /dev/null does not exist then this will lead to an error
+[[ -e ${DEV}/null ]] && rm -rf ${DEV}/null
 mknod -m 666 ${DEV}/null c 1 3
+[[ -e ${DEV}/zero ]] && rm -rf ${DEV}/zero
 mknod -m 666 ${DEV}/zero c 1 5
+[[ -e ${DEV}/random ]] && rm -rf ${DEV}/random
 mknod -m 666 ${DEV}/random c 1 8
+[[ -e ${DEV}/urandom ]] && rm -rf ${DEV}/urandom
 mknod -m 666 ${DEV}/urandom c 1 9
+[[ -e ${DEV}/pts ]] && rm -rf ${DEV}/pts
 mkdir -m 755 ${DEV}/pts
+[[ -e ${DEV}/shm ]] && rm -rf ${DEV}/shm
 mkdir -m 1777 ${DEV}/shm
+[[ -e ${DEV}/tty ]] && rm -rf ${DEV}/tty
 mknod -m 666 ${DEV}/tty c 5 0
+[[ -e ${DEV}/console ]] && rm -rf ${DEV}/console
 mknod -m 600 ${DEV}/console c 5 1
+[[ -e ${DEV}/tty0 ]] && rm -rf ${DEV}/tty0
 mknod -m 666 ${DEV}/tty0 c 4 0
+[[ -e ${DEV}/tty1 ]] && rm -rf ${DEV}/tty1
 mknod -m 666 ${DEV}/tty1 c 4 1
+[[ -e ${DEV}/tty2 ]] && rm -rf ${DEV}/tty2
 mknod -m 666 ${DEV}/tty2 c 4 2
+[[ -e ${DEV}/tty3 ]] && rm -rf ${DEV}/tty3
 mknod -m 666 ${DEV}/tty3 c 4 3
+[[ -e ${DEV}/tty4 ]] && rm -rf ${DEV}/tty4
 mknod -m 666 ${DEV}/tty4 c 4 4
+[[ -e ${DEV}/tty5 ]] && rm -rf ${DEV}/tty5
 mknod -m 666 ${DEV}/tty5 c 4 5
+[[ -e ${DEV}/full ]] && rm -rf ${DEV}/full
 mknod -m 666 ${DEV}/full c 1 7
+[[ -e ${DEV}/initctl ]] && rm -rf ${DEV}/initctl
 mknod -m 600 ${DEV}/initctl p
+[[ -e ${DEV}/loop0 ]] && rm -rf ${DEV}/loop0
 mknod -m 660 ${DEV}/loop0 b 7 0
+[[ -e ${DEV}/loop1 ]] && rm -rf ${DEV}/loop1
 mknod -m 660 ${DEV}/loop1 b 7 1
+[[ -e ${DEV}/ptmx ]] && rm -rf ${DEV}/ptmx
 ln -s pts/ptmx ${DEV}/ptmx
+[[ -e ${DEV}/fd ]] && rm -rf ${DEV}/fd
 ln -s /proc/self/fd ${DEV}/fd
 
 echo "Adding an etc/fstab that must be modified later with the"
@@ -123,11 +146,11 @@
 
 # Back up the existing init scripts and install the lxc versions:
 ( cd $rootfs/etc/rc.d
-  cp -a /usr/share/lxc/scripts/slackware/* .
-  chmod 755 *.lxc
-  for file in *.lxc ; do
-    cp -a $(basename $file .lxc) $(basename $file .lxc).orig
-    cp -a $file $(basename $file .lxc)
+  for file in /usr/share/lxc/scripts/slackware/*.lxc ; do
+    base=$(basename $file .lxc)
+    cp -a $base $base.orig
+    cp -a $file $base
+    chmod 755 $base
   done
 )
A few more files (e.g. dev/zero) were created by the install scripts causing errors when mknod or ln was called. As a precaution I changed the script to check and delete any file if it already exists.


Another issue was that originally the script would first copy all *.lxc files into /etc/rc.d and then erroneously assume that every file that has an *.lxc suffix is a replacement for another "regular" script. This, however, is not true for rc.lxc where .lxc is not a suffix indicating a replacement script. The original script would strip this suffix and then try to execute
Code:
cp rc rc.orig
The patch addresses this issue, too, by deriving the basenames from /usr/share/lxc/scripts/slackware instead of from within $rootfs/etc/rc.d after they are copied.
 
1 members found this post helpful.
  


Reply

Tags
container, lxc


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] "lxc list" vs "lxc-ls" yknivag Linux - Virtualization and Cloud 1 03-09-2017 05:53 AM
[SOLVED] Stopping cron job emails to root, do I use >/dev/null 2>&1 or &> /dev/null anon091 Linux - Newbie 3 11-12-2013 10:21 AM
What is meant by " file > /dev/null 2>&1 </dev/null " attockonian Linux - Newbie 5 06-30-2006 10:51 PM
1> /dev/null 2> /dev/null elyk Programming 9 09-20-2004 05:44 PM
1>/dev/null 2>/dev/null chr15t0 Linux - General 2 07-19-2002 08:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration