Re: parted gpt on Fedora 16 breaks kickstarts and partition resizing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Old way with fdisk:

On 12/07/2011 05:12 PM, Phil Meyer wrote:
>
> #!/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}
>

Now because of parted required in Fedora 16, I had to actually learn and 
re-learn(expect) a few things and now this works:

#!/usr/bin/perl -w
#
use Expect;
use strict;

my $re1='(\\s+)';    # White Space 1
my $re2='(2)';    # Integer Number 1
my $re3='(\\s+)';    # White Space 2
my $re4='(\\d+)';    # Integer Number 2
my $re5='((?:[a-z][a-z]+))';    # Word 1

my $re=$re1.$re2.$re3.$re4.$re5;

my $start = "";
my $logfile = "/tmp/wowsers";
my $timeout = 2;

my $account_id = $ARGV[0] or die "Usage: growit.pl account_id\n";
my $drive = "/dev/mapper/${account_id}";
my $parted = new Expect;

system ("iscsiadm -m session -R\n");
system ("multipath -r\n");
system ("partprobe $drive\n");

$parted->spawn("parted $drive") or die "Cannot spawn parted: $!\n";
$parted->log_file($logfile);

$parted->expect($timeout,'(parted)') or die "No prompt from parted\n";
$parted->send("print\n");
$parted->expect(2,'(parted)') or $parted->send("Fix\n");
if ( $parted->before() =~ m/FIx/is )
     {
     $parted->send("Fix\n");
     $parted->expect($timeout,'(parted)') or die "Could nor FIX it\n";
     }
$parted->send("print\n");
if ( $parted->before() =~ m/$re/is )
     {
     $start=$4.$5;
     print "Start = $start\n";
     }
$parted->expect($timeout,'(parted)') or die "Where am I?\n";
$parted->send("rm 2\n");
$parted->expect($timeout,'(parted)') or die "Deleted??\n";
$parted->send("mkpart primary $start -1\n");
$parted->expect($timeout,'(parted)') or die "mkpart?\n";
$parted->send("quit\n");

system ("partprobe $drive\n");
system ("fsck -f -y ${drive}p2\n");
system ("/sbin/resize2fs -p ${drive}p2\n");
system ("fsck -f -y ${drive}p2\n");

Advice is still welcome!

Thanks
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux