Jordan Share wrote:
I would like to use this partitioning scheme (I think :):
'fdisk /pri:30,100;fdisk /pri:30,100;fdisk /pri:300 /spec:131;fdisk /ext:100,100;fdisk /log:6000 /spec:131;fdisk /log:2000 /spec:130;fdisk /log:100,100 /spec:131',
The idea is that it will create:
* 2 partitions for use with windows, each 30% of the disk size
* 300meg (perhaps excessive) partition which I will use for a linux /boot partition.
* extended partition for the rest of the disk
* 6 gig partition within the extended partition (linux /)
* 2 gig swap partition
* rest of disk into "extra" partition
But, the install.pl doesn't seem to care for the 130 and 131 partition types. :) I think it would be possible to just translate them to "linux-swap" and "ext2" respectively (as it does for translating 7 to "ntfs").
I am attempting to bend install.pl to my will, but my perl is perhaps not as mighty as it should be.
Ok, I hacked together a solution for this. It lets me use the above partitioning commands, and works with the multiboot setup that I use.
On this 80gig disk that I'm using, after I install FC2 into the end, its parted says:
Disk geometry for /dev/hda: 0.000-76319.085 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 22889.487 primary ntfs hidden
2 22889.487 45786.818 primary ntfs boot
3 45794.663 46092.744 primary ext3
4 46092.744 76316.594 extended lba
5 46092.775 52093.586 logical ext3
6 52093.617 54093.867 logical linux-swap
7 54093.898 76316.594 logical ext3
And sfdisk says: Disk /dev/hda: 9729 cylinders, 255 heads, 63 sectors/track Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/hda1 0+ 2917 2918- 23438803+ 17 Hidden HPFS/NTFS
/dev/hda2 * 2918 5836 2919 23446867+ 7 HPFS/NTFS
start: (c,h,s) expected (1023,254,63) found (1023,0,1)
/dev/hda3 5838 5875 38 305235 83 Linux
/dev/hda4 5876 9728 3853 30949222+ f W95 Ext'd (LBA)
/dev/hda5 5876+ 6640 765- 6144831 83 Linux
/dev/hda6 6641+ 6895 255- 2048256 82 Linux swap
/dev/hda7 6896+ 9728 2833- 22756041 83 LinuxI am attaching the patch from CVS for install.pl. It's pretty klugey. For logical partitions I just cut-n-pasted find_free_space to find_free_space_ext, and made it 1) skip extended partitions when it scans them all, and 2) use the end of the extended partition, instead of the end of the disk.
I also added support for /spec:130 and /spec:131, but 131 is just specified as ext2 (which does give the partition the proper type). As you can see above, after the partitions have a file system, the FC2 parted sees them as type ext3.
How come Unattended uses parted instead of sfdisk, anyway? Parted seems kind of weak. You can't set arbitrary partition types, at least. And sfdisk lets you use nice round integers for partitioning down to the sector level.
Jordan
Index: install.pl
===================================================================
RCS file: /cvsroot/unattended/unattended/install/dosbin/install.pl,v
retrieving revision 1.136
diff -r1.136 install.pl
540a541,602
> # Find the largest interval of free space in ext partition which does not
> # overlap other partitions. Return as a pair (START, END) where each
> # is in megabytes from start of disk.
> sub find_free_space_ext () {
> $is_linux
> or croak 'internal error';
>
> my @partitions;
>
> # Read the current partition table.
> my $cmd = 'parted -s /dev/dsk print';
> open PARTED, "$cmd|"
> or die "Unable to fork: $^E";
>
> my $extstart;
> my $extend;
> while (my $line = <PARTED>) {
> my ($start, $end) = ($line =~ /^\d+\s+(\d+\.\d{3})\s+(\d+\.\d{3})/);
> defined $end
> or next;
> if ( $line =~ /^\d+\s+(\d+\.\d{3})\s+(\d+\.\d{3})\s+extended/ ) {
> ( $extstart, $extend ) = ($line =~
> /^\d+\s+(\d+\.\d{3})\s+(\d+\.\d{3})\s+extended/);
> next;
> }
> push @partitions, [ $start, $end ];
> }
>
> defined $extend
> or die "No end of extended partition found, cannot find free space for logical
> partition.\n";
>
> close PARTED
> or die "'$cmd' failed: $^E $?";
>
> # Keep track of best result so far.
> my ($best_start, $best_end) = (0, 0);
>
> # Now loop through looking for free space.
> LOOP:
> foreach my $part ([0, 0], @partitions) {
> # Try fitting new partition in just after this one.
> my $start = $part->[1];
> my $end = $extend;
> foreach my $other (@partitions, [ $extend, $extend ]) {
> # Each other partition may or may not constrain us.
> my ($other_start, $other_end) = @$other;
> if ($start >= $other_end) {
> # Partition ends before we start, so no worries.
> }
> elsif ($end > $other_start) {
> # We must end before the other partition starts.
> $end = $other_start;
> }
> }
>
> # Keep track of the best we have found.
> $end - $start > $best_end - $best_start
> and ($best_start, $best_end) = ($start, $end);
> }
>
> return ($best_start, $best_end);
> }
>
566,567c628,631
< elsif ($cmd =~ /\/pri(o)?:(\d+)(,100)?(?:\s+\/spec:(\d+))?/i) {
< my ($fat16, $size, $is_percent, $type) = ($1, $2, $3, $4);
---
> elsif ($cmd =~ /\/(log|ext|pri)(o)?:(\d+)(,100)?(?:\s+\/spec:(\d+))?/i) {
> my ($ptype, $fat16, $size, $is_percent, $type) = ($1, $2, $3, $4, $5);
>
> my ($start, $end) = find_free_space ();
569c633,635
< my ($start, $end) = find_free_space ();
---
> if ( $ptype eq "log" ) {
> ($start, $end) = find_free_space_ext ();
> }
591,593c657,660
< $type == 7
< or croak "Sorry, only type 7 (NTFS) is allowed ($fdisk_cmd)";
< $fs = 'ntfs';
---
> if ( $type == 7 ) { $fs = 'ntfs'; }
> elsif ( $type == 130 ) { $fs= 'linux-swap' }
> elsif ( $type == 131 ) { $fs= 'ext2' }
> else { croak "Sorry, unsupported filesystem type ($fdisk_cmd)"; }
596c663,668
< $ret = "$parted mkpart primary $fs $start $end";
---
> my $parttype = '';
> if ( $ptype eq "pri" ) { $parttype = 'primary' }
> elsif ( $ptype eq "log" ) { $parttype = 'logical' }
> elsif ( $ptype eq "ext" ) { $parttype = 'extended'; $fs='' }
>
> $ret = "$parted mkpart $parttype $fs $start $end";
