parted gpt on Fedora 16 breaks kickstarts and partition resizing
Phil Meyer
pmeyer at themeyerfarm.com
Thu Dec 8 00:12:03 UTC 2011
Confession: I am old; had been working as a UNIX/Solaris admin for
many years when Linus first posted on Usenet in 1991. I remember
smirking ...
And now its been all Linux work for over 8 years. Times change.
Part of my specialty has always been automated installs, automated
software distribution, and systems tools automation. When installing 2
or more systems, the first becomes the auto installer for the others.
Recently we have automated 'cloud' server installs of RHEL, Centos,
Fedora, and Ubuntu. My son also threw Windows 2k8r2 in there, but ...
We use a %pre section in kickstart to determine the appropriate first
disk, regardless of driver type.
Like this:
%include /tmp/partitions
%pre
awk 'BEGIN {disk=""} /a$/ {if (disk == "") disk=$4} END {printf "part
/boot --size=320 --ondisk=%s\npart / --fstype ext4 --size 1 --grow
--asprimary --ondisk=%s\n", disk, disk}' /proc/partitions > /tmp/partitions
%end
Elegant and simple. FYI we are doing file based swap now days -- much
simpler to manage and no performance issues. Example later:
In order to facilitate parted in anaconda instead of fdisk, we had to:
%include /tmp/partitions
%pre
awk 'BEGIN {disk=""} /a$/ {if (disk == "") disk=$4} END {printf "part
biosboot --fstype=biosboot --size=1 --asprimary --ondisk=%s\npart /
--fstype=ext4 --size=1 --grow --asprimary --ondisk=%s\n", disk, disk}'
/proc/partitions > /tmp/partitions
%end
We really hate so many exceptions to the rules, but ok so far, really.
The error message was a complete surprise and no help, even from
google. We finally had to study the latest kickstart manual to see the
note about biosboot and the clue about using gpt partitions with parted
by default now. But if you want to automate adding space to an iscsi
device, for example, that might attached to this Fc16 box, as in a VM,
it gets nasty.
Here is how it can be done with fdisk from the server running the VM
with an iscsi disk. Grow the size of the iscsi drive beforehand using
whatever tool is provided for that storage. 10GB growth in this
sample. The server will not see your change until you reboot or do
something like this:
#!/bin/bash
set -x
account_id=$1
if [ -z "$account_id" ]
then
exit -1
fi
virsh shutdown a${account_id}
sleep 60
virsh destroy a${account_id}
iscsiadm -m session -R
multipath -r
partprobe /dev/mapper/${account_id}
fsck -f -y /dev/mapper/${account_id}p1
fsck -f -y /dev/mapper/${account_id}p2
fdisk /dev/mapper/${account_id} <<_EOF
d
2
n
p
2
w
_EOF
partprobe /dev/mapper/${account_id}
fsck -f -y /dev/mapper/${account_id}p2
/sbin/resize2fs -p /dev/mapper/${account_id}p2
fsck -f -y /dev/mapper/${account_id}p2
virsh start a${account_id}
Here is the real deal breaker for us: There is no possible way to do
this type of automation with parted. When parted sees that the gpt
label is not at the physical end of the drive, it goes into interactive
mode! And even though its been in RedHat bugs for years, it is still
broken.
"Error: The backup GPT table is not at the end of the disk, as it should be.
This might mean that another operating system believes the disk is smaller.
Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel?
Warning: Not all of the space available to /dev/mapper/952774 appears to be
used, you can fix the GPT to use all of the space (an extra 20981760
blocks) or
continue with the current setting?
Fix/Ignore?"
We may be forced to drop Fedora from our server offerings as a result.
Yes, there are lots of developers who want FC16 in the cloud to test
stuff before it hits RHEL and Centos.
Please show me that my memory and research skills are lacking. It won't
be the first time! Take a shot. After all, I am a parted newb.
As promised, if you made it this far, here is the %post section we now
use to add swap:
# set up swap
dd if=/dev/zero of=/.SWAP_FILE bs=1M count=2048
echo "/.SWAP_FILE swap swap defaults 0 0" >> /etc/fstab
mkswap -L SWAP_FILE /.SWAP_FILE
Thanks!
More information about the users
mailing list