dnschneid / crouton

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

Backup chroot #211

Closed sherip99 closed 11 years ago

sherip99 commented 11 years ago

The wiki says to use "sudo edit-chroot -b nameofchroot" to backup a chroot, but the "-b" option doesn't seem to be available on my Acer chromebook. It is in Developer mode, does it also have to be running Developer channel? I did try switching from Stable to Beta, (under Chrome, Settings, Help) but no joy.

dnschneid commented 11 years ago

Update your chroot with the latest crouton. I just added the feature last night.

sherip99 commented 11 years ago

Shouldn't I be backing it up before updating it? :)

Sorry I'm pretty new to this.

My chroot has raring xfce, created less than a week ago but I've customized it quite a bit. Is an update going to change anything? Also I was trying to run the edit-chroot from crosh, not from within the chroot, is that the right context? The chroot was not running.

Maybe I can add details to the Wiki once I successfully use the update and backup facilities.

dnschneid commented 11 years ago

Yes, good point. You can download the latest edit-chroot here, and copy it to /usr/local/bin/.

Update should never fundamentally change anything. It usually just fixes bugs or adds new features to improve interoperability with Chromium OS, but it won't change your desktop at all.

And yes, you want to run edit-chroot outside of the chroot.

sherip99 commented 11 years ago

Haven't tried it yet but before seeing your reply I tried to update and got an error.

First I downloaded the updated crouton script.

Then I got the tarball with: sudo sh -e crouton -d -f \path\to\croutonbootstrap.tar.bz2

Then tried to update. Why is it looking for precise?

sudo sh -e crouton -r raring -t xfce -u -f croutonbootstrap.tar.bz2 Detecting archive release and architecture... /usr/local/chroots/precise does not exist; cannot update.

ls /usr/local/chroots raring

dnschneid commented 11 years ago

Remove the -f part. It's detecting the release from that, and you don't need a bootstrap for updating.

sherip99 commented 11 years ago

Thanks, I downloaded the edit-chroot script and made a backup. Then I ran the crouton script with -u and proper options and successfully updated. However I do think the update may have removed the apps I've installed. Just started the chroot and among the output in the crosh window I noticed this:

* (zeitgeist-datahub:23998): WARNING _: recent-manager-provider.vala:133: Desktop file for "file:///usr/bin/teamviewer" was not found, exec: exo-desktop-item-edit, mimetype: application/octet-stream * (zeitgeist-datahub:23998): WARNING **: recent-manager-provider.vala:133: Desktop file for "file:///usr/bin/krusader" was not found, exec: exo-desktop-item-edit, mime_type: application/octet-stream

sherip99 commented 11 years ago

OK, not sure what that output meant, but both the referenced aps still work fine in the chroot (whew :) )

Lots of output piles up in crosh while the chroot is running. Next two lines are being output at least once a second while teamviewer is running:

err:ole:CoGetClassObject no class object {bcde0395-e52f-467c-8e3d-c4579291692e} could be created for context 0x1 err:ole:CoGetClassObject class {bcde0395-e52f-467c-8e3d-c4579291692e} not registered

teamviewer makes use of wine behind the scenes. Before starting teamviewer I start its daemon in a terminal. Teamviewer appears to working ok while I'm interacting with it. I use it with the Chromebook on the client end of remote desktop sessions. The Host is a Win 8 desktop system on my network.

dnschneid commented 11 years ago

Yeah, wine tends to be very noisy in the terminal. I suggest running it with &>/dev/null at the end to silence the messages.

sherip99 commented 11 years ago

Hmmn, I restored and reset my chromebook back to stock (only way to redeam the Google Drive offer) and now want to restore my crouton stuff. Is there an option to run crouton without setting up a target so that edit-chroot and other /usr/local/bin stuff gets established so I can try to restore my raring backup?

BTW, I've not succeeded in eliminating noisy output from teamviewer. Is it possible to limit the the size of the crosh buffer?

dnschneid commented 11 years ago

You can run sh -e crouton -x to extract the juicy scripts from the crouton executable, then cd into the "host-bin" directory and run edit-chroot directly. Be sure to specify the -c parameter to restore the chroot to the right location (probably /usr/local/chroots). Once it's restored, run crouton to update the chroot and it will copy all of the scripts to the correct place.

Another thing you can try is passing the tarball as -f to the crouton installer; be sure to also specify -r. That might do the right thing, but no guarantees.

sherip99 commented 11 years ago

I ran the installer as you suggested and it seems to have worked fine, thanks!

I've just noticed some info concerning the keyboard target. If I run the installer and specify a target of keyboard would it get added to my chroot and allow volume and brightness keys to function, or have I misunderstood?

Oops, I think I ran the crouton script as root in VT-2. I haven't noticed any problem, but I could redo it all and run from terminal if that's important.

sherip99 commented 11 years ago

I reset my chromebook (this time by going out then in to developer mode) and reran the installer as before but from the terminal with sudo instead of as root in VT-2. This time there were issues, I think because updates were triggered and wine got removed, looks like a later version was supposed to be installed but failed. Possibly it had happened in the previous execution from VT-2 as root and I missed it. Anyway I tried something different. I removed the raring chroot with sudo delete-chroot raring then ran sudo edit-chroot -r raring -f /media/removable/SD\ Card/ChromebookDownloads/bkup_my_chroot/raring-20130617-1234.tar.gz for purposes of restoring the backup and it failed. Looks like a bit of a mess, what happened here? The crouton version I'm using is a couple days old (from 6/17), downloaded just prior to creating the backup.

Found /home/chronos/user/Downloads/ for restoring raring. tar: /home/chronos/user/Downloads/: Cannot read: Is a directory/raring... tar: At beginning of tape, quitting now tar: Error is not recoverable: exiting now Finished restoring /home/chronos/user/Downloads/ to /usr/local/chroots/raring Found /home/chronos/user/Downloads/ for restoring -f. Restoring /home/chronos/user/Downloads/ to /usr/local/chroots/-f...tar: /home/chronos/user/Downloads/: Cannot read: Is a directory tar: At beginning of tape, quitting now tar: Error is not recoverable: exiting now Finished restoring /home/chronos/user/Downloads/ to /usr/local/chroots/-f Found /home/chronos/user/Downloads/ for restoring /media/removable/SD Card/ChromebookDownloads/bkup_my_chroot/raring-20130617-1234.tar.gz. Restoring /home/chronos/user/Downloads/ to /usr/local/chroots//media/removable/SD Card/ChromebookDownloads/bkup_my_chroot/raring-20130617-1234.tar.gz...tar: /home/chronos/user/Downloads/: Cannot read: Is a directory tar: At beginning of tape, quitting now tar: Error is not recoverable: exiting now Finished restoring /home/chronos/user/Downloads/ to /usr/local/chroots//media/removable/SD Card/ChromebookDownloads/bkup_my_chroot/raring-20130617-1234.tar.gz

chronos@localhost / $ ls /usr/local/chroots -f media raring

A directory named "-f" ?

dnschneid commented 11 years ago

Drop the "raring"; it's just -r.

Looks like I need to handle the situation where there are no tarballs better as well...[edit: fixed]

sherip99 commented 11 years ago

again reset the chromebook (out/in developer mode)

this time I ran crouton -x in the Downloads directory and cd'ed to host-bin. It returned immediately with no output and doesn't appear to have done anything.

chronos@localhost ~/Downloads/crouton.unbundled/host-bin $ sudo edit-chroot -c /usr/local/chroots -r -f /media/removable/SD\ Card/ChromebookDownloads/bkup_my_chroot/raring-20130617-1234.tar.gz

We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

sudo: edit-chroot: command not found chronos@localhost ~/Downloads/crouton.unbundled/host-bin $ sudo ./edit-chroot -c /usr/local/chroots -r -f /media/removable/SD\ Card/ChromebookDownloads/bkup_my_chroot/raring-20130617-1234.tar.gz chronos@localhost ~/Downloads/crouton.unbundled/host-bin $ ls /usr/local/chrootsls: cannot access /usr/local/chroots: No such file or directory chronos@localhost ~/Downloads/crouton.unbundled/host-bin $ ls -l total 152 lrwxrwxrwx 1 chronos chronos 11 May 11 16:06 delete-chroot -> edit-chroot -rwxr-xr-x 1 chronos chronos 13774 Jun 15 19:51 edit-chroot -rwxr-xr-x 1 chronos chronos 13007 Jun 15 19:51 enter-chroot -rwxr-xr-x 1 chronos chronos 10503 Jun 15 19:51 mount-chroot -rwxr-xr-x 1 chronos chronos 520 Apr 20 17:11 starte17 -rwxr-xr-x 1 chronos chronos 508 Jan 18 15:31 startkde -rwxr-xr-x 1 chronos chronos 511 Jan 18 15:31 startlxde -rwxr-xr-x 1 chronos chronos 497 Feb 1 01:09 startunity -rwxr-xr-x 1 chronos chronos 497 Jan 18 15:31 startxfce4 -rwxr-xr-x 1 chronos chronos 8525 Jun 15 19:51 unmount-chroot chronos@localhost ~/Downloads/crouton.unbundled/host-bin $

dnschneid commented 11 years ago

You need to explicitly run the local edit-chroot through sh: sudo sh -e ./edit-chroot ...

sherip99 commented 11 years ago

Fixed, thank you. I still had to update, but I was able to resolve my wine update issue. As much as I've been rewriting my SSD its made me wonder if ChromeOS automatically runs trim on an SSD boot drive. If not, any idea if it could be done from within a chroot?

DennisLfromGA commented 11 years ago

I love the backup features recently added to edit-chroot, I was doing them manually and they weren't very consistent plus I'd have to search through my bash history 'cause I couldn't always remember the exact format of the command I used.

I hesitate to ask but it would be nice to also pull in some of the 'bin' files like crouton and all the start-xxxx files and such so that the archive contained a complete functioning chroot environment when restored. That way, you could unarchive on another machine and everything would just work.

Just a thought...

dnschneid commented 11 years ago

Yeah, the start* files aren't associated with any chroot in particular. However if you restore using crouton -f, you can specify the right targets and it will add in the start* scripts. I need to add a little bit more intelligence to fully support the crouton -f method of restoring chroots, but it should work fine for normal usage.

tedm commented 9 years ago

downloaded the latest crouton, updated precise chroot, and also latest edit-chroot

from outside the chroot, with the chroot unmounted, I can't sudo edit-chroot -b backup.tar.gz

it gives an error:

chronos@localhost / $ sudo edit-chroot -b mybackup.tar.gz /mnt/stateful_partition/crouton/chroots/mybackup.tar.gz not found. chronos@localhost / $

going to /usr/local/chroots and manually using tar -czvf to ~/Downloads/mybackup.tar.gz works, but gives errors on locked files, and resultant tar.gz is about 1GB less than previous edit-chroot backups?

Anyone else having trouble with edit-chroot -b today?

DennisLfromGA commented 9 years ago

@tedm, It looks for the file in ~/Downloads unless you give it another path.

On Tue, Apr 28, 2015 at 4:04 PM, tedm notifications@github.com wrote:

downloaded the latest crouton, updated precise chroot, and also latest edit-chroot

from outside the chroot, with the chroot unmounted, I can't edit-chroot -b backup.tar.gz

it gives an error that the file doesn't exist

going to /usr/local/chroots and manually using tar works, but gives errors on locked files, and resultant tar.gz is about 1GB less than previous edit-chroot backups?

Anyone else having trouble with edit-chroot -b today?

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

DennyL@GMail

tedm commented 9 years ago

@DennisLfromGA I'm trying to create a backup with -b, so am using unique filenames with extensions of .tar.gz I'm not specifying a path, so am expecting it in ~/Downloads where previous backups have gone fine.

I've downloaded and moved the latest edit-chroot, chown it as root:root ; chmod it to 77 and it still does not run, but this time with permission errors.

DennisLfromGA commented 9 years ago

@tedm - You're in the root '/' directory, is that where you want to be? Also, prefix your edit-chroot command with sh - sudo sh /path/to/edit-chroot -b /path/to/mybackup.tar.gz

tedm commented 9 years ago

ahh, I was running edit-chroot as a command, forgot the sh, thanks!!

weird that I got it to run partially though ??

On Tue, Apr 28, 2015 at 5:11 PM, DennisL notifications@github.com wrote:

@tedm https://github.com/tedm - You're in the root '/' directory, is that where you want to be? Also, prefix your edit-chroot command with sh - sudo sh /path/to/edit-chroot -b /path/to/mybackup.tar.gz

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

tedm commented 9 years ago

@DennisLfromGA is working fine now with sh as root, but I think usage could be better, I kept assuming it would backup my only chroot at the time (precise), and kept passing it the destination filename, knowing that it would go in ~/Downloads, but it wants the source name, and automatically generates the target destination and filename (precise-datecode-info), which is pretty good, but if the usage returned the proper usage when improper arguments are passed, that would be good. What do you think?

DennisLfromGA commented 9 years ago

I do agree with you about returning more info. in the usage blurb. I have been contemplating bringing up this very subject with the higher powers but didn't want to bother them with this now in the midst of 'freon' rolling out and all the 'black screen' problems and such.

In the crouton scripts, there are comments for the tests that kick out the usage message, I think it would be a good idea to also kick out the comment contents of why the test(s) failed in addition to the usage message. Some examples of this are:

# At least one command must be specified
if [ -z "$ALLCHROOTS$BACKUP$DELETE$ENCRYPT$KEYFILE$LISTDETAILS$MOVE$RESTORE" ]; then
    error 2 "$USAGE"
fi

# Need at least one chroot listed if not using -r with -f or -a.
if [ $# = 0 ] && ! [ -n "$RESTORE" -a -n "$TARBALL" -o -n "$ALLCHROOTS" ]; then
    error 2 "$USAGE"
fi

# Cannot specify a chroot and -a.
if [ $# -gt 0 -a -n "$ALLCHROOTS" ]; then
    error 2 "$USAGE"
fi

# -f without -r or -b doesn't make sense
if [ -n "$TARBALL" -a -z "$BACKUP$RESTORE" ]; then
    error 2 "$USAGE"
fi

# Cannot specify both backup and restore.
if [ -n "$BACKUP" -a -n "$RESTORE" ]; then
    error 2 "$USAGE"
fi

# Cannot specify delete with anything else.
if [ -n "$DELETE" -a -n "$BACKUP$ENCRYPT$KEYFILE$MOVE$RESTORE" ]; then
    error 2 "$USAGE
fi

Like in the first example, instead of just spitting out - error 2 "$USAGE" Maybe it could be - echo "At least one command must be specified" 1>&2 error 2 "$USAGE"

Just an idea but I think it might help users to understand sometimes why their command failed and they're getting the usage message.

tedm commented 9 years ago

@DennisLfromGA yeah, that would be good. For -b errors, this would be nice:

echo "enter name of source chroot and optionally target directory or filename" 1>&2 error 2 "$USAGE"