rcpinheiro
Posts: 7
Joined: Fri Apr 05, 2019 1:40 pm

Raspberry Pi at home and at work

Tue Oct 15, 2019 10:29 am

Hi!
I have a Raspberry Pi at work that sometimes I bring home. The configuration in the two environments is different: some services I don't want to run on one of them, firewall rules changes, no wireless or DHCP at work, etc.

What is the best and fastest way to accomplish this with minimal user interaction? Right now I have some cumbersome scripts to do this after logging in but what I really need is a kind of multi-boot where the user select the environment at boot time before loading services, network, login, etc.
Thanks in advance!

W. H. Heydt
Posts: 11111
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Raspberry Pi at home and at work

Tue Oct 15, 2019 3:50 pm

Simplest way...use two different microSD cards. One for work, one for home. If you need to have common data files, put them on a USB stick. There are some really tiny USB storage devices that you can just leave in the Pi when you move it.

User avatar
B.Goode
Posts: 8987
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Raspberry Pi at home and at work

Tue Oct 15, 2019 4:58 pm

^--

+1 for what @whh said.

(Annoyed with myself that I wrote a similar reply in almost identical terms about 6 hours ago but failed to hit [Submit] ... )

bjtheone
Posts: 397
Joined: Mon May 20, 2019 11:28 pm
Location: The Frozen North (AKA Canada)

Re: Raspberry Pi at home and at work

Wed Oct 16, 2019 7:16 pm

W. H. Heydt wrote:
Tue Oct 15, 2019 3:50 pm
Simplest way...use two different microSD cards. One for work, one for home. If you need to have common data files, put them on a USB stick. There are some really tiny USB storage devices that you can just leave in the Pi when you move it.
Building on this, use one common SD card to boot and run off two seperate SSD (leave one at work, and one at home). Works great if you have different data sets at home and work, and really should keep them seperate. Alternately have the full OS with appropriate configs on the two SD cards and all your user data on a single SSD and schlep it back and forth if you have a large amount of data. Done right this has the advantage of being able to fairly easily access/use your data on another computer.

Another would be 2 SD cards and store your shared files in the cloud. It really depends on your particular use case (size and number of files, and any restrictions on how they can leave the company).

Are you trying to continue to do work at home, or are you wanting to use the same computer for two different sets of tasks?

rcpinheiro
Posts: 7
Joined: Fri Apr 05, 2019 1:40 pm

Re: Raspberry Pi at home and at work

Fri Oct 18, 2019 5:30 pm

Thanks for the answers.
The SD Card+External storage is a valid solution but I'l use it as a last resort.
I was thinking along the lines of creating a dialog to select Work or Home in runlevel 2 and change accordingly the configuration files for network and other services. I'll have to dig deeper in /sbin/init manuals to see if this is possible.

User avatar
DougieLawson
Posts: 36578
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Raspberry Pi at home and at work

Fri Oct 18, 2019 5:37 pm

/sbin/init is the systemd control program.

Your better option is to look a PINN (which is a superset of the NOOBS multiboot manager). You can probably set up an SDCard with two distinct copies of Raspbian and use PINN to switch between them. You'll need a 32GB SDCard to do that.

The PINN developer is Procount on here.

https://www.raspberrypi.org/forums/view ... p?t=142574
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

rcpinheiro
Posts: 7
Joined: Fri Apr 05, 2019 1:40 pm

Re: Raspberry Pi at home and at work

Fri Oct 18, 2019 9:07 pm

Here's what I've done:

/etc/profiles/choices:

Code: Select all

#!/bin/bash
lastone=`cat /etc/profiles/menu.choice`
WORK=$(systemd-ask-password --timeout 10 "Are you at work? ($lastone): " --echo)
echo $WORK > /etc/profiles/menu.choice

/lib/systemd/system/profile.service

Code: Select all

[Unit]
Description=Profile choice
After=-.mount

[Service]
Type=oneshot
ExecStart=/etc/profiles/choices

[Install]
WantedBy=multi-user.target

Enable service using: systemctl enable profile.service and you're almost done!
Now all you have to do is to make the required services to start after the profile is choosen by using After= in the systemd unit and alter the script to check the user selection (/etc/profiles/menu.choice).

PS: Thanks for the tip, DougieLawson. I will check PINN out.

Return to “Advanced users”