kingneil
Posts: 36
Joined: Tue Sep 27, 2016 3:32 am

Can you modify Raspbian and then save its "state"..?

Sat Oct 29, 2016 1:00 am

Is it possible to do something like

1. strip down loads of programs out of Raspbian, install some startup scripts, etc

2. and then somehow save the entire "state" of the SD card..

3. to where you could re-download this saved state, and put it on a fresh SD card, and then the user would have exactly the same state as where you left off...?

Kind of like creating an entirely customised modification of Raspbian, but instead of doing an entire ISO, just save its state.... which can then be copied and pasted across SD cards..?

Thanks

User avatar
Douglas6
Posts: 4853
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Can you modify Raspbian and then save its "state"..?

Sat Oct 29, 2016 1:03 am

Yes.

klricks
Posts: 7135
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Can you modify Raspbian and then save its "state"..?

Sat Oct 29, 2016 1:37 am

kingneil wrote:Is it possible to do something like

1. strip down loads of programs out of Raspbian, install some startup scripts, etc

2. and then somehow save the entire "state" of the SD card..

3. to where you could re-download this saved state, and put it on a fresh SD card, and then the user would have exactly the same state as where you left off...?

Kind of like creating an entirely customised modification of Raspbian, but instead of doing an entire ISO, just save its state.... which can then be copied and pasted across SD cards..?

Thanks
Yes you can copy (backup) the OS using the built in copy utility or Win32diskimager or dd. The image can then be written to another SD card.
Your last statement does not make sense however...... The "state" of the SD card can have no other meaning except for.... backup/restore the entire OS (SD card).
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

JMK8
Posts: 42
Joined: Tue Apr 28, 2015 10:00 am

Re: Can you modify Raspbian and then save its "state"..?

Sat Oct 29, 2016 10:18 am

I suppose you could avoid saving the whole modified SD card by creating a script to implement all your desired changes on a standard Raspbian distribution. Possibly not trivial but doable.

hippy
Posts: 7459
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Can you modify Raspbian and then save its "state"..?

Sat Oct 29, 2016 1:00 pm

JMK8 wrote:I suppose you could avoid saving the whole modified SD card by creating a script to implement all your desired changes on a standard Raspbian distribution. Possibly not trivial but doable.
Something like that would be great. After every Pi install I always remove some packages, install others, add my own programs and scripts, edit boot and other configuration files, all to make things how I would like them to be. It would sure be nice to have a means of doing that automatically rather than manually every time I install Raspbian.

Unfortunately I haven't worked out any easy means to do it. With Raspbian evolving it is not safe to simply move an edited version of a file over the existing, it has to be smarter than that.

The best I could come up with is an automated check list which can tell me what I have done and what I have yet to do; You haven't removed Wolfram, You haven't installed Samba, Ethernet doesn't have the right static IP addresses, You haven't turned off CLI blanking, Your locale is wrong, etc, with brief instructions on what to do to fix the issue.

I created a means to do that for Windows back in the day, automating as much as it could, and leaving the rest for the user to sort out, but I haven't had the time to get round to it for the Pi.

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: Can you modify Raspbian and then save its "state"..?

Sat Oct 29, 2016 3:37 pm

hippy wrote:
JMK8 wrote:I suppose you could avoid saving the whole modified SD card by creating a script to implement all your desired changes on a standard Raspbian distribution. Possibly not trivial but doable.
Something like that would be great. After every Pi install I always remove some packages, install others, add my own programs and scripts, edit boot and other configuration files, all to make things how I would like them to be. It would sure be nice to have a means of doing that automatically rather than manually every time I install Raspbian.

Unfortunately I haven't worked out any easy means to do it. With Raspbian evolving it is not safe to simply move an edited version of a file over the existing, it has to be smarter than that.
sed can be a useful tool for editing config files.

For instance, in a setup script I wrote a while ago, to set the hostname I use

Code: Select all

echo $NEW_HOSTNAME > /etc/hostname
sed -i "s/127.0.1.1.*$CURRENT_HOSTNAME/127.0.1.1\t${NEW_HOSTNAME}.${DOMAIN}\t${NEW_HOSTNAME}/g" /etc/hosts
(I think this bit was based on what raspi-config does)

The sed line looks for "127.0.0.1 raspberrypi" on a clean install (CURRENT_HOSTNAME is based on whats in /etc/hostname) and then replaces it with "127.0.1.1 mypi.mydomain.org mypi" (if NEW_HOSTNAME is mypi and DOMAIN is mydomain.org)

Another set of sed rules I've used are

Code: Select all

sed -i -e '/LoadModule mpm_event_module/ s/^/# /' httpd.conf
sed -i -e '/LoadModule mpm_prefork_module/ s/#//' httpd.conf
The first searches for "LoadModule mpm_event_module" and then comments it out "s/^/# /". The second searches for "LoadModule mpm_prefork_module" and uncomments it "s/#//"

Return to “General discussion”