Quantcast
Channel: Linux Device Hacking
Viewing all articles
Browse latest Browse all 3191

howto: easy startover with a fresh debian (1 reply)

$
0
0
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

Viewing all articles
Browse latest Browse all 3191

Latest Images

Trending Articles



Latest Images