10

I have a netbook with a tiny hard drive, and an external drive to go with it. It's running Ubuntu. I want to be able to install some packages to that external hard drive, so that when the hard drive is not plugged in the netbook still functions, just with out some functionality. It doesn't have to be this way exactly, I just want the effect of offloading some of my installed libraries and programs onto the portable hard drive. In other words, just mounting some directories from the external drive wont work because I at least need some basic programs to run normally.

Here are some things I was thinking about but wasn't able to find enough information to actually understand if they are feasible, or how to go about doing them. Comments on how to do any of these or on alternate methods are greatly appreciated.

  1. Can I do something like this if I use the --root=/media/external switch of dpkg install and then add /media/external/ to my system path?
  2. What if I create some kind of wrapper for dpkg that will install the package into an alternate root (--root=/media/external) and then create a symlink in the internal file system to every file that was just installed on the external file system?
  3. How about something where I chroot into the external drive?
  4. How about something using LVM?

2 Answers 2

5

You can use --root to install packages into another directory, but you can't use most programs from there as most programs look for some files in fixed places (like /etc). The option is there for cases like installing packages into a NFS root for diskless clients.

Maybe you could use something like UnionFS to merge the two file systems.

4
  • Yeah, that's what I figured would be the problem. At first glance, UnionFS looks like it might work very well. I'll see if I can give that a try. Jun 24, 2010 at 16:01
  • So it appears that UnionFS was dropped from ubuntu since Karmic and replaced with unionfs-fuse (a fuse implementation rather than a kernal module). I like the idea of a kernel module better but this seems to be working quite well. This is, at least, exactly what I wanted so thanks for the good answer :). Jun 24, 2010 at 19:15
  • Ok, I'm un-answering this. UnionFS, it seems, is only a half answer. It does mostly what I want, but it appears that you can't unionfs two directories together, and then mount the union to one of the two.. which is what I would need. One way (possibly) to finish the answer would be to do something with a chroot? i.e. create a fakeroot as the union of the roots of each drive, and then chroot into that. Will this work? I don't know how to use chroot. Jun 25, 2010 at 19:44
  • aufs2 is what's used for union mounts in ubuntu livecds IIRC.
    – Tobu
    Jun 25, 2010 at 21:46
4

If you want a simple answer that doesn't make you work your away around the debian package management, just use mount and symlinks. You could mount your external drive using /etc/fstab and have some symlinks that point into that drive. NOTE: You shouldn't blindly symlink, be sure before you change something ;)

A rather save suggestion would be to put your /tmp into a ramfs (which you should be doing anyways on many netbooks with SSD).

Are you sure your programs need the most space on your internal drive? Did you check it using a tool like xdiskusage?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .