1

I have been using Windows for a long time,

In Windows I can install an application and place it on the hard disk storage, can that also be done on the Ubuntu OS?

gdAdithya
  • 259

2 Answers2

2

Packages have fixed locations

The usual (and recommended) way to install most programs is through your distributions package manager. This program basically takes an archive (think zip file) of the the program and extracts it to a fixed location on your file hierarchy tree.

The way programs are developed, their location in the system, however, is fixed at compilation time. That is, the person creating the archive determines where the program resides in the file hierarchy. Unless you create your own package or install the program outside of your package manager (both not recommended), installing a package on a different drive is not possible.

Windows letter-drives v. UNIX hierarchy

However, Linux and Windows have a completely different idea on how to "make use of" disk drives. While on Windows each volume is assigned a volume letter like C:\, with each its own file system tree, on Linux you have one "big" tree and mount volumes with their own file systems "into" that same hierarchy/tree (NB: That's actually possible on Windows as well, but uncommon).

Approach A: Put /usr on a different drive

When installing a program, its files will mostly reside in /usr/, /etc/. The latter contains only configuration files, so in order to save storage, one could imagine that simply having the /usr/ be provided by a different drive (say /dev/sdb instead of /dev/sda) would fix the problem. This has the side effect though that if your second drive fails to be mounted, you have a non-working installation. However, that's rather unlikely.

Historical Approach: Split /bin and /usr/bin

Back in the days, UNIX (and Linux) did split /bin and /usr/bin into "essential" and "less essential" programs for that reason---the former was part of the boot drive, the second part of the data drive. With storage increasing, this split was reverted on most Linux distributions though.

Approach B: Merge partitions to one volume

A different approach than having the physical partition sdb provide /usr/ is to use LVM to create a logical volume of the partitions sda and sdb. This means, the file system (ext4/btrfs/zfs/...) sees a continuous storage which is actually made up of two drives. Again, obviously, this means that if one drive is inaccessible, the file system can't start up and your in for a bad situation. I've been running this setup with 5 SSDs for years now.

The nice thing is that you don't think about where to put files, you let your OS reason about this. The "philosophy" behind is to have the user spend less time administrating their PC and more on using it.

Approach C: Put /home on a different drive

This is probably the most common approach (and often combined with B). Usually, data simply exceeds programs by a good amount. (Servers, for the same reason, often put /srv on a different volume.) It puts pressure off your main drive. Furthermore, with Flatpak (or Ubuntu Snap), you have another application manager on your system than apt! This system works more with complete bundles of applications with all their dependencies in one huge package, rather than small packages. This is a bit like Apple macOS apps, or Android/iOS Apps and mostly focused on "desktop applications" (and not CLI-Tools!). I'm mentioning this, because Flatpak allows you to install applications not only to the "root tree" but also have each user install their own apps into their home directory! Again, putting of pressure off your main drive.

The /opt dir

Final note: Some packages install everything into /opt. Typically these are on the whole on the larger side and they never are essential programs. So mounting a second drive to /opt is reasonable (and approach I have taken at some point as well).

ljrk
  • 817
  • 7
  • 14
0

In Windows (and linux) it is really hard and insecure to install your programs on something different than your boot hdd/ssd. But if you mean a secondary hard drive, this is possible with some Windows programs, but AFAIK, most Linux programs cannot be installed on a secondary hard drive. Some distro's actually support installing programs on your RAM (weird, but PCLinuxOS can do that), but then you need your complete OS on your RAM and it gets deleted if your pc reboots :(

Irsu85
  • 551