Welcome! Log In Create A New Profile

Advanced

howto: easy startover with a fresh debian

Posted by shivahoj 
howto: easy startover with a fresh debian
September 23, 2017 08:59AM
Hello,
I am learning to use ansible, to automatize linux installation of server farms for my job, and i need A LOT of fresh untampered debian installs to play with.

I have come to use one of my NSA320 to boot form different partitions(on same or different hard disks), depending on environment settings.
Thus i can just mount and erase a broken installation of a debian server, say on /dev/sdb1, while safely booting from /dev/sda1.

Prerequisites:
  • 2 or more ext2/3/4 Partitions. I suggest naming them differently, like rootfs1, rootfs2 etc. I used 2 partitions both labeled "rootfs" on /dev/sda1 and /dev/sdb1. One of the partitions could be your "master" for daily use, while the other(s)are for experimenting only.
  • some script(s) on the "master" to change the boot-device related env variables
  • a recent debian install tarball ( i use Debian-4.12.1-kirkwood-tld-1-rootfs-bodhi.tar.bz2) on the master part.
  • a working serial or nc boot control (only necessary if you play with the ssh daemon or lock yourself out some other way).

First i install a debian linux on /dev/sda1(partition named "rootfs"), together with all my stuff i like or need. 4 GB space should be enough for that. This will be my "master" partition that wil not be affected by ansible.
Then i create a like-sized, like-named partition on /dev/sdb1, mount it somewhere and untar a fresh debian tarball there.

Finally i create two text files, i named them boot01 and boot11. 01 stands for disk0, partition1, and 11 for disk1, part.1
root@publik2:/home/dirk# cat boot01
# This file sets the bootdevice to the 1st partition of the first (left) drive
device 0:1
load_uimage ext2load ide 0:1 0x800000 /boot/uImage
load_initrd ext2load ide 0:1 0x1100000 /boot/uInitrd
load_dtb ext2load ide 0:1 0x1c00000 /boot/dts/kirkwood-nsa320.dtb
and
root@publik2:/home/dirk# cat boot11
# This file sets the bootdevice to the 1st partition of the second (right) drive
device 1:1
load_uimage ext2load ide 1:1 0x800000 /boot/uImage
load_initrd ext2load ide 1:1 0x1100000 /boot/uInitrd
load_dtb ext2load ide 1:1 0x1c00000 /boot/dts/kirkwood-nsa320.dtb
when i want to practice ansible, i do
sudo fw_setenv --script /home/dirk/boot11
sudo reboot
and after reboot i have a fresh debian installation.
So i if i mess up an ansible playbook(thats what the ansible scripts are called), i start over by going back to my master partition
sudo fw_setenv --script /home/dirk/boot01
sudo reboot
and after reboot, i can mount the testing partition and delete all the broken stuff, and untar a fresh debian.
To find out which disk you booted from you can always use mount without options.
I use a ssh-banner to remind me that i have booted the system i shouldnt mess with.
Of course you can also set a warning in the shell prompt.

If you decide to give your root partitions different volume names, you must change the root=LABEL=YourName in the env line
bootargs=console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 orion_nand:1M(u-boot),512K(uboot_env),512K(key_store),512K(info),10M(etc),10M(kernel_1),48896K(rootfs1),10M(kernel_2),-(rootfs2)
to represent your Volume Label name.
To be done:
The process of mounting the broken installation, deleting it, untarring a fresh debian, changing the boot drive and rebooting could use a nice shell script

2 Pieces NSA320 , u-boot 2016.05, debian 4.12.1, Several Mac and Linux boxes connected.
More into soldering than programming. Location:Hildesheim, Germany



Edited 3 time(s). Last edit at 09/23/2017 09:11AM by shivahoj.
Re: howto: easy startover with a fresh debian
September 23, 2017 09:47AM
You could do this just as well with a TFTP-boot, but i like to depend as little as possible on other machines or hard-to-debug protocols...



Edited 1 time(s). Last edit at 09/23/2017 09:48AM by shivahoj.
Re: howto: easy startover with a fresh debian
September 23, 2017 06:39PM
shivahoj,

Very good approach! this is similar to what I did about 5 years ago with old u-boot.

With the new u-boots, a big improvement can be applied to this type of setup: use uEnv.txt capability to control what will be the next boot system. The advantages of using uEnv.txt:

- No need to write envs to flash (avoid wearing out NAND).
- Can use Linux shell script to set the uEnv.txt location (rootfs partition) and content.
- Netconsole can be also used to accept input and control the boot option at power up.

Hint: don't use multiple uEnv.txt files. Use one uEnv.txt file and its presence as an indicator of the boot partition.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 2 time(s). Last edit at 09/23/2017 06:43PM by bodhi.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: