Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A quick question - would appreciate a quick answer - is there a way to install packages to a system on HDD from a USB/CD/DVD live environment?


Though I would love a quick answer, it doesn't necessarily have to be simple, if the only workable solution is possibly a little difficult/complicated. I'm thinking of somehow changing the target directory of dpkg to the hard disk instead of the live environment or something. Of course, I don't know how to do that or even if it's possible, hence the question. Hope my input helps me get help.

share|improve this question
up vote 3 down vote accepted

You'll have to chroot into the system. Assume sda1 is your HDD:

sudo su
mount /dev/sda1 /mnt
for f in proc sys dev ; do mount --rbind /$f /mnt/$f ; done
chroot /mnt/

From then on you are using the root of your HDD as root and you can apt-get update or yum update or whatever the HDD-system demands.

Exit with STRG + D or by typing exit.

EDIT: sometimes you seem to have to copy /etc/resolv.conf to your chroot as pointed out by enzotib in the comments.

share|improve this answer
Just after I executed an apt-get install command, the message sudo: unable to resolve host ubuntu appeared. I hope it won't cause any problem. – Oxwivi May 5 '11 at 19:27
Oh wait, I'm running as root, so that message appeared because I typed in sudo even though I didn't need to? – Oxwivi May 5 '11 at 19:29
@Oxwivi: Start another terminal windows and sudo cp /etc/resolv.conf /mnt/etc. – enzotib May 5 '11 at 19:50

Your Answer


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.