Mounting home folders to sd card

Moving these posts to a new thread to isolate the discussion of mounts.

Either symlinks or bind mounts would work. I use a bind mount in /etc/fstab for my own SDcard, but if you do it, be sure to add the nofail option (my full list of options are auto,bind,nofail ) so that you won’t get stuck at boot if there isn’t an sd card present.

For instance this is how I ensure my Documents directory is stored on my SD card:

/dev/sda1 /mnt/sda1 auto auto,nofail 0 2
/mnt/sda1/Documents /home/purism/Documents none auto,bind,nofail 0 0

Repeat the second “bind” mount line for any other folders you want to bind mount into your home dir. The destination directory will need to exist.

@Kyle_Rankin I put in a beefy sd card of 128GB and mounted according to your instructions, just to realize I didn’t move the contents of my previous Documents folder to the sd card folder before mounting.
Do you keep the Documents folder etc. on the device and just empty them or what do you recommend?

EDIT: Just noticed that all of the mounts are write protected for the user purism, how can I change that?


1 Like

I just formatted the sd card to ext4. Two things:

  1. df -h reports a total space of my 128G card as 117G, used as 24K and available as 111G, why isnt the total space available?
  2. After rebooting and mounting the sd card, I have no write permissions.

Sorry for the noob questions about mounting and formatting, but I am trying to set m L5 up as a proper convergent device together with a laptop dock and for that I need a good amount of disk space on the device.

The difference in reported space and actual usable space could be the difference between “gigabytes” and “gibibytes” and disk manufacturers tend to use the metric that makes the disk seem larger.

The permissions are because when you mount a file system it is owned by root unless you pass extra options to fstab (or mount) to change that. What you will want to do is create directories within that mount point that are owned by your purism user:

sudo mkdir /mnt/sda1/Documents
sudo chown purism:purism /mnt/sda1/Documents
1 Like

Ok, if I start with mounting only /dev/sda, do I have to give it user permissions before I copy the folders over to it (I have a backup of all the folders from my first attempt)? Because I haven’t been able to copy anything to the sd card when not mounted to my /mnt.

Yes, if you create a folder within /mnt/sda1/ you will need to give it the user permissions you want it to have, because you are creating it initially as the root user, so initially it will be owned by the root user.

1 Like

Perfect, thanks, it works now!

1 Like

There is also the 5% the OS reserves for working space.

1 Like

And basically every file system has overheads to some degree.


I’m not sure if this is the best place for this, but it seems there is some experience/expertise on this thread relevant to my goal/issue.

I have an SD card that I’d like to use for my /home partition, which I’ve been using for a little over week with some success, but I’ve noticed that sometimes the mount will flip to read-only. This either occurs over some period of time or on reboot. For example:

$ mount | grep home
/dev/mapper/home on /home type ext4 (rw,relatime)

And after some time:

$ mount | grep home
/dev/mapper/home on /home type ext4 (ro,relatime)

Here are the contents of my fstab:

proc /proc proc defaults 0 0
UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX /boot ext2 errors=remount-ro 0 2
/dev/mapper/home /home ext4 defaults,rw 0 0

I know the rw is redundant with defaults, but wanted to be explicit about it. There is one partition on the card, which is luks and unlocked with a key file on boot. Any ideas on what might be going on here? I could see in the instance of reboot that maybe there is something happening out of time, but I find it really odd that the partition could flip from rw to ro while the phone is powered on.

If I can’t get this working, I’ll move to a solution suggested earlier in this thread by mounting the card under /media and then symlinking from the /home folder, but feel like this is not ideal.

… is the default. So are you getting errors on the uSD card? Maybe examine the journal with journalctl ...

Oooh, didn’t realize that. Good to know :+1:

Looks like there’s a ton of relevant logs. There’s a number of repetitions of these lines with some slight differences:

Nov 02 00:53:55 librem5 kernel: EXT4-fs (dm-0): I/O error while writing superblock
Nov 02 00:53:55 librem5 kernel: sd 0:0:0:0: [sda] tag#0 device offline or changed
Nov 02 00:53:55 librem5 kernel: EXT4-fs error (device dm-0): __ext4_find_entry:1658: inode #1706297: comm feedbackd: reading directory lblock 0
Nov 02 00:53:55 librem5 kernel: sd 0:0:0:0: [sda] tag#0 device offline or changed
Nov 02 00:53:55 librem5 kernel: Buffer I/O error on dev dm-0, logical block 0, lost sync page write

Am I dealing with a corrupted partition?

Maybe a dying SD card. If you can still read from it, I’d pull the data off and try a different SD card.

Yeah? I took it out of my phone and plugged it into my laptop to run an fsck and it turned up no issues. Is there any way I can confirm that to be the issue before running out to buy another card? I just got this one and I think it worked for a short period before this issue started, but it was a fairly brief period, so it may have been luck. Would it be worth while to reformat and start from scratch? I’m only hesitant to do that because of the time involved.

What is the capacity of your current card? Surely you have some spare card to try, even if of lower capacity? (I would rather try a spare card than reformat the existing card.)

I hate to ask but there have been many reports of counterfeit cards (from well beyond the Purism ecosystem). Sometimes those cards have a data storage capacity that is much lower than the capacity that the card reports to the operating system (but of course they are sold at a price that is close to appropriate for the reported capacity)

So … are you comfortable that you bought from a reputable supplier and a reputable brand of card? Was the price unusually low?

“a dying SD card” is just one possibility.

“A dying SD card reader” is another, albeit unlikely at this point.

I don’t know if it’s the same issue, but I will say that I randomly get an error where the Librem 5 stops being able to read the SD card. It happens the same time as another known issue where the modem suddenly stops working until a reboot is done. When I reboot to fix the modem it fixes the SD card read error too.

1 Like

256 GB and no, unfortunately I don’t have another. It just doesn’t seem to be a storage medium I need that often.

Not exactly. I bought it from a store that seems a tiny bit sketchy, but other interactions have been fine with them. Also, when I asked them how much it costs, they asked me how much I want to pay, which has never happened to me before. It’s a SanDisk.

Are there any ways to confirm any of these scenarios? The disk utility shows size and brand as expected, though I don’t know how trustworthy those are.

Say what now? Yeah that sounds somewhat sketchy. I believe you need to confirm or eliminate as a possibility the scenario that the card is counterfeit.

Some counterfeit cards have modified firmware so as to pretend to be what you thought you were buying i.e. they lie to the operating system.

Fair enough. I have a fleet of Raspberry Pi devices, so I have spare uSD cards around for those anyway.

I guess the point is that if you go out and buy a legitimate small (<= 32 GB) uSD card, it won’t cost much money (a handful of dollars).

Good question. I don’t have a ready-made script to cover it - and the test that I would want to do is destructive (to the content of the file system) so you would need to save the directory tree from the card first (and reformat and restore the directory tree afterwards).

Then I would generate a random 4KiB block of data, write it to the highest 4KiB-aligned block on the card, read it back, compare what you wrote with what you read. If you can be bothered, repeat for a downward random succession of other similarly aligned blocks.

That isn’t exhaustive but if any such block either fails to write, fails to read or compares as different then the card is either faulty or counterfeit.

If anyone knows of a shell command that can conduct this sort of test automatically, please chime in!

There is a software suite called f3 that attempts to detect counterfeit sd cards. There is a very good write-up here:

Beware though; this software will destroy all the data on your card so make sure you make a backup of your data somewhere safe before running the tests.

1 Like

Wow, this is wild, I had no idea this problem was prevalent enough to necessitate tools like this. I’ll give it a try some time, but for now I’ve resorted to buying another card from a different source since it’s not terribly expensive. It’s only been 24 hours, but I haven’t observed the same issue yet. I will report back once I have a chance to run the tests on the card or if the new one falters.

1 Like