Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: souren on September 15, 2010, 01:44:47 AM

Title: [solved] Unexpected Restore during bootup in persistence mode
Post by: souren on September 15, 2010, 01:44:47 AM
I have setup Tiny Core to run on VirtualBox. Now, I wanted to have a persistent home and opt folder, so I modified menu.lst to contain home=hda1 and opt=hda1 as parameters to the kernel command.

I also created the respective folders in /mnt/hda1 (home and opt)

Now, I have an app that I wish to get invoked each time TinyCore reboots, so I copied my_app.tcz file to /mnt/hda1/tce/optional
and edited /mnt/hda1/tce/onboot.lst to include my_app.tcz

Following that, I edited /mnt/hda1/opt/bootlocal.sh to contain sudo my_app

Now, after I reboot the VirtualBox I find the bootlocal.sh no longer contains the line to invoke my_app on bootup..!!!! It seems to have been reset back to the original content....!?!?

Can someone please advice me what I might be doing wrong now...  ???
Title: Re: bootlocal.sh
Post by: souren on September 15, 2010, 02:59:48 AM
To add more info, this is what my menu.lst in /mnt/hda1/boot/grub looks like:

default 0
timeout 10
title tinycore
kernel /boot/bzImage home=hda1 opt=hda1 quiet
initrd /boot/tinycore.gz

I just can't figure out why the /mnt/hda1/opt folder keeps getting reset back to default state every time I reboot TC!!?!?
Title: Re: bootlocal.sh
Post by: aus9 on September 15, 2010, 05:42:20 AM
hi

until you get a better reply...I think you have not backed up correctly.

http://wiki.tinycorelinux.com/Backup-check

will show you whats currently in your mydata file....which is what is going to be restored.

2) I am guessing opt is in your mydata file

3) and not sure if you know but you need full pathways in your bootlocal file please.
Normally this file is run by root so there is no need to use sudo but you do need to specify
/usr/local/bin/myapp -switch (switch or parameter if needed)


good luck
Title: Re: bootlocal.sh
Post by: TaoTePuh on September 15, 2010, 08:34:38 AM
Have you modified /opt/.filetool.lst correctly to your persistent setup?

Title: Re: bootlocal.sh
Post by: souren on September 15, 2010, 08:43:57 AM
@aus9: Thanks mate...will try that out tomorrow.

@TaoTePuh: I find that the whole /opt folder gets reset everytime I reboot the system. So, that includes .filetool.lst as well...
Title: Re: bootlocal.sh
Post by: TaoTePuh on September 15, 2010, 09:55:56 AM
Can you please post the content of .filetool.lst? E.g. "cat /opt/.filetool.lst"
Title: Re: bootlocal.sh
Post by: gerald_clark on September 15, 2010, 10:07:16 AM
You cannot launch interactive programs in bootlocal.sh, only daemons.
If you want to launch a console application add it to /home/tc/.profile.
If you want to launch an X application, you need to create a startup script in /home/tc/.X.d/
Title: Re: bootlocal.sh
Post by: souren on September 15, 2010, 07:48:05 PM
@TaotePuh: The contents of my .filetool.lst:
opt/bootlocal.sh
opt/shutdown.sh
opt/tcemirror
opt/.filetool.lst
opt/.xfiletool.lst
home
Title: Re: bootlocal.sh
Post by: souren on September 15, 2010, 08:24:56 PM
It's wierd. I seem to be having the same problem with the .profile file in /mnt/hda1/home/tc!

Does this have anything to do with the fact that I am trying this under Virtual Box...I doubt it!

Why is it that none of the changes I am making to /home and /opt is being maintained after a reboot, althought I am passing home=hda1 and opt=hda1 to the kernel parameter list!?!?
Title: Re: bootlocal.sh
Post by: gerald_clark on September 15, 2010, 09:34:43 PM
You need to delete all the lines from .filetool.lst and do a save.
The saved files keep overwriting the persistant /home/tc and /opt files.

Please read the wiki articles on persistant home and opt.
Title: Re: bootlocal.sh
Post by: maro on September 15, 2010, 09:51:32 PM
Yesterday I was just about to comment the same as aus9 did, so I stopped and considered the issue resolved. Have you actually paid attention to what has been posted here? I'm sure that none of this is related to operating in a VM.

At least to myself it is quite obvious that the restoration of your backup file (i.e. 'mydata.tgz') overwrites your persistent '/opt' and '/home' files. The '/opt/.filetool.lst' file still contains the entries of 'opt/bootlocal.sh' and 'home'. The latter explains why you now observe the fact that '/home/tc/.profile' gets overwritten. To check the content of your backup file you could use: tar tvzf /mnt/hda1/tce/mydata.tgz Don't be surprised to see 'bootlocal.sh' and 'home/tc/.profile' to show up there, and the file size and timestamp should indicate that they are the versions that keep on overwriting the ones in '/opt' and '/home'.

I guess you have a few different options in how you can resolve this:
In case you are wondering why would one want to keep the backup/restore capability available when using persistent '/opt' and '/home, and therefore not opt for option (3) from above: Well, there are situations when files from '/etc' will need to "survive" a reboot (e.g. when using user passwords), and then backup/restore will be required again.
Title: Re: bootlocal.sh
Post by: souren on September 15, 2010, 10:07:54 PM
Thanks maro and gerald.

Yes, I did look at aus9's suggestion...and I did try removing all entries from the .filetool.lst

But I am definitely missing something else, because although I deleted all the lines from .filetool.lst they just came back after the reboot! The bootlocal.sh timestamp was also reset back to Sept 13 - which is the timestamp stored in the mydata.tgz.
Title: Re: bootlocal.sh
Post by: maro on September 15, 2010, 10:26:19 PM
Quote
...and I did try removing all entries from the .filetool.lst

But I am definitely missing something else, because although I deleted all the lines from .filetool.lst they just came back after the reboot!
An empty '/opt/.filetool.lst' leads to the (silent) failure of the backup process, which means that the 'mydata.tgz' file reamains unchanged to what it was before the alteration to '/opt/.filetool.lst'. Removing 'mydata.tgz' should help in this situation.

Quote
The bootlocal.sh timestamp was also reset back to Sept 13 - which is the timestamp stored in the mydata.tgz.
As was to be expected.

BTW, you might want to consider changing the title of the thread to something more appropriate considering the recent change of tack. This could help other users to find the information more easily in the future.
Title: Re: Unexpected Restore during bootup in persistence mode
Post by: souren on September 15, 2010, 10:34:12 PM
Ok so having a space in .filetool.lst is not enough to trick TC into skipping the restore, becuase I used the echo command that you suggested.

Anyhow, if that is true, then in my last attempt I deleted everything from .filetool.lst except the last line 'home'.

After the reboot...well it's been restored again!!
Title: Re: Unexpected Restore during bootup in persistence mode
Post by: souren on September 16, 2010, 12:55:20 AM
Ok...I am not happy with this solution, but unless I come across a better way of doing it this will have to do I suppose.

I got rid of mydata.tgz so that no restore happens at all...

For the life of me I can't figure out how .filetool.lst is getting reset to the default state...and if that's getting reset...well of course bootlocal.sh and all other files would too! <SIGH>
Title: Re: Unexpected Restore during bootup in persistence mode
Post by: maro on September 16, 2010, 12:55:46 AM
Changing '/opt/.filetool.lst' does only indirectly influence what happens with the restoration, as is only controls what goes into the backup file. That obviously requires to execute a backup (e.g. filetool.sh -b or at shutdown). Otherwise the old 'mydata.tgz' is still around, and unless you are using bootcode 'norestore' don't be surprised that the old files are re-appearing. You really need to check the contents of your 'mydata.tgz'.

I've now done a re-test of my earlier advice and like to offer the following as a "proof" of that recommendation:
Code: [Select]
tc@box:~$ date > file
tc@box:~$ ls -l file
-rw-r--r--    1 tc       staff           29 Sep 16 04:20 file
tc@box:~$ echo file > list
tc@box:~$ rm -f a.tgz ; busybox tar czvf a.tgz -T list ; echo $? ; ls -l a.tgz
file
0
-rw-r--r--    1 tc       staff          127 Sep 16 04:21 a.tgz
tc@box:~$ tar tzvf a.tgz
-rw-r--r-- tc/staff        29 2010-09-16 04:20:52 file
This is the "normal" case: an entry in the list file results in a non-empty archive file.

Code: [Select]
tc@box:~$ rm -f list
tc@box:~$ rm -f a.tgz ; busybox tar czvf a.tgz -T list ; echo $? ; ls -l a.tgz
tar: can't open 'list': No such file or directory
1
ls: a.tgz: No such file or directory
Having no list file leads to the failure of the 'tar' command, and no archive file gets created.


Code: [Select]
tc@box:~$ rm -f list ; touch list
tc@box:~$ ls -l list
-rw-r--r--    1 tc       staff            0 Sep 16 04:22 list
tc@box:~$ rm -f a.tgz ; busybox tar czvf a.tgz -T list ; echo $? ; ls -l a.tgz
tar: empty archive
1
ls: a.tgz: No such file or directory
Having an empty list file will still results in a failure and the lack of an archive file.

Code: [Select]
tc@box:~$ echo ' ' > list
tc@box:~$ rm -f a.tgz ; busybox tar czvf a.tgz -T list ; echo $? ; ls -l a.tgz
tar:  : No such file or directory
tar: error exit delayed from previous errors
1
-rw-r--r--    1 tc       staff           29 Sep 16 04:23 a.tgz
tc@box:~$ tar tzvf a.tgz
tc@box:~$ echo $?
0
tc@box:~$
Having just a single blank character as an entry in the list file results still in a warning from 'tar', but this time at least an empty archive file gets created.

BTW, it would be enough to do echo > list as the 'echo' command produces in any case a linefeed and hence the list file would not be empty.
Title: Re: Unexpected Restore during bootup in persistence mode
Post by: souren on September 16, 2010, 01:25:22 AM
Yup. Thanks Maro for your help.

I'll go with the norestore option...