borgauf
Posts: 5
Joined: Thu Apr 18, 2019 3:42 pm

How to prepare complete OS and software for multiple stations

Sun Dec 29, 2019 2:40 am

I'm trying to set up many (15+) RPi-4's together for a school group. I was considering Ubuntu Server 19.10 as I've heard that's a new option with the RPi-4 machine, but it's not critical that I use Ubuntu. What I do need is to set up our RPi-4's with an Debian-like Linux OS complete with many software packages, e.g., Emacs (GUI-based) and a highly customized .emacs.d/, gnuplot, TeX-Live, Racket, and many other packages. That is, I don't want to have to set up all the post-OS install packages individually on each machine. With Ubuntu I believe I could just prepare one machine with everything as I want it, then make an iso image of it -- although I'm not sure about that. Our RPi-4 machines will have 4gb RAM and 32gb SD cards. I guess the original machine cannot have a user/password already set up, correct?

User avatar
Gavinmc42
Posts: 4502
Joined: Wed Aug 28, 2013 3:31 am

Re: How to prepare complete OS and software for multiple stations

Sun Dec 29, 2019 3:03 am

You might want to practice with some Pi3 and netbooting them.
Not sure of the status of netbooting on the Pi4, is it still in testing?
Probably a PC as the server will be less hassle in the short term.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

borgauf
Posts: 5
Joined: Thu Apr 18, 2019 3:42 pm

Re: How to prepare complete OS and software for multiple stations

Sun Dec 29, 2019 3:13 am

I'm not looking to have a server-client setup. I want all machines to be stand-alone peers. I found https://lifehacker.com/how-to-clone-you ... 1261113524, but I'm not sure it applies to multiple different RPi's.

User avatar
thagrol
Posts: 2929
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: How to prepare complete OS and software for multiple stations

Sun Dec 29, 2019 11:27 am

borgauf wrote:
Sun Dec 29, 2019 3:13 am
I'm not looking to have a server-client setup. I want all machines to be stand-alone peers. I found https://lifehacker.com/how-to-clone-you ... 1261113524, but I'm not sure it applies to multiple different RPi's.
That's an old article (from 2013) so while it may work in pronciple I wouldn't rely on it in practise.

You could set up one Pi then clone the SD card to the others but doing that would mean they all have the same hostname which is bad. You won't know which one you're talking to with raspberrypi.local. But if they're not going to be networked this doesn't matter.

I have a script here: https://github.com/thagrol/usb-gadget called set_id.py that, among other things, can set a Pi's hostname based on its serial number.

For your use case:
  1. Download it to /usr/local/bin.
  2. Give it execute permission
  3. Add the following to root's crontab:

    Code: Select all

    @reboot /usr/local/bin/set_id.py -U > /tmp/set_id.log 2>&1
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

LTolledo
Posts: 3293
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: How to prepare complete OS and software for multiple stations

Sun Dec 29, 2019 11:47 am

...or change the hostname of the source every time before starting each cloning process. Its a bit tedious, and you'll have to mark each microSD card with the host name .....to prevent confusion later on.
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

borgauf
Posts: 5
Joined: Thu Apr 18, 2019 3:42 pm

Re: How to prepare complete OS and software for multiple stations

Sun Dec 29, 2019 4:21 pm

So when you say "clone," you mean create an iso image, correct? And doesn't every Rasbian new install have the default hostname "raspberrypi"? That would need changing anyway in a multi-user networked environment.

User avatar
thagrol
Posts: 2929
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: How to prepare complete OS and software for multiple stations

Sun Dec 29, 2019 7:23 pm

LTolledo wrote:
Sun Dec 29, 2019 11:47 am
...or change the hostname of the source every time before starting each cloning process. Its a bit tedious, and you'll have to mark each microSD card with the host name .....to prevent confusion later on.
Which is a right PITA. Which is why I wrote the script linked above. Though granted that was for a slightly different environment: a cluster of Pi Zeros.

Configure one Pi/SD card including ym script. Take an image of it then use that image for every other Pi. UNless you're unlucky enough to have two Pi with the same serial number each will have a unique host name once booted. Though they will reboot during that process.

Move the SD card to a different Pi, the hostname will update accordingly. Admittedly, this may not be what you want it depends on how you're using them.
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

User avatar
thagrol
Posts: 2929
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: How to prepare complete OS and software for multiple stations

Sun Dec 29, 2019 7:26 pm

borgauf wrote:
Sun Dec 29, 2019 4:21 pm
That would need changing anyway in a multi-user networked environment.
In a multi machine network environment, yes. Not so much in a multi-user environment. Hence my script above.

And, admittedly I'm being picky here, the image wouldn't be an ISO. .iso is specifically for optical discs not SD cards.
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters

borgauf
Posts: 5
Joined: Thu Apr 18, 2019 3:42 pm

Re: How to prepare complete OS and software for multiple stations

Sun Dec 29, 2019 10:25 pm

So how would I create an "image" from one SD chip set up perfectly with everything to a blank one (of the same size, make)? Is it just a copy operation?

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5587
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: How to prepare complete OS and software for multiple stations

Sun Dec 29, 2019 11:00 pm

borgauf wrote:
Sun Dec 29, 2019 10:25 pm
So how would I create an "image" from one SD chip set up perfectly with everything to a blank one (of the same size, make)? Is it just a copy operation?
No it's not "just a copy operation" :
1) Partly because no two uSDHC cards of the same nominal (labelled) size are exactly the same size and
2) It depends if you want to copy a "running" system whilst it's running (ie. clone it) or use a different, running system (could be another computer) & two "external" card reader/writers.
As hinted in previous posts cloning of a running Raspbian system is possible but will require the "hostname" of the system using the cloned card after first boot etc. FWIW, screenshots of Raspbian "SD Card Copier" Tool** "in action" and the subsequent hostname change can be seen here:
https://www.cpmspectrepi.uk/raspberry_p ... OnP4B.html
using this USB3 card reader: https://www.cpmspectrepi.uk/raspberry_p ... oSD_Reader
Trev.
** Found under the "Accessories" menu
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

User avatar
rpdom
Posts: 16986
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: How to prepare complete OS and software for multiple stations

Mon Dec 30, 2019 8:03 am

The way I would do something like this is to get one SD card set up on a Pi with the software required. Then shut the Pi down and put the card in a USB adaptor and plug it into any Linux box (even the same Pi with a default Raspbian Lite would do).

Then I would use gparted (or resize2fs and fdisk) to shrink the main partition down to a little more then the minimum size needed.

Then I would use dd with a size limit to dump the partition table and partitions to a file (probably compressed with xz to save space).

Then I would write a script that would extract that file to a new SD card (for each machine being deployed), expand the file system to fit that specific card, prompt for a hostname and update that and also set the current time in /etc/fake-hwclock.data

I do actually do something similar to this when I set up a new or test Pi. It also adds a few customisations of my own.
Unreadable squiggle

incognitum
Posts: 476
Joined: Tue Oct 30, 2018 3:34 pm

Re: How to prepare complete OS and software for multiple stations

Mon Dec 30, 2019 1:44 pm

Gavinmc42 wrote:
Sun Dec 29, 2019 3:03 am
You might want to practice with some Pi3 and netbooting them.
Yes.
For multi-user environments (like schools), there is piserver.

https://www.raspberrypi.org/blog/piserver/

All Pi use same image, so only need to install extra software once.
Do need to create accounts for all students (or link it to an existing active directory server for authentication).

swampdog
Posts: 379
Joined: Fri Dec 04, 2015 11:22 am

Re: How to prepare complete OS and software for multiple stations

Mon Dec 30, 2019 9:03 pm

There's plenty of ways to go about this as you've seen above. My method is targeted at headless rpi's so won't suit you. One thing my method does do though is mount the sdcard image partitions after writing the raspbian zip image then fiddle with them. I use a linux box to write the sdcard images: no reason why an existing rpi can't do it.

You need a tool such as 'udisksctl' to do this (looks like "apt-get install udisks2" on rpi). You'll then be able to edit the new rpi hostname prior to shoving that sdcard into the new rpi.

Return to “Beginners”