Why does /tmp show only 2GB instead 4GB on my RPi4?

For spinning rust type media storage wear is negligible in my experience, and even for flash reading is pretty benign. We are talking about bittorrent/filesharing IIUC not a big in memory database here :wink:
BUT not my call to make anyway :wink:

I've got dual RPi4s as file servers. The OS is on a 32GB microSD I made a multi gig partition using F2FS for /var/log. They've run continuously since early 2020 and are still going strong. I'd recommend for filesharing type uses just plug a 64GB flash drive and format it as f2fs... If the $10 drive dies after 5 years just call it cost of doing business

2 Likes

That or just attache some "spinning rust" type storage media over USB3 which in a home setting might last longer than 5 years (or not, hard discs are not infallible either and tend to draw more current).

1 Like

Almost certainly going to be more expensive overall, cheapest spinning drives are like $50 and the power consumption will be more expensive than a USB flash drive, but if you need several terabytes the spinning rust is the way to go. If the concern is to have a couple gigabytes, then a flash drive and F2FS gives you 10x that at a super cheap cost. The F2FS filesystem spreading writes over the whole thing really does work to reduce wear.

For my particular case I just wanted RAM space at least 3.5 GB so that I can download files where server cap speed to kbps for every client. Besides, I can transfer movies from my PC to router almost instantly (110MBPS from HDD) and then family members can stream those on their phones without buffering at the same time. I'm more than happy with my setup. But maybe in future I'll consider buying 512 GB flash drive and use it as f2fs filesystem to store/download files. Although it wont be as fast RPi4's DDR4 RAM read/write speed.

Just outta curiosity how do you make partition to store files on the current flash drive? Let's say, openwrt is installed on my 32GB flash drive, but I can't use any of that extra space. I read the article & it says f2fs is better than ext4 (or even exFAT) for NAND flash drives. Can I use gdisk instead fdisk?

Yes g-disk should work fine just don't touch any of the existing partitions and just add a new one

But how can I add a new partition?

As long as there's unpartitioned space, just use the usual method?

I'm not so sure how. You mean this?

DEVICE="$(sed -n -e "/\s\/overlay\s.*$/s///p" /etc/mtab)"
uci -q delete fstab.rwm
uci set fstab.rwm="mount"
uci set fstab.rwm.device="${DEVICE}"
uci set fstab.rwm.target="/rwm"
uci commit fstab
gdisk /dev/sda

Then in gdisk you can use p to print the partition table, and n for a new partition. Then you need to save the partition table, possibly reboot...

Then you'd mkfs.f2fs (which probably requires installing some packages first).

alternative method is shut down the device and physically eject the uSD card, insert it into a desktop machine and run gparted on the desktop machine to use a nice GUI.

  1. And these are the only necessary packages?
block-mount mkf2fs libf2fs6 gdisk
  1. I was hoping single line command like example
mount tmpfs /tmp -t tmpfs -o remount,size=3482M,nosuid,nodev  

Is there another way like this?

the line above doesn't create any partition ...

Okay I'm trying the gdisk method hold on
Edit:

root@OpenWrt:~# gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.8

Problem opening /dev/sda for reading! Error is 2.
The specified file does not exist!
root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                24.8M     24.8M         0 100% /rom
tmpfs                     3.4G      2.4G      1.0G  71% /tmp
/dev/loop0               68.9M    763.0K     62.6M   1% /overlay
overlayfs:/overlay       68.9M    763.0K     62.6M   1% /
/dev/mmcblk0p1           63.9M     17.1M     46.7M  27% /boot
tmpfs                   512.0K         0    512.0K   0% /dev

well how to partition on the same flash drive running openwrt?

Not a problem, as long as you're not editing any used partition.

try /dev/mmcblk0

root@OpenWrt:~# gdisk /dev/mmcblk0
GPT fdisk (gdisk) version 1.0.8

Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!

Warning: Invalid CRC on main header data; loaded backup partition table.
Warning! One or more CRCs don't match. You should repair the disk!
Main header: ERROR
Backup header: OK
Main partition table: OK
Backup partition table: OK

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: damaged

Found valid MBR and corrupt GPT. Which do you want to use? (Using the
GPT MAY permit recovery of GPT data.)
 1 - MBR
 2 - GPT
 3 - Create blank GPT

Your answer:

It's probably MBR, but if you're unsure, make a backup of the storage 1st.

Or check what fdisk says about it.

For a fresh new partition we should choose Create blank GPT right?

I would image blank GPT would wipe the existing partition table, but I might be wrong.