Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to install ArchLinux, but my laptop hangs whenever I have any bootable media attached (other than the primary disk luckily). I tell you this, not because I'm looking to fix my laptop (although any comments about why this might be happening are welcome), but to explain why I'm trying to do what might seem rather convoluted.

I have an old version of Ubuntu running on the laptop and the ArchLinux iso on a disk which I can mount. My plan is to chroot into the ArchLinux installation environment, sort of the reverse of the installation process.

At this point however, my ignorance starts to show. I have RTM but since there is little hope of a second try at this if I kill my existing installation, I would appreciate any gotchas to look out for and any advice in general.

share|improve this question
    
This can be done without "killing" your current install. See this. –  don_crissti Mar 24 '13 at 20:18
    
    
grub 0.X or grub 1.X? –  warl0ck Mar 25 '13 at 1:48

1 Answer 1

Before I get to the chrooting, have you considered circumventing the problem? You're not entirely without options:

  1. booting from USB stick or USB DVD (unless that hangs the computer too)

    or, if you have another computer at hand,

  2. booting from network (if your laptop is capable of that) - setting up a tftp server is not difficult.

  3. taking the hard drive out and installing it on another machine.

The next thing to consider is: do you really need chrooting at all? Isn't the installer able to run from any directory?

Now chrooting. A lot depends on whether your disk is partitioned. If it is not I would strongly suggest to take one of the routes above (which are actually a fallback if anything goes wrong).

Supposing you have a partition S mounted at /S where you can put the installation media contents, and a partition T mounted as / in running system, the steps should be more or less as follows (disclaimer: I haven't tested it!):

  1. loopback-mount the iso somewhere: mount -o loop,ro /path/to/iso /some/where

  2. copy the media contents to from media to S: cp -r /some/where/* /S

  3. get in single-user mode, switch off all sevices, unmount all partitions except for T and S

  4. bind-mount important pseudo file systems from the running system:

    for fs in /dev /dev/pts /proc /sys; do
        mount -o bind ${fs} S${fs}
    done
    
  5. pivot_root - swap root and another directory for the running process and exec chroot (the exec is necessary to be able to unmount the old /).

    cd /S
    pivot_root . old_root
    exec chroot . command
    
  6. unmount old root:

    for fs in /dev /dev/pts /proc /sys; do
        umount old_root${fs}
    done
    umount old_root
    

And there you should be, having the media contents mounted as / and the most important pseudo file systems where they usually are. Note that you can't really just chroot to the mounted media, if you want to unmount the old / - the mounted media backing file has to be on a file system mounted somewhere under the old root and you have to unmount everything from under root. And you do want to unmount the old root, unless you have another spare partition to install to - because if you are going to install to T having it mounted somewhere else at the same time, possibly with some programs still running from it, is just asking for troubles. Especially should you decide to format it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.