Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: nim108 on September 21, 2015, 08:06:41 AM
-
So long story short, I have a live CD remaster that can either be running off CD (/dev/srX) or USB stick (/dev/sdX). My application is embedded in the initrd, but I have large files on the device that my application reads off of; therefore, I need to access it. For ease of access, I simply symlink a directory in /opt/dirlink that points to the device folder I need access to. Currently, in my bootlocal.sh, I have:
if grep -qs '/mnt/sr0' /proc/mounts; then
ln -s /mnt/sr0/dir /opt/dirlink
elif grep -qs '/mnt/sdb' /proc/mounts; then
ln -s /mnt/sdb/dir /opt/dirlink
else
...
fi
Problem with this is the mount points can change depending on the hardware (i.e. user may have no HDD in the system so it'd be sda instead or user may be using an external DVD device so sr0 may not even exist). So what is the best foolproof way to do this? If I can detect what the device the user is booting from (does TC have knowledge of this in one of its hooks?), it'd be a lot easier.
-
Not sure if it's 100% foolproof, but I use this:
TCE_DIR="$(readlink /etc/sysconfig/tcedir)"
TCE_DIR="${TCE_DIR#/mnt/}"
TCE_DIR="${TCE_DIR%%/*}"
So you could do:
/mnt/"$TCE_DIR"/dir
-
Linux cannot detect what device it booted from.
Linux does not start until after the boot loader has loaded the kernal and initrds and is no longer running.
The best you can do is include a fake boot code you can process to give you a hint.
-
It is not a must to have tcedir on the boot media. First, there is the option tce boot arg where you can set it to anywhere. Also, TC picks up the first tce dir found during startup. For example I'm booting a system from USB but using a tce dir on a hard disk partion.
It was already discussed few times here and the final conclusion is that no fool proof solution. Depending on your needs however you can find a solution which works if some special requirements met.
-
Thanks guys, because my tcedir is guaranteed to be on the live CD (this would be my "special requirement" as you call it bmarkus), I can use something like Misalf's solution which will work for now.
-
Use a label or UUID?
-
Use a label or UUID?
Not sure but I'll have to go with one of these other suggestions as Misalf's won't work. readlink /etc/sysconfig/tcedir shows up as /tmp/tce on my Live CD so that's a no go.
-
Since the CD/USB is guaranteed to be mounted when you start it up, for now I've resorted to using "mount" and grepping for the /mnt/path (i.e. /mnt/sr0 or /mnt/sdb). Unfortunately, there seems to be few reliable ways to do it.
-
I've run into this problem on previous projects where multiple devices maybe connected to the PC each with a version of TC installed. I resolved this issue by creating an empty file with a unique file name installed along with your remastered ISO, or tcz store. where you install to depends on the exact info you're looking for
We then mount all
search for the unique file name and grep for the specific path information looking for
then unmount all but the device at the path found
there is no doubt now as to the source whether cd/dvd, USB, HDD or specific partition etc
-
I've run into this problem on previous projects where multiple devices maybe connected to the PC each with a version of TC installed. I resolved this issue by creating an empty file with a unique file name installed along with your remastered ISO, or tcz store. where you install to depends on the exact info you're looking for
We then mount all
search for the unique file name and grep for the specific path information looking for
then unmount all but the device at the path found
there is no doubt now as to the source whether cd/dvd, USB, HDD or specific partition etc
Interesting approach!