Debian Installer (LWP) with multiple disks

Jurjen Bokma

May 2011


We try to unattended-reinstall Linux on /dev/sda1 without damaging the software RAID that is on /dev/sdb and /dev/sdc.

Procedure 20.  Seeing if the LWP is RAID-proof (if the RAID is on other disks than the OS)
  1. To get Linux on the machine in the first place, we use the LWP installer: a preseeded D-I that installs in to the largest free space, with an @partman_early_command script that cleans the previous install out of that space.

    [Warning]Warning

    It is very important to realise that if there are any large empty disks - if they are larger than the 40GB-or-so hole left for the OS on /dev/sda - then the installer is probably going to pick that disk for the OS, instead of the hole on /dev/sda.

  2. Be fore we reboot, we add two extra disks. The after reboot, we create the raid as described in . Both /dev/sdb and /dev/sdc are 50GB, while /dev/sda is 40GB. The installer has an algorithm that chooses the largest free space to install the OS in. It should still ignore /dev/sdb and /dev/sdc because their partition tables say they are occupied by RAID partitions, but we do want to tempt the installer a bit. After all, we wouldn't like to have this test succeed, only to see our actual RAID overwritten because its disks are larger.

  3. To get rid of the filesystems on each partition and reboot he machine, we do:

    sudo sh -c "for i in 9 8 7 6 5 3 2 1 '' ; do dd if=/dev/zero of=/dev/sda${i} bs=512 count=20000 ; done ; shutdown -r now"

    Then we reboot and install the LWP once again.

  4. Not only has the RAID survived, mdadm has automatically been installed, /etc/mdadm/mdadm.conf has been autoconfigured, and /dev/md0 can readily be mounted:

    admin@host:~$ sudo mount /dev/md0 /mnt/D
    admin@host:~$ ls /mnt/D
    RAIDME.txt  lost+found
    admin@host:~$ cat /mnt/D/RAIDME.txt
    This is a file on a RAID created during a previous run

[Note]Note

We put the RAID on /dev/sdb1 and /dev/sdc1. So the disks do have partition tables. However, all this works if we use bare-device RAID too.