0

I am trying to dual boot ubuntu on my laptop, and because I have low space on my SSD, I have allocated 20 GB to root in the SSD, and 120 GB to the home directory in my HDD. I only installed the root on SSD for faster boot times, and my main goal is to have 90% of the files installed in the HDD.

However, it seems like everything is getting installed in the root partition of ubuntu, when I instead want to install most of the programs (including the ones I install using apt-get) into my HDD. I only want the most essential files in the SSD.

Is there a way to change the install location for software in ubuntu? Or alternatively, during the install of ubuntu, can I allocate only the essential files to the SSD and have everything else install on HDD instead?

Edit: Looks like my question is misworded. What I meant was that I want to use my SSD's efficiency coupled with the large capacity of my HDD so that I can run linux a bit faster on my laptop.

quiccode
  • 129
  • 5
    This is not a viable partition scheme. The minimum system requirement for Ubuntu Desktop is 25 GB. It would be wise to allocate more space. As far as trying to relocate where applications are installed, this is not how Ubuntu is designed to work and it's not a good idea to try to change this. Why do you even need a separate home partition to begin with? Are you sure it's necessary for your use case? What are your reasons for making a separate home partition? If you can only spare 20 GB on your SSD, then you should probably just install Ubuntu to the HDD. – Nmath Mar 27 '22 at 01:49
  • 1
    It's doable. Probably not going to end up being as beneficial as you think. I'd be lying if I said I havent seen similar on production systems. We have separate partitions for /var and even /var/log and I've seen a /home partition. It will be on you to create partitions for all the relevant directories under / during the install. Ive only ever walked into this situation, so I don't know if there is anything special that needs to be done other than creating partitions with those directory names. I think you will find that your idea of "essential files" and the OS' idea, are completely different – WU-TANG Mar 27 '22 at 02:14
  • @Nmath I'm still an ubuntu noob, so please correct me if I'm wrong, but I was under the impression that it should be possible to make it work like windows, where I have a separate "program files" folder in my HDD for installing every software in that folder, whereas the SSD contains only the important files like the drivers, notes, and other small files. I wanted to achieve something similar with ubuntu. I have actually allocated 30 GB for ubuntu, but I will be giving ~6 GB of it to swap memory. So in other words, I only want to install additional software to the HDD instead of the SSD. – quiccode Mar 27 '22 at 02:31
  • 1
    One of the worst things you could do if you are new to using Linux is to try to make it work like Windows. Due to the open source nature of Linux, you can really do anything you want, provided you have the skill and patience to do it. That doesn't mean you should. Ubuntu/Debain's package management doesn't work anything like Windows where every application is usually packaged with its own libraries and dependencies. In Ubuntu, a lot is shared. *NIX file systems are also set up differently and follow more rigid conventions. See: https://en.m.wikipedia.org/wiki/Filesystem_Hierarchy_Standard – Nmath Mar 27 '22 at 02:41
  • 1
    Definitely don't create a swap partition in this case. It isn't necessary. In absence of a swap partition, Ubuntu will use a swap file instead. A swap file has been the default for Ubuntu installations for several years now. So if you can use that extra 6GB for your root partition that will put you at 26GB. – Nmath Mar 27 '22 at 02:50
  • 1
    ...addendum to above... while in the install, just put "/" on ssd.... make at least 6 more partitions on the HDD and while creating them, from the drop down put /home, /usr, /bin, /sbin, /snap, and /var on those partitions... I'm a little more experimental than most... I just stepped through this in the install but without actually hitting the install button. But @Nmath I think what he is describing is way less frankenstein than his description... I think in time he'll see it really wasn't worth it.. but it doesn't seem that bad – WU-TANG Mar 27 '22 at 02:51
  • @WU-TANG I agree that it would not be worth it. If the idea behind installing to the limited space on the SSD is so that it can benefit from faster start and launch times. But even having /usr and /home on a HDD is going to eat into that considerably – Nmath Mar 27 '22 at 02:56
  • see also https://askubuntu.com/q/313592 and https://askubuntu.com/q/27213 – Nmath Mar 27 '22 at 03:09
  • linux has the Filesystem Hieracy Standard (man fhs and https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html ) that explains what directories are required. Ubuntu software installs in these directories. To mess with this leads to madness. – waltinator Mar 27 '22 at 03:23
  • @Nmath Well I was only using windows as an analogy but this seems to be more of a fundamental problem for me: Since I have low disk space on my ssd, I wanted to divide the workload between my ssd and the hdd, so that I could utilize the fast performance of my ssd to load in the essential files, and use hdd as the main container for everything else. It is unfortunate that I can't do that because of ubuntu's file system, so I guess I'll be installing everything in the hdd instead then. But I feel like that should be an option in the OS so that people with ssd low space can still benefit. – quiccode Mar 27 '22 at 06:26
  • @WU-TANG Thanks, that is something I could attempt...Would you happen to know an estimate of the size I'd have to allocate each partition to, or a source that has that info? – quiccode Mar 27 '22 at 06:30

2 Answers2

2

How do I make it so that ubuntu installs everything on /home instead of the root?

You don't, unless you have deep knowledge on how to configure a linux system differently than the conventions.

However, you can configure a linux system rather easily to have system files placed on another drive, i.e. in your case, a HDD rather than the SSD. Symlinks already would cut it - several directories of the system file structure could be redirected to a HDD this way.

Still, also that is not optimal. For performance - fast startup, fast response of the system and fast loading of programs - prefer leaving all the system files on the SSD. 20 GB is already quite adequate to contain a Linux operating system provided you have your /home directory mounted on another drive, but it still depends on how many programs you install, and whether you install applications as snap or flatpak instead of as a regular APT package.

  • You could move out your swapfile to the other drive, especially if you have 8 GB of memory or more. Swapping, however, will become markedly slower if you need it.
  • Make sure you regularly clean out old kernels, which each take a few hundreds of megabytes. The command sudo apt autopurge will remove all libraries that are not needed anymore, but also will remove all old kernels, except one: one old kernel is kept. That facilitates keeping sufficient free space on your root partition.
  • Several applications now are available as an AppImage. You place these where you want. That is another way to cut down on the number of packages you need to install in the system file area.
  • If the need arizes, and you use snap a lot, linking out system files of snap (/snap/, /var/snap/, /var/lib/snapd/) remains a possibility. Cold startup times, however, would severely worsen more over what they already are when using SSD.
vanadium
  • 88,010
2

As pointed out several times, this is idea of yours is probably not going to be as effective as you are thinking... BUT... it is not out of the way or illogical. It is usually just done for other reasons.

(in your defense) I use a system that has things like elasticsearch and database software that has a lot of indexes and logs constantly building up on them. Yes, the ideal way to deal with that would be to responsibly handle the logging or indexes, but there is no way to compensate for that if the system falls into an error state. I also worked on a system where /home has its own partition, simple because there was no way to predict what havoc "users" would release... So yes we wanted a separate partition (even disk) for those, to not have the root disk being at risk of filling and locking up the production machine.

I think the way you worded some things has caused some people to go on alert (you also have to realize that you are not going to be the only one seeking info and reading this question/answers/comments). But from what I can tell, your goal is just to use the efficiency of the limited space on the SSD for your OS, while putting the most of what you can on your HDD. If that is true, that is definitely not what the wording of your question [currently] implies. (it also says that you might not quite understand the concept of /home yet)

So, if my interpretation is correct, then you could attempt something like what I described in the comments. During the install, (choosing "something else", when you're asked how you want the install configured):

Just create a partition on your SSD, designating your "/" mount point there.

And on your HDD create several partitions. Personally, I'd say about 6 for /home, /usr, /bin, /sbin, /snap, and /var.

Here I did a bit of what you are trying to do. I put "/" on a partition (/dev/sdb1) on one drive and /home on another partition (/dev/mmcblk1p3) on a different drive. And began creating another partition for /usr... Notice some of these directory names are preloaded options, so this is meant to work this way. enter image description here (My depiction is STRICTLY an example, to show that multiple drives can be used and also to illustrate the dropdown selections... I just selected partitions that I had available to play with... I know the layout doesn't make sense)

This is going to be trial and error for you.

If you do sudo du -hd 1 / on an existing system you would get an idea of directories file size usage. Then you can make the partition sizes proportional to what you see. Now you have your partitions on your big drive, so I wouldnt be too concerned with over-sizing them, again, trial and error...(Especially if you were willing to give swap 6 Gigs!, way overkill in my PERSONAL opinion). You just have to use some logic, knowing that the entire system would normally have been stored on that 20G partition you previously installed on. (...but I can say my /snap directory has 9G in it)

I don't expect any recognizable increase in performance from this... But that is for you to figure out and experiment with. I wouldn't steer any one else towards this type of setup... but in your (the OP) case, if you have the logic in your head and you want to test it, this is a good science project for you and hopefully you'd only benefit from the lessons.

WU-TANG
  • 3,071
  • That is exactly what I want, yes, thank you for the info! Sorry for the misunderstanding, it looks like I need to do more reading on how linux's file system works. I will edit the original question accordingly – quiccode Mar 27 '22 at 21:56
  • Not sure if this is exactly what you want for a personal computer. You are using space inefficiently with separate partitions, and if there is a need to resize, you will be stuck, unless you would implement this with LVM. – vanadium Mar 28 '22 at 08:53