Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
eject cd before reboot?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
RobertDavid
Apprentice
Apprentice


Joined: 08 Aug 2005
Posts: 271
Location: Czech Republic

PostPosted: Wed Nov 16, 2005 8:16 pm    Post subject: eject cd before reboot? Reply with quote

How to do script to wait for ejecting CD from drive befre livecd shuts down and than press a key to shutdown/reboot,

I have tryed to add these lines to /etc/init.d/reboot.sh

Code:
echo -e "Eject the CD"
read


but it didnt work:( it works like plain scrip w/o reboot command but dont on reboot:(
and I need to unmount CD, maybe it is still mounted as /, it runs after "unmounting filesystems" "remounting filesystems read only"

Maybe I will download Knoppix and look at its config,,

Do you have any idea?
_________________
Arch & Fluxbox & 2.6.24-rc-zen!!!!
robertek.brevnov.net
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Wed Nov 16, 2005 8:22 pm    Post subject: Reply with quote

I have one, but never tested it, so it might work, of might not.

You can try to put it in the /etc/conf.d/local.stop file. Just make sure that the service "local" is used on boot (rc-update add local default). On startup local reads local.start, and when it is turned off in shutdown it should read local.stop, but I cant confim this. Just try it and see if you can get some usefull result...
Back to top
View user's profile Send private message
RobertDavid
Apprentice
Apprentice


Joined: 08 Aug 2005
Posts: 271
Location: Czech Republic

PostPosted: Thu Nov 17, 2005 5:20 pm    Post subject: Reply with quote

So I tryed that but didnt work:( Because local is stoping at first (so nothing is unmounted and I dont know what to unmount coz it should be anytime different).

So I need to change somehow stoping scripts, maybe not to remount filesystems readonly,,

The best way will be to look at knoppix, I will try to find that.. Is there some way how decompress knoppix image directly on disk or mount it somehow?
_________________
Arch & Fluxbox & 2.6.24-rc-zen!!!!
robertek.brevnov.net
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Thu Nov 17, 2005 5:49 pm    Post subject: Reply with quote

Knoppix uses a compressed fs image. I think that it is squashfs, wich can be compiled into the linux kernel. So, select squashfs into your kernel, recompile it, reboot and try to mounc that image into any other place with the -oloop option and -t squashfs type. That should work.
Back to top
View user's profile Send private message
nativemad
Developer
Developer


Joined: 30 Aug 2004
Posts: 918
Location: Switzerland

PostPosted: Sun Dec 04, 2005 8:26 pm    Post subject: Reply with quote

Did you get this working? I'm searching for quite a while now... 8O
Back to top
View user's profile Send private message
Omega21
l33t
l33t


Joined: 14 Feb 2004
Posts: 788
Location: Canada (brrr. Its cold up here)

PostPosted: Mon Dec 05, 2005 3:37 am    Post subject: Reply with quote

An init script maybe?
_________________
iMac G4 1GHz :: q6600 //2x 500GB//2GB RAM//8600GT//Gentoo :: MacBook Pro//2.53GHz
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Mon Dec 05, 2005 3:53 am    Post subject: Reply with quote

When 6th goes bored...

Code:

#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

depend() {
   before *
}

start() {
   ebegin "Started shutdown auto-ejector."
}

stop() {
   ebegin "Ejecting DVD..."

   eject /dev/dvd

   eend $? "Failed to eject DVD."
}

I dont know anything about init scripts but I toyed around a bit and made this, you can save it as /etc/init.d/eject-dvd or whatever you preffer. Then add it as you would do with any other: "rc-update add eject-dvd default". You can make different copys and modiffy them to eject another drive, or modiffy it to eject all the ejectable things... You know :lol:
Back to top
View user's profile Send private message
nativemad
Developer
Developer


Joined: 30 Aug 2004
Posts: 918
Location: Switzerland

PostPosted: Mon Dec 05, 2005 12:30 pm    Post subject: Reply with quote

A simple init-script does not work on a Live-CD... The root is still mounted when you call the script (and it will not be the last script wich is called...;), so it will not eject!

You have to put 'eject' and its libs in the initrd and call it somewhere in the shutdown scripts... but where, which script?!? I always get a "failed to unmount"!

i tried /etc/init.d/shutdown.sh and /etc/init.d/halt.sh wich seems to be very interesting... but i had no luck so far! :(
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Mon Dec 05, 2005 5:23 pm    Post subject: Reply with quote

nativemad wrote:
A simple init-script does not work on a Live-CD... The root is still mounted when you call the script (and it will not be the last script wich is called...;), so it will not eject!

You have to put 'eject' and its libs in the initrd and call it somewhere in the shutdown scripts... but where, which script?!? I always get a "failed to unmount"!

i tried /etc/init.d/shutdown.sh and /etc/init.d/halt.sh wich seems to be very interesting... but i had no luck so far! :(

Oops, I forgot it was for a livecd. You are right... :oops:
Back to top
View user's profile Send private message
carl.anderson
Apprentice
Apprentice


Joined: 05 Sep 2005
Posts: 162
Location: Mountain View

PostPosted: Fri Jan 06, 2006 8:31 pm    Post subject: well, sorta Reply with quote

I was able to do something "almost" right. I but the binary for eject into the squashfs filesystem, but I'm still not able to eject the cd while it's mounted.

So I can umount -l /mnt/cdrom and then eject, but I get all kinds of error messages after that. Apparently the system is depending on files that are on the CDrom.

I would like to mount the entire squashfs onto a hard drive once I've booted from the cdrom.

If I copy the squashfs file, how can I switch into that image and cleanly unmount the cdrom?
Back to top
View user's profile Send private message
gieltje
n00b
n00b


Joined: 14 Aug 2004
Posts: 59

PostPosted: Tue Sep 04, 2007 3:59 pm    Post subject: Reply with quote

Little late bump, but anyways.

Has anyone found a way to do this (using genkernel)?
Back to top
View user's profile Send private message
carl.anderson
Apprentice
Apprentice


Joined: 05 Sep 2005
Posts: 162
Location: Mountain View

PostPosted: Wed Sep 05, 2007 12:09 pm    Post subject: I actually solved this a long time ago. Reply with quote

Sorry I didn't post this before.

Among the kernel boot options there is a 'docache' option. This forces the squashfs file to be copied to ram on boot up. If you want to eject the cd before reboot you need this. You can add it to the default kernel options if you want.

I'm assuming you know how to copy the livecd iso, modify a file and create a new iso to test. When I was hacking livecds I used an RW until I got it right. The newer livecds actually include the eject binary, so all you need to do is make sure the docache option has been used.

Then take a look at /bin/bashlogin. This is a script that is launched on all seven terminals to drop you into a bash prompt. If you can script, you can do practically anything you want by modifying this file. Although I warn you, to edit this file you need to know a little more.

To see the file you have to be able to extract the contents of the squashfs file on the livecd. You need FUSE enabled in your kernel to use squashfs. emerge squashfs-tools. You will find tools to mount a squashfs filesystem and create a new one. You basically need to do this (as root):
Code:
mount -o loop livecd.iso /mnt/cdrom
mkdir -p /mnt/loop
mount -o loop -t squashfs /mnt/cdrom/*.squashfs /mnt/loop
cp -a /mnt/loop/ /tmp
umount /mnt/loop

At this point, /tmp/loop contains a snapshot of all the files in the squashfs filesystem. You can edit them here and then create a new squashfs file to put onto the livecd iso.
Code:
cd /tmp/loop
mksquashfs * ../foo.squashfs


Happy hacking.
Back to top
View user's profile Send private message
gieltje
n00b
n00b


Joined: 14 Aug 2004
Posts: 59

PostPosted: Fri Sep 07, 2007 3:21 pm    Post subject: Reply with quote

would it not be possible to add a minimalist image to the memory instead of the whole cd with just eject and needed library's?
Back to top
View user's profile Send private message
carl.anderson
Apprentice
Apprentice


Joined: 05 Sep 2005
Posts: 162
Location: Mountain View

PostPosted: Fri Sep 07, 2007 4:27 pm    Post subject: Reply with quote

It's actually not the whole cd; it's only the 50MB squashfs file. So unless you are working on an embedded system with less than 50MB of RAM - loading the squashfs file is not a very big deal. Frankly I'm surprised it's not the default behavior.
Back to top
View user's profile Send private message
gieltje
n00b
n00b


Joined: 14 Aug 2004
Posts: 59

PostPosted: Fri Sep 07, 2007 7:08 pm    Post subject: Reply with quote

carl.anderson wrote:
It's actually not the whole cd; it's only the 50MB squashfs file. So unless you are working on an embedded system with less than 50MB of RAM - loading the squashfs file is not a very big deal. Frankly I'm surprised it's not the default behavior.


I think there is a bit more cached then you think. I just booted my livecd with docache on and it consumed 1300mb's of ram after boot. I was able to run every big thing I could think of after the cd was ejected :?
Back to top
View user's profile Send private message
carl.anderson
Apprentice
Apprentice


Joined: 05 Sep 2005
Posts: 162
Location: Mountain View

PostPosted: Fri Sep 07, 2007 7:13 pm    Post subject: Reply with quote

Are you using mksquashfs to customize your squashfs filesystem? Are you putting extra stuff in there?

When I was hacking install cds I was working with the minimal isos. I don't have a lot of experience with the 'live' cds, so they may be different than I expect. If that's the case, you might open a bug as a feature request and let the developers look into it.
Back to top
View user's profile Send private message
gieltje
n00b
n00b


Joined: 14 Aug 2004
Posts: 59

PostPosted: Fri Sep 07, 2007 7:50 pm    Post subject: Reply with quote

carl.anderson wrote:
Are you using mksquashfs to customize your squashfs filesystem? Are you putting extra stuff in there?

When I was hacking install cds I was working with the minimal isos. I don't have a lot of experience with the 'live' cds, so they may be different than I expect. If that's the case, you might open a bug as a feature request and let the developers look into it.


I am running my full fledged custom livecd (total iso is 537mb). So that is why I was thinking of a minimal image for just eject or the kind
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum