LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   How can I prevent this error during a kickstart install (http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/how-can-i-prevent-this-error-during-a-kickstart-install-4175431756/)

PeterSteele 10-11-2012 05:53 PM

How can I prevent this error during a kickstart install
 
I have what is intended to be an unattended install of a CentOS VM controlled through kickstart. I partition a drive into two parts, each to host a VM, using the sequence

Code:

    dd if=/dev/zero of=/dev/sdb bs=512 count=1
    parted -s /dev/sdb mklabel gpt
    parted -s /dev/sdb mkpart primary ext4 0 20G
    parted -s /dev/sdb -- mkpart primary ext4 20G -1
    sleep 0.5
    partprobe /dev/sdb

I then install a VM on sdb1 and sdb2. The install on partition 1 works without issues. When the kickstart install is running on partition 2 however, the following dialog appears:

Code:

+-------------------------------- Warning +---------------------------------+
                                                                            
         Error processing drive:                                ?         
                                                                 ?         
         pci-0000:00:04.0-virtio-pci-virtio1                             
         944103MB                                                         
         Virtio Block Device                                             
                                                                          
         This device may need to be reinitialized.                       
                                                                          
         REINITIALIZING WILL CAUSE ALL DATA TO BE LOST!                   
                                                                          
         This action may also be applied to all other disks               
         needing reinitialization.                              ?         
                                                                            
   +--------+  +------------+  +---------------+  +-------------------+ 
   Ignore   Ignore all   Re-initialize   Re-initialize all  
   +--------+  +------------+  +---------------+  +-------------------+ 
                                                                            
                                                                            
 +----------------------------------------------------------------------------+

I'm sure many of you are familiar with this dialog. I problem is I just want it to default to "Re-initialize all" and not interrupt my kickstart. Is there any way to do this?

The command I am using to install my VM is this:

Code:

virt-install --connect=qemu:///system \
            --network bridge=br0
            --initrd-inject=/ks.cfg \
            --extra-args="ks=file:/ks.cfg text console=tty0 utf8 console=ttyS0,115200" \
            --name=vmtest \
            --disk path=/dev/sdb2,bus=virtio \
            --vcpus=1 --ram=4096 --check-cpu --accelerate \
            --hvm --location=centos.iso \
            --nographics --noreboot


PeterSteele 10-12-2012 12:03 PM

I solved the problem, sort of, by using the command

Code:

dd if=/dev/zero of=/dev/sdb bs=1M count=1
to clear out the old partition table. In the past I've just cleared out the first 512 bytes and that seemed to suffice. At least I don't get the error from kickstart.

But there must be a *correct* way of doing this, clearing out old partitions and creating new ones, without the VM installing thinking it has a bad drive.

PeterSteele 10-13-2012 03:19 PM

I spoke too soon. Even with bs=1M, I am hitting this error at times. Is there anyway to force the "Re-initialize all" option to be automatically selected in this case?

Barring that, I guess the solution would be to use a pre-script and format the partition manually, and tell kickstart to install on that partition directly without formatting it. That should do the trick, but I was hoping to avoid this approach...

jars99 03-05-2013 02:23 PM

I'm having this problem as well. Did you ever figure out a solution?

PeterSteele 03-05-2013 05:56 PM

Yes, I came up with a solution that works for us. I'd think you could adapt it to your case as well. What I did was write a %pre script that does this:

%pre --log=/root/anaconda-pre.log
echo "#####################################"
echo "# Running pre configuration script #"
echo "#####################################"
set -x
parted -l
cd /dev
for d in sd?; do
# Skip drive sda since this is the USB boot stick
if [ "$d" = "sda" ]; then continue; fi
# Everything else is a valid drive on the system, so go
# ahead and zap the disk and label it.
dd if=/dev/zero of=/dev/$d bs=1M count=1
parted -s /dev/$d mklabel gpt
done
%end

My install runs from a USB stick, so if you are booting from a DVD, you will want to remove the first two lines inside the for loop. What this code does is loop through all drives and wipes out the partition table, if any, and then creates gpt label on each drive. This %pre script is of course part of the kickstart script. The core steps of the kickstart script look like this:

install
text
poweroff
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw root
firewall --disabled
selinux --disabled
timezone --utc America/Los_Angeles
firstboot --disable
bootloader --driveorder=sdb --location=mbr --append="console=tty0 console=ttyS0,115200"
part / --ondrive=sdb --fstype=ext4 --asprimary --size=10240
...

Note again that I am referencing drive sdb here because we are using a USB boot stick. You'd want to change this to sda if you are booting from a custom DVD.

Give this a try. If you need additional information, just let me know.

Peter

BDJCL 03-06-2013 08:39 AM

I believe you can do a clearpart --initlabel

PeterSteele 03-06-2013 09:12 AM

I would have thought so as well, but I resorted to the %pre script because that was the only method I found that avoided this "re-initialize" dialog...

PeterSteele 03-06-2013 09:23 AM

Oops, I pulled out the wrong %pre script. The script I use for my VM kickstart scripts looks like this:

%pre
echo "####################################"
echo "# Running pre configuration script #"
echo "####################################"
set -x
dd if=/dev/zero of=/dev/vda bs=1M count=1
parted -s /dev/vda mklabel gpt
parted -s /dev/vda mkpart primary ext4 0 128
mkfs.ext4 /dev/vda1
%end

I not only label the drive, but also create a partition on it. The main kickstart script then does this:

install
text
poweroff
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw root
firewall --disabled
selinux --disabled
timezone --utc America/Los_Angeles
bootloader --location=mbr --append="console=tty0 console=ttyS0,115200"
clearpart --all --initlabel
part /boot --size=128 --fstype ext4 --asprimary
part swap --recommended --fstype swap --asprimary
part / --size 500 --grow --fstype ext4 --asprimary

So, as you see, I do end up doing the clearpart command, but without the %pre script, the clearpart command causes this re-initialize dialog to occur, stalling the kickstart script. It's a hack, but it works, at least this was the only solution I could find to avoid this dialog.

hfreyer 04-22-2013 11:06 AM

In my usecase (kickstart network install of RHEL6.4
inside VM on a RHEL6.4 host system),
adding the option
Quote:

zerombr
before clearpart in the kickstart script solved the problem.

PeterSteele 04-22-2013 11:13 AM

I couldn't use this approach. We are booting from a USB stick and the zerombr command zeros all MBRs on all disks, including the USB stick that we booted from.

I came up with a solution using a %pre script to make sure the drives don't look "uninitialized" by the time the main kickstart script starts. A bit of a hack but it works for us.


All times are GMT -5. The time now is 02:17 PM.