0

I have linux installed on a laptop with only 32 GB SSD and I'd like to be able to add an SD card and extend the system so that that the internal SSD and external SD card are continuous.

I'd like the system to still boot from the internal SSD but have the root file system on the SD card so when I use a package manager to install new software etc. it all gets installed on the (much larger) SD card.

I was hoping someone could point me in the right direction on how to do this in the best way.

slm
  • 369,824

1 Answers1

0

In Unix you can create links to other filesystem's at any point within the directory tree hierarchy.

So for example, if your SD card were mounted as /mnt, you could simply go into another directory where there's a top level directory, and simply do this:

$ ln -s existing_dir /mnt

This would be in a directory such as this:

$ pwd
/usr

$ ls -l
total 120
dr-xr-xr-x.  2 root root 24576 Jul  5 05:11 bin
drwxr-xr-x.  2 root root  4096 Nov  5  2016 etc
drwxr-xr-x.  2 root root  4096 Nov  5  2016 games
drwxr-xr-x. 34 root root  4096 Jul  5 03:00 include
dr-xr-xr-x. 30 root root  4096 Jul  5 03:00 lib
dr-xr-xr-x. 45 root root 36864 Jul  5 03:13 lib64
drwxr-xr-x. 26 root root  4096 Jul  5 03:13 libexec
drwxr-xr-x. 12 root root  4096 May  2 10:39 local
dr-xr-xr-x.  2 root root 20480 Jul  5 03:13 sbin
drwxr-xr-x. 96 root root  4096 Jul  5 03:13 share
drwxr-xr-x.  5 root root  4096 Jul  5 03:00 src
lrwxrwxrwx.  1 root root    10 May  2 10:39 tmp -> ../var/tmp

And existing_dir would be one of the above directories. Incidentally, notice that a similar approach is being taken with the /usr/tmp directory, where it's a link to another location.

Is this a good idea?

Probably not, unless you really know what you're doing. By doing this, you introduce the potential for some of your data to be on 1 HDD's partition while the rest of it being on the SD storage. If either of these fail, you'll lead to catastrophic failure of your system.

If you put the SD storage into the system, prior to installation/setup, you'd be a little better off, since, in theory, all the OS' filesystem would be contained on the single SD card.

I'd still probably not approach things this way, but that's just my $0.02.

slm
  • 369,824
  • Ok, is there a way i could instead copy the root file system to the card and then configure linux to treat it as such instead? I'm thinking about something like copying / to the sd card and then changing /etc/fstab and /proc/cmdline to point to the sd card as root. – Alon Gelber Jul 05 '18 at 19:22
  • You could do this, but you'd need to use a recovery CD/USB to boot the system into while doing this reshuffling of data that's on the HDD. – slm Jul 05 '18 at 19:23
  • that shouldn't be a problem..is there anything else you'd suggest modifying other than those two files? – Alon Gelber Jul 05 '18 at 19:39
  • @AlonGelber - keep in mind that the package manager puts files in multiple places, not just /usr. It puts things in /lib and `/etc too. – slm Jul 05 '18 at 19:44