home *** CD-ROM | disk | FTP | other *** search
- # Handles partitioning disks
-
- sub get_partitions {
- local ($type) = @_;
- local ($bsdtype, $parttype);
- local ($device, $start, $stop, $blocks, %partinfo, $lastbsddev);
-
- $type eq "swap" && ($bsdtype = "swap", $parttype = "Linux swap");
- $type eq "ext2" && ($bsdtype = "ext2", $parttype = "Linux native");
-
- open(SAVEERR, ">&STDERR");
- open(STDERR, ">/dev/null");
- open(PROC, "fdisk -l |") || die "Can't call fdisk!";
- while (<PROC>) {
- if (/^\/dev\/([a-z0-9]+) *([0-9]+) *[0-9]+ *([0-9]+) *([0-9]+).*$parttype/) {
- $device = "/dev/$1";
- $start = $2;
- $stop = $3;
- $blocks = $4;
- $partinfo{$device} = "$start $stop $blocks";
- } elsif (/^BSD label for device: *\/dev\/([a-z0-9]+)/) {
- $lastbsddev = $1;
- } elsif (/([a-z]): +([0-9]+) +([0-9]+) *$bsdtype/) {
- $device = ord($1) - ord("a") + 1;
- $device = "/dev/$lastbsddev$device";
- $start = $3;
- $blocks = $2;
- $stop = $start + $blocks;
- $partinfo{$device} = "$start $stop $blocks";
- }
- }
-
- close PROC;
- open(STDERR, ">&SAVEERR");
-
- return %partinfo;
- }
-
- sub partition_disks {
- local ( $ret );
-
- if (! &rhs_yesno ( "Disk Partitions",
- <<EOM
- You must have one or more free partitions for your
- Linux filesystem. In addition, you may want to create
- a swap partition. If you have already created partitions
- for your new Linux system you can skip this step.
- >
- Do you need to partition your disks?
- >
- EOM
- , 70)) {
- return 1;
- }
-
- if ($instarch eq "i386") {
- if (! &rhs_yesno ( "Disk Partitions",
- <<EOM
- >
- If you will be using OS/2 on your system in addition
- to Linux, you must use the OS/2 partitioning
- software. OS/2 will not recognize partitions created
- by the Linux partitioning software.
- >
- If you have not done this, choose the Reboot option,
- partition your drives with the OS/2 software, and
- restart the Red Hat installation.
- >
- Continue?
- >
- EOM
- , 70)) {
- return 0;
- }
- }
-
- if ($instarch eq "i386") {
- &rhs_msgbox ( "Disk Partitions",
- <<EOM
- >
- Each partition used for the Linux filesystem must be set as
- type 83. Each partition used for a Linux swap partition
- must be set as type 82.
- >
- EOM
- , 70);
- } else {
- &rhs_msgbox ( "Disk Partitions",
- <<EOM
- >
- There are two styles of disk partitioning available. The first
- is PC style partitioning, which is done with fdisk. If you are
- using the ARC firmware, you must use this.
-
- BSD style disk labeling is also available. You may manipulate
- disk labels with fdisk by typing 'b<Enter>' as the first command
- in fdisk. Another program, minlabel, also allows you to use
- disk labels.
- >
- EOM
- , 70);
- }
-
- &_partition_disks;
- }
-
- sub _partition_disks {
- local ( $ret, $snarf, $disklist, $diskinfolist, $msg, $ent );
- local ( @choices );
-
- $ret = &rhs_infobox ( "Disk Partitioning",
- <<EOM
- >
- Discovering what hard drives are attached to the system...
- >
- EOM
- , 70);
-
- @disklist = ();
- @diskinfolist = ();
- open(SAVEERR, ">&STDERR");
- open(STDERR, ">/dev/null");
- open(PROC, "fdisk -l |") || &newdie("Can't call fdisk!");
- while (<PROC>) {
- if (/^Disk (.*):(.*)$/) {
- $disklist[@disklist] = $1;
- $diskinfolist[@diskinfolist] = "$1:$2";
- } elsif (/^BSD label for device: *\/dev\/([a-z0-9]+)/) {
- $disklist[@disklist] = "/dev/$1";
- $diskinfolist[@diskinfolist] = "/dev/$1:hard disk";
- }
- }
- close PROC;
- open(STDERR, ">&SAVEERR");
-
- $msg =
- <<EOM
- The following disks were found:
- >
- EOM
- ;
- foreach $ent (@diskinfolist) {
- $msg .= ">" . $ent . "\n";
- }
-
- if ($instarch eq "i386") {
- @choices = ("fdisk", "Partition a disk with fdisk (command line)",
- "cfdisk", "Partition a disk with cfdisk (full screen)");
- } else {
- @choices = ("fdisk", "Partition a disk with fdisk",
- "minlabel", "Partition a disk with minlabel");
- }
-
- while (1) {
- if (! &rhs_menu("Disk Partitioning", $msg,
- 70, (($#choices + 1) / 2) + 1,
- @choices,
- "done", "Done with partitioning")) {
- last;
- }
- last if ($dialog_result eq "done");
- &partition_disk ("fdisk", @disklist) if ($dialog_result eq "fdisk");
- &partition_disk ("cfdisk", @disklist) if ($dialog_result eq "cfdisk");
- &partition_disk ("minlabel", @disklist) if ($dialog_result eq "minlabel");
- }
-
- &rhs_menu("Disk Partitioning",
- <<EOM
- >
- If fdisk (or cfdisk) complained about not being able
- to reload the partition tables or you are using disk
- labeling, you should reinstall now.
- >
- After rebooting skip the partitioning step and continue
- with the rest of the installation.
- >
- EOM
- , 70, 2,
- "Reboot", "Reboot now",
- "Continue", "Continue the install process");
-
- exit(0) if ($dialog_result eq "Reboot");
-
- return 1;
- }
-
- sub partition_disk {
- local ( $fdisk, @disklist ) = @_;
- local ( $ret );
-
- if (! &rhs_menul ( "Disk Partitioning",
- <<EOM
- >
- Which disk do you want to partition?
- >
- EOM
- , 50, scalar(@disklist), @disklist)) {
- return 1;
- }
-
- &invoke("$fdisk $dialog_result");
-
- print "\nHit enter to continue";
- <STDIN>;
- }
-
- ############
- 1;
-