dnschneid / crouton

Chromium OS Universal Chroot Environment
https://goo.gl/fd3zc?si=1
BSD 3-Clause "New" or "Revised" License
8.57k stars 1.24k forks source link

placing config scripts in the /etc/init folder. #1809

Closed newbieUK closed 9 years ago

newbieUK commented 9 years ago

Hi there,

I am very new to Linxux (Chromebook Os) and have what is probably a very simple question.

I am trying to install the Autostart crouton chroot at ChromeOS startup and have been following the instructions on https://github.com/dnschneid/crouton/wiki/Autostart-crouton-chroot-at-ChromeOS-startup

However, I don't know how to actually place the placing config scripts in the /etc/init folder (the crouton.conf) in this instance.

I currently have crouton.conf in my download folder - what code or step to I need t do to move it to etc/init ? In the world of Windows I would simply drop and drag but I don't know what the Linxus equivalent is - any help would be much appreciated.

Thank you

tcagle commented 9 years ago

Assuming you have the correct crouton.conf file in your ~/Downloads path already you should be able to get into crosh and do the following... 1) sudo sh 2) cp /home/chronos/user/Downloads/crouton.conf /etc/init and probably need to.. 3) chmod 644 /etc/init/crouton.conf Exit crosh session and reboot

newbieUK commented 9 years ago

Thank you fro taking the time to reply; I tried as you suggested but it didn't work. I also tried replacing sh with sudo on step one - that also didn't work.

The terminal didn't give an error message or any message for that matter - any other ideas? Thanks.

On Sun, May 31, 2015 at 1:17 AM, tcagle notifications@github.com wrote:

Assuming you have the correct crouton.conf file in your ~/Downloads path already you should be able to get into crosh and do the following... 1) sudo sh 2) cp /home/chronos/user/Downloads/crouton.conf /etc/init and probably need to.. 3) chmod 644 /etc/init/crouton.conf

— Reply to this email directly or view it on GitHub https://github.com/dnschneid/crouton/issues/1809#issuecomment-107102982.

tcagle commented 9 years ago

Ooops I mispoke and used the wrong file name but there seems to be a further permissions issue. Here is what I got when I tried to run my own flawed instructions and corrected my mistake...

crosh> shell chronos@localhost / $ curl -Lk --connect-timeout 60 -m 300 --retry 2 "https://gist.github.com/DennisLfromGA/aa1c92ebe77c3df4ca84/download" | tar -xzO > ~/Downloads/crouton.init % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 786 0 786 0 0 2715 0 --:--:-- --:--:-- --:--:-- 3070 chronos@localhost / $ id uid=1000(chronos) gid=1000(chronos) groups=1000(chronos),18(audio),27(video),208(pkcs11),220(cras),240(brltty),403(devbroker-access),1001(chronos-access) chronos@localhost / $ sudo sh Password:

cp /home/chronos/user/Downloads/crouton.conf /etc/init

cp: cannot stat ‘/home/chronos/user/Downloads/crouton.conf’: No such file or directory

cp /home/chronos/user/Downloads/crouton.init /etc/init

cp: cannot create regular file ‘/etc/init/crouton.init’: Read-only file system #

Try this instead...

1) sudo sh 2) cp /home/chronos/user/Downloads/crouton.conf /usr/local/chroots//etc/init and probably need to.. 3) chmod 644 /usr/local/chroots//etc/init/crouton.conf

reboot and cross your fingers and you may be good then.

Note that is what you actually used for the name of your chroot as installed. If you took defaults at install I believe that is "precise" (without the quotes of course). Good Luck.

Hmmm, after further examination, I am not sure but what you may have to edit the crouton.init file itself to match your exact install DE etc before you copy it into place. I've never used this autostart stuff because I use an encrypted chroot which means I can't use the techniques in your original link at all. I will butt out and let somebody who may know something help you now. Looks like the entire autostart article could be re-written to be a bit clearer about those /usr/local/chroot/ relative paths to me. ;) Hope this helps and doesn't just muddy the water.

On Sun, May 31, 2015 at 1:37 PM, newbieUK notifications@github.com wrote:

Thank you fro taking the time to reply; I tried as you suggested but it didn't work. I also tried replacing sh with sudo on step one - that also didn't work.

The terminal didn't give an error message or any message for that matter - any other ideas? Thanks.

On Sun, May 31, 2015 at 1:17 AM, tcagle notifications@github.com wrote:

Assuming you have the correct crouton.conf file in your ~/Downloads path already you should be able to get into crosh and do the following... 1) sudo sh 2) cp /home/chronos/user/Downloads/crouton.conf /etc/init and probably need to.. 3) chmod 644 /etc/init/crouton.conf

— Reply to this email directly or view it on GitHub <https://github.com/dnschneid/crouton/issues/1809#issuecomment-107102982 .

— Reply to this email directly or view it on GitHub https://github.com/dnschneid/crouton/issues/1809#issuecomment-107232711.

tonyxue commented 9 years ago

The script shouldn't be placed inside the chroot. It should be directly placed at /etc/init not /usr/local/chroots/<your chroot name>/etc/init

The cp: cannot create regular file ‘/etc/init/crouton.init’: Read-only file system error is because the Chromium OS file system is by default mounted read-only. If you want to make it writable, follow the first step in the wiki. Place the script provided by @DennisLfromGA into /etc/init after remount the file system to read and writable.

Click on the rw-rootfs link in the wiki. Download and run the script first.

DennisLfromGA commented 9 years ago

@newbieUK,

A slight correction to what @tonyxue said: the script crouton.conf needs to placed outside the chroot, on the Chrome OS side, in the folder /etc/init. However, in order to do that, you need to first remove rootfs verification which is Step 1 in the wiki.

tonyxue commented 9 years ago

outside the chroot

:+1: Yep, that's more precise. Thanks!

newbieUK commented 9 years ago

Thanks everyone; I have configured all the files and can see the script is in /etc/init folder but its just not working for me - cannot figure it out.

On Mon, Jun 1, 2015 at 7:37 AM, Xue, Zhaoxin (Tony) < notifications@github.com> wrote:

The script shouldn't be placed inside the chroot. It should be directly placed at /etc/init not /usr/local/chroots//etc/init

The cp: cannot create regular file ‘/etc/init/crouton.init’: Read-only file system error is because the Chromium OS file system is by default mounted read-only. If you want to make it writable, follow the first step in the wiki https://github.com/dnschneid/crouton/wiki/Autostart-crouton-chroot-at-ChromeOS-startup#method-and-scripts-to-invoke-a-crouton-chroot-session-at-chromeos-startup. Place the script provided by @DennisLfromGA https://github.com/DennisLfromGA into /etc/init after remount the file system to read and writable.

Click on the rw-rootfs https://gist.github.com/DennisLfromGA/6690677 link in the wiki. Download and run the script first.

— Reply to this email directly or view it on GitHub https://github.com/dnschneid/crouton/issues/1809#issuecomment-107322746.

DennisLfromGA commented 9 years ago

@newbieUK - Is crouton.conf in /etc/init/ on the Chrome OS side, in other words, did you copy it in a crosh shell not a chroot shell? If so, then after you reboot and log in, there should be a /tmp/crouton-$PID.log file that shows you what went wrong. The $PID will be the process number that it ran under.

newbieUK commented 9 years ago

I've amended the conf file - it hasn't changed anything but there is no log file being created.

This is the revised conf file: http://codepad.org/59iEO5ci

This list what is my etc.init, tmp and var/log files on Chrome Os side:

http://codepad.org/Xhnfx2Ir

Thanks,

On Sat, Jun 6, 2015 at 5:34 PM, DennisL notifications@github.com wrote:

@newbieUK https://github.com/newbieUK - Is crouton.conf in /etc/init/ on the Chrome OS side, in other words, did you copy it in a crosh shell not a chroot shell? If so, then after you reboot and log in, there should be a /tmp/crouton-$PID.log file that shows you what went wrong. The $PID will be the process number that it ran under.

— Reply to this email directly or view it on GitHub https://github.com/dnschneid/crouton/issues/1809#issuecomment-109614667.

DennisLfromGA commented 9 years ago

@newbieUK,

I can't help you if you alter crouton.conf beyond the two areas where it allows you to:

## Choose when the crouton chroot will be started - 4 choices below -
## NOTE: use only 1, prepend the others with the remark character: #

#start on starting ui          # 1st - starts when the user interface begins
                               #     + only 1 chroot will run in this mode
                               #     + must use XMETHOD: 'xorg' or 'xephyr'

#start on started ui           # 2nd - starts when the user interface appears
                               #     + only 1 chroot will run in this mode
                               #     + must use XMETHOD: 'xorg' or 'xephyr'

#start on login-prompt-visible # 3rd - starts when the login screen appears
                               #     + only 1 chroot will run in this mode
                               #     + must use XMETHOD: 'xorg' or 'xephyr'

 start on start-user-session   # 4th - starts when the user logs in - DEFAULT
                               #     + multiple chroots could run in this mode
                               #     + can use any XMETHOD: 'xiwi','xorg' or 'xephyr'
                               #     + ensures user ~/Downloads is available

and

############################################################################
## NOTE: This job can be controlled externally by placing the file        ##
#+       'crouton.init' in the User's Downloads folder on a per User      ##
#+       basis or in the chroots parent folder per system with the        ##
#+       following six optional variables set:                            ##
#+  1) DELAY 2) CHROOT 3) START_DE 4) CHROOT_APP 5) XMETHOD 6) RUN_STATE  ##
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##
#+ [ the 'env ' prefix must be omitted in the control file ]              ##
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##
## Start of control file variables                                        ##
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##
env DELAY=10            # delay desired number of seconds before starting ##
env CHROOT=precise      # enter desired chroot to start                   ##
env START_DE=startxfce4 # enter desired Desktop Envirnoment to use        ##
env CHROOT_APP=none     # enter desired chroot application to run         ##
env XMETHOD=default     # enter temporary X-Window Envirnoment to use     ##
env RUN_STATE=y         # change to 'n' to disable running $CHROOT        ##
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##
## End of control file variables                                          ##
############################################################################

If you follow those guidelines and create either a /usr/local/crouton.init or ~/Downloads/crouton.init file with your specific parameters, then we can make more progress. If there is no DEBUG file (/tmp/crouton-$PID.log), then it is not working... :/

tedm commented 9 years ago

does anyone have this working?

On Sun, Jun 7, 2015 at 7:58 AM, DennisL notifications@github.com wrote:

@newbieUK https://github.com/newbieUK,

I can't help you if you alter crouton.conf beyond the two areas where it allows you to:

Choose when the crouton chroot will be started - 4 choices below -

NOTE: use only 1, prepend the others with the remark character:

start on starting ui # 1st - starts when the user interface begins

                           #     + only 1 chroot will run in this mode
                           #     + must use XMETHOD: 'xorg' or 'xephyr'

start on started ui # 2nd - starts when the user interface appears

                           #     + only 1 chroot will run in this mode
                           #     + must use XMETHOD: 'xorg' or 'xephyr'

start on login-prompt-visible # 3rd - starts when the login screen appears

                           #     + only 1 chroot will run in this mode
                           #     + must use XMETHOD: 'xorg' or 'xephyr'

start on start-user-session # 4th - starts when the user logs in - DEFAULT

+ multiple chroots could run in this mode

                           #     + can use any XMETHOD: 'xiwi','xorg' or 'xephyr'
                           #     + ensures user ~/Downloads is available

and

############################################################################

NOTE: This job can be controlled externally by placing the file

+ 'crouton.init' in the User's Downloads folder on a per User

+ basis or in the chroots parent folder per system with the

+ following six optional variables set:

+ 1) DELAY 2) CHROOT 3) START_DE 4) CHROOT_APP 5) XMETHOD 6) RUN_STATE

~~~~~~~~~~~~~~~~

+ [ the 'env ' prefix must be omitted in the control file ]

~~~~~~~~~~~~~~~~

Start of control file variables

~~~~~~~~~~~~~~~~

env DELAY=10 # delay desired number of seconds before starting ## env CHROOT=precise # enter desired chroot to start ## env START_DE=startxfce4 # enter desired Desktop Envirnoment to use ## env CHROOT_APP=none # enter desired chroot application to run ## env XMETHOD=default # enter temporary X-Window Envirnoment to use ## env RUN_STATE=y # change to 'n' to disable running $CHROOT ##

~~~~~~~~~~~~~~~~

End of control file variables

############################################################################

If you follow those guidelines and create either a /usr/local/crouton.init or ~/Downloads/crouton.init file with your specific parameters, then we can make more progress. If there is no DEBUG file (/tmp/crouton-$PID.log), then it is not working... :/

— Reply to this email directly or view it on GitHub https://github.com/dnschneid/crouton/issues/1809#issuecomment-109763113.

DennisLfromGA commented 9 years ago

Yup. Are you trying to do it?

tedm commented 9 years ago

Yeah, but the documentation is not clear to me. I have a r/w fs with secure boot disabled (fyi - this is the default on a Toshiba Chromebook 2, when entering dev mode). also, what's with the scary script to test for r/w ? 3rd, what's with adding 10 seconds to boot time?

DennisLfromGA commented 9 years ago

@tedm -

Yeah, but the documentation is not clear to me.

Is this the documentation you're refering to? 'Autostart crouton chroot at ChromeOS startup' If so, what part is unclear?

I have a r/w fs with secure boot disabled (fyi - this is the default on a Toshiba Chromebook 2, when entering dev mode)

I don't know what 'secure boot' means exactly but if your rootfs is r/w then this should work.

what's with the scary script to test for r/w ?

It actually doesn't just test for r/w, it will make rootfs r/w. In so doing, on some Chromeboxes and possibly Chromebooks, when 'dev_boot_signed_only' is set to 1 and rootfs verification is removed, it has been reported to "enter in to recovery mode". Therefore the scary warning, it's not the script, it's running - sudo /usr/share/vboot/bin/make_dev_ssd.sh --force --remove_rootfs_verification --partitions $CURRENTKERNEL that causes it.

3rd, what's with adding 10 seconds to boot time?

It's an option, you don't need it...

newbieUK commented 9 years ago

Got it to work! Thank you!

On Sun, Jun 7, 2015 at 3:58 PM, DennisL notifications@github.com wrote:

@newbieUK https://github.com/newbieUK,

I can't help you if you alter crouton.conf beyond the two areas where it allows you to:

Choose when the crouton chroot will be started - 4 choices below -

NOTE: use only 1, prepend the others with the remark character:

start on starting ui # 1st - starts when the user interface begins

                           #     + only 1 chroot will run in this mode
                           #     + must use XMETHOD: 'xorg' or 'xephyr'

start on started ui # 2nd - starts when the user interface appears

                           #     + only 1 chroot will run in this mode
                           #     + must use XMETHOD: 'xorg' or 'xephyr'

start on login-prompt-visible # 3rd - starts when the login screen appears

                           #     + only 1 chroot will run in this mode
                           #     + must use XMETHOD: 'xorg' or 'xephyr'

start on start-user-session # 4th - starts when the user logs in - DEFAULT

+ multiple chroots could run in this mode

                           #     + can use any XMETHOD: 'xiwi','xorg' or 'xephyr'
                           #     + ensures user ~/Downloads is available

and

############################################################################

NOTE: This job can be controlled externally by placing the file

+ 'crouton.init' in the User's Downloads folder on a per User

+ basis or in the chroots parent folder per system with the

+ following six optional variables set:

+ 1) DELAY 2) CHROOT 3) START_DE 4) CHROOT_APP 5) XMETHOD 6) RUN_STATE

~~~~~~~~~~~~~~~~

+ [ the 'env ' prefix must be omitted in the control file ]

~~~~~~~~~~~~~~~~

Start of control file variables

~~~~~~~~~~~~~~~~

env DELAY=10 # delay desired number of seconds before starting ## env CHROOT=precise # enter desired chroot to start ## env START_DE=startxfce4 # enter desired Desktop Envirnoment to use ## env CHROOT_APP=none # enter desired chroot application to run ## env XMETHOD=default # enter temporary X-Window Envirnoment to use ## env RUN_STATE=y # change to 'n' to disable running $CHROOT ##

~~~~~~~~~~~~~~~~

End of control file variables

############################################################################

If you follow those guidelines and create either a /usr/local/crouton.init or ~/Downloads/crouton.init file with your specific parameters, then we can make more progress. If there is no DEBUG file (/tmp/crouton-$PID.log), then it is not working... :/

— Reply to this email directly or view it on GitHub https://github.com/dnschneid/crouton/issues/1809#issuecomment-109763113.

tedm commented 9 years ago

@DennisLfromGA I think I'm going to try it. Why can't options 1 and 2 use a shared downloads folder? Does this do anything nasty, like install the Ask toolbar? ;)

DennisLfromGA commented 9 years ago

@newbieUK - Cool, cool, cool! Now don't touch it ;)

DennisLfromGA commented 9 years ago

@tedm,

Why can't options 1 and 2 use a shared downloads folder?

Because Chrome OS/Chromium use the /etc/init/ folder for config files like a lot of linux systems use /etc/init.d/.

Does this do anything nasty, like install the Ask toolbar? ;)

Well yes, but you can opt out of it by pressing Ctrl+Alt+DEL ;)