User avatar
jahboater
Posts: 7318
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: This fits into a few categories, so please help in the area you can. Thanks

Sun Jul 25, 2021 12:24 am

thagrol wrote:
Sun Jul 25, 2021 12:13 am
That said, the advantage of putting thing like /tmp and /run into RAM isn't performance, it's that it reduces writes to the SD card.
Yes, but tmpfs is extremely fast too.
I use this on my 8GB Pi4:

Code: Select all

tmpfs /tmp tmpfs defaults,noatime,nosuid,size=7g 0 0
tmpfs /var/log tmpfs defaults,noatime,nosuid,size=16m 0 0
.

bob332
Posts: 38
Joined: Mon Jul 15, 2019 12:15 am

Re: This fits into a few categories, so please help in the area you can. Thanks

Sun Jul 25, 2021 1:11 am

Saying that a RAM drive will reduce writes to the SD Card, am I correct in thinking that a 8GB model will have less writes than a 2GB model or does the OS not work that way?

Also, any recommendations for a particular "RaspbianPi for a dummies" style book? That I could get a lot of these questions figured out on my own without bothering you guys/gals and get to more to the "meat" of the Pi?

I still need to look at the USB3 under a microscope, I will get to to that hopefully tomorrow.

Appreciate all the answers thus far,
Bob

bob332
Posts: 38
Joined: Mon Jul 15, 2019 12:15 am

Re: This fits into a few categories, so please help in the area you can. Thanks

Sun Jul 25, 2021 4:20 am

May as well ask for an excellent Python3 book too!

Thanks all!


It has been a while since I have coded, but that does not deter me ( 20+ years )!

Recommend me the great books!

Bob
.…

User avatar
jahboater
Posts: 7318
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: This fits into a few categories, so please help in the area you can. Thanks

Sun Jul 25, 2021 9:57 am

bob332 wrote:
Sun Jul 25, 2021 1:22 am
Saying that a RAM drive will reduce writes to the SD Card, am I correct in thinking that a 8GB model will have less writes than a 2GB model or does the OS not work that way?
Possibly, it depends on your usage.
It also may reduce reads, which although they don't wear out the SD card, do help performance.
When the 8GB model was released Eben pointed out that all the app's on the OS distribution could fit in memory.
(every time you run a program, it and any data that it read or wrote, is retained in memory in case its used again. So if you run a program twice, the second time it will start much faster).

I also add this to the / (ext4) entry in fstab
PARTUUID=ca2ecb0f-02 / ext4 defaults,lazytime,noatime,commit=1000,errors=remount-ro 0 1
The commit=1000 reduces writes to the SD card and improves performance (at an increased risk of corruption if you have an unplanned power cut). I have used it for years on all my Pi's with no problems.
commit=1000 flushes the dirty blocks in the disk cache every 1000 seconds instead of the ultra-conservative default which is every 5 seconds.

As for RAM disks, tmpfs is actually "virtual memory", its not a normal RAM disk (which would be ramfs).
With tmpfs memory is only used for the actual files stored on it, unlike a RAM disk where the entire disk is allocated in memory.
Also if memory is short, tmps files will get paged out like any other memory.

ejolson
Posts: 8070
Joined: Tue Mar 18, 2014 11:47 am

Re: This fits into a few categories, so please help in the area you can. Thanks

Sun Jul 25, 2021 3:06 pm

jahboater wrote:
Sun Jul 25, 2021 9:57 am
bob332 wrote:
Sun Jul 25, 2021 1:22 am
Saying that a RAM drive will reduce writes to the SD Card, am I correct in thinking that a 8GB model will have less writes than a 2GB model or does the OS not work that way?
Possibly, it depends on your usage.
It also may reduce reads, which although they don't wear out the SD card, do help performance.
When the 8GB model was released Eben pointed out that all the app's on the OS distribution could fit in memory.
(every time you run a program, it and any data that it read or wrote, is retained in memory in case its used again. So if you run a program twice, the second time it will start much faster).

I also add this to the / (ext4) entry in fstab
PARTUUID=ca2ecb0f-02 / ext4 defaults,lazytime,noatime,commit=1000,errors=remount-ro 0 1
The commit=1000 reduces writes to the SD card and improves performance (at an increased risk of corruption if you have an unplanned power cut). I have used it for years on all my Pi's with no problems.
commit=1000 flushes the dirty blocks in the disk cache every 1000 seconds instead of the ultra-conservative default which is every 5 seconds.

As for RAM disks, tmpfs is actually "virtual memory", its not a normal RAM disk (which would be ramfs).
With tmpfs memory is only used for the actual files stored on it, unlike a RAM disk where the entire disk is allocated in memory.
Also if memory is short, tmps files will get paged out like any other memory.
In my opinion the commit setting along with lazytime and noatime automatically make good use of extra RAM without having to manually create and manage a RAM-backed filesystem.

If worried about wear on the SD card from lots of user activity, I'd suggest placing the home directories and maybe /tmp on either a USB3 SSD or an iSCSI network block device. Even a simple NAS such as the QNAP TS-231P (in my case) can be configured to provide an iSCSI target as the home directory for a Raspberry Pi.

Since iSCSI appears to the OS as another physical drive, it also enjoys the benefits of the larger Linux buffer cache provided by the 8GB RAM. Such a setup allows me to work on projects where I constantly copy and compile files without concern about excess wear to the SD card.

bob332
Posts: 38
Joined: Mon Jul 15, 2019 12:15 am

Re: This fits into a few categories, so please help in the area you can. Thanks

Sun Jul 25, 2021 8:30 pm

ejolson wrote:
Sun Jul 25, 2021 3:06 pm
jahboater wrote:
Sun Jul 25, 2021 9:57 am
bob332 wrote:
Sun Jul 25, 2021 1:22 am
Saying that a RAM drive will reduce writes to the SD Card, am I correct in thinking that a 8GB model will have less writes than a 2GB model or does the OS not work that way?
Possibly, it depends on your usage.
It also may reduce reads, which although they don't wear out the SD card, do help performance.
When the 8GB model was released Eben pointed out that all the app's on the OS distribution could fit in memory.
(every time you run a program, it and any data that it read or wrote, is retained in memory in case its used again. So if you run a program twice, the second time it will start much faster).

I also add this to the / (ext4) entry in fstab
PARTUUID=ca2ecb0f-02 / ext4 defaults,lazytime,noatime,commit=1000,errors=remount-ro 0 1
The commit=1000 reduces writes to the SD card and improves performance (at an increased risk of corruption if you have an unplanned power cut). I have used it for years on all my Pi's with no problems.
commit=1000 flushes the dirty blocks in the disk cache every 1000 seconds instead of the ultra-conservative default which is every 5 seconds.

As for RAM disks, tmpfs is actually "virtual memory", its not a normal RAM disk (which would be ramfs).
With tmpfs memory is only used for the actual files stored on it, unlike a RAM disk where the entire disk is allocated in memory.
Also if memory is short, tmps files will get paged out like any other memory.
In my opinion the commit setting along with lazytime and noatime automatically make good use of extra RAM without having to manually create and manage a RAM-backed filesystem.

If worried about wear on the SD card from lots of user activity, I'd suggest placing the home directories and maybe /tmp on either a USB3 SSD or an iSCSI network block device. Even a simple NAS such as the QNAP TS-231P (in my case) can be configured to provide an iSCSI target as the home directory for a Raspberry Pi.

Since iSCSI appears to the OS as another physical drive, it also enjoys the benefits of the larger Linux buffer cache provided by the 8GB RAM. Such a setup allows me to work on projects where I constantly copy and compile files without concern about excess wear to the SD card.
Out of curiosity, how does a Pi work when using a NAS as the drive for all the drive activity over the network? I know I could get one of the re-branded LSI SAS/SATA ( with the thought of using SSDs - I will need to research this the verify ) cards on the cheap and put a pair of 256GB ( or even 128GB ) SSDs in a RAID1 setup? I know it would kill any chance of a power savings, but that machine would be on a decent ( for home ) battery backup, unless I were to run the machine off of solar, which I think I could do with 2x 100W panels, then after the initial investment would be free power...

Any thoughts on this type of setup? Any suggestion on a solar controller using either 2x motorcycle batteries or even 2x small car batteries? I believe I have stated I believe in this thread I get a ton of Sun ( ~300 days a year ) which was going to be used for a solar powered sprinkler controller using motorcycle batteries, but just upsizing the components ( by putting the batteries in parallel ) the components a bit would ( in theory ) make it a perfect computer UPS since battery death is caused out here is by heat ( ~2-3yr max ) in the engine compartment. I am a PHX, AZ native and all the years I can remember, going back to childhood, I do not ever recall receiving getting a car battery replaced 100% via the " warranty ".

Again, greatly appreciate the suggestions,
Bob

Return to “Other projects”