How to install applications to a separate hdd?
I was so good with windows, now I’m feeling like a complete idiot.
I have an SSD for ubuntu and want to install the majority of my programs to a separate HDD but I have no clue how.
All searches I have tried only turn up with dual-boot installations.
-
(RESOLVED -> )
I am also having trouble locating "/etc/". Specifically, to modify Conky.
Searching for this term only turns up instances where people are telling you to access this file, not how to get to it.
Solution 1:
There is a major difference between Windows and GNU/Linux. On Windows it is common, that each program together with all the libraries it depends on is installed in a separate folder. This often leads to a lot of wasted disk space due to libraries being installed multiple times, for each program that uses them.
On Linux, programs are installed following the Filesystem Hierarchy Standard (FHS). This means, that the libraries the programs depend on are all installed in a common dedicated location, so that they are usually only installed once, no matter how many programs use them. Also, programs are built in such a way, that they all use the same version of a certain library. This saves disk space (and RAM at runtime), but has the drawback, that one cannot freely install programs on different partitions or hard disks, at least not without editing system configuration files (for instance /etc/ld.so.conf.d to include the different library folders).
Since the Debian package system was implemented with the FHS in mind, there is, as far as I know, no easy way to install Debian packages to a folder different from the one they were intended to be placed in and have them working without manually moving and editing files afterwards. This is, because paths are often hardcoded at compile time. So even if you install a package to a different folder, for instance by using dpkg --instdir=folder/ package.deb
on the command line, the program will still look for its configuration in '/etc', not 'folder/etc', but the config files that were shipped with the package of course were installed to 'folder/etc'... The program will not be added to the menu either, since menu files are supposed to be in '/usr/share applications', not in folder/usr/share/applications.
You can of course manually configure and compile a program from its source code to have it install the binary and data parts wherever you'd like, while still installing configuration files to the FHS compliant locations, but this is something I'd only recommend for advanced users. If you are going to compile from source, have a look at checkinstall, a tool that automatically creates debian packages.
Another option, that was suggested on linuxfromscratch, is to unpack the package to a suitable location and then to create symbolic links to all installed files in the corresponding FHS locations.
Since in the comments you were referring to games: Many games that are not bought through Ubuntu Software Center come as an installer executable, and those can then of course be installed to any folder, usually a subfolder of your home directory. Windows games, which are being run using WINE can also be installed in any directory you want. For wine there exists an environment variable called WINEPREFIX with which you can set up numerous independent WINE folders, each including its own virtual C: drive. Read the WINE man page for more info.
Even if games/programs come as Debian packages, you can look at the package contents in your favorite archive manager. If the game is going to be installed in /opt, you can usually safely install it to a different folder, since /opt is often used as installation location for programs that don't adhere to FHS.
Solution 2:
TL;DR
Boot the external USB disk with the version of Ubuntu you just installed and I'm assuming
/dev/sda
is your SSD and/dev/sdb
is your HDD.Create a partition on your HDD to contain all the applications you want to install (let's say 64 GB) using gparted and I'm assuming this will be the third partition you'll be creating on your HDD (
/dev/sbd3
)-
execute the following commands:
mkdir /media/apps mount /dev/sdb3 /media/apps mkdir /media/apps/usr cp --preserve=all --recursive /opt /media/apps cp --preserve=all --recursive /usr/bin /media/apps/usr
-
sudo nano
thefstab
on/dev/sda1/etc/
to include the following right after the/
entry (the root directory)/dev/sdb3 /media/apps ext4 errors=remount-ro 0 0 /opt /media/apps/opt none defaults,bind 0 0 /usr/bin /media/apps/usr/bin none defaults,bind 0 0
reboot and test
The long version:
Unix / Linux / Ubuntu was conceived to be a server OS with a desktop as an afterthought whereas Windows was conceived to be a Desktop OS and the server came as an afterthought.
So the Linux Filesystem Hierarchy Standard allows you to have an unlimited amount of drives / partitions to be located anywhere and bind them to the correct drive or partition with total transparency to the user whereas the Windows OS is limited to a maximum of 24 accessible drives/partitions (C:
through Z:
as A:
and B:
are reserved for floppy disks.)
Most applications you install yourself get installed in /opt/
and /usr/bin
, so install Ubuntu normally and then use the below steps where I'm assuing /dev/sda
is your SSD, /dev/sdb
is your HDD and /dev/sdd
is your USB stick:
- Boot the external USB disk with the version of Ubuntu you just installed.
- Create a partition on your HDD to contain all the applications you want to install (let's say 64 GB) using gparted and I'm assuming this will be the third partition you'll be creating on your HDD (
/dev/sbd3
) -
Mount that partition in a temporary directory:
mkdir /media/apps mount /dev/sdb3 /media/apps
-
copy the existing
/opt
and/usr/bin
to there:mkdir /media/apps/usr cp --preserve=all --recursive /opt /media/apps cp --preserve=all --recursive /usr/bin /media/apps/usr
-
sudo nano
thefstab
on/dev/sda1/etc/
to include the following right after the/
entry (the root directory)/dev/sdb3 /media/apps ext4 errors=remount-ro 0 0 /opt /media/apps/opt none defaults,bind 0 0 /usr/bin /media/apps/usr/bin none defaults,bind 0 0
reboot and test
- If everything works correctly, reboot to the USB stick again and delete everything in the
/dev/sda1/opt
and/dev/sda1/usr/bin
to reclaim the disk space still in use by now obsolete directories already mounted somewhere else.
Warning: the last command might also make your system crash in the unlikely case of /dev/sbd3
not mounting due to a HW failure