Skip to contentSkip to conversation

Allow palo partition to be mounted as ext2

parisc-linux James Bottomley 3 participants 4 messages Nov 8, 2003 – Nov 9, 2003

lore
Share & tools
lore
#0 lore raw

It can be a bit of a pain having both a palo partition and a /boot partition on the root disc (and both < 2GB), so this patch allows the palo partition to be mounted as an ordinary ext2/ext3 filesystem (ideally as /boot).

It does this by creating an ext2/3 filesystem in the palo partition but leaving a hole for the iplboot program (by telling the filesystem the blocks are bad). The kernels can be booted from this filesystem by specifying 0/ as the partition as usual.

Attached is a preliminary patch for you to see what you think.

Ultimately, it should mean we can get palo to operate much more like grub (using a palo.conf file within the palo partition itself for instance).

The diffs are against the palo cvs tree.

James

Index: ipl/ipl.c
===================================================================
RCS file: /var/cvs/palo/ipl/ipl.c,v
retrieving revision 1.32

ipl.c +16 -4
diff -u -r1.32 ipl.c
@@ -252,7 +252,7 @@
     int blocked_bootdev;
     int bootdev;
     int wide;
-    int kern_part, rd_part, i;
+    int kern_part, rd_part, i, ext2 = 0, f0;
     char kern_name[128], rd_name[128];
     char kern_fullname[128];
 
@@ -294,6 +294,11 @@
     printf("\n%s contains:\n",
 	partitioned ? "PALO(F0) partition" : "Boot image");
 
+    if(partitioned && f.version >= 4 && (f.flags & PFLAG_EXT2)) {
+	printf("PALO is formatted EXT2/3\n");
+	ext2 = 1;
+    }
+
     if (f.version < 3 && f.kern32_sz > 0)
     {
 	printf("    0/vmlinux %d bytes @ 0x%x\n", f.kern32_sz, f.kern32_offset);
@@ -392,16 +397,23 @@
     {
 	if (partition[i].id == 0xf0)
 	{
-	    if (kern_part == i + 1)
+	    f0 = i + 1;
+	    if (kern_part == f0)
 		kern_part = 0;
 
-	    if (rd_part == i + 1)
+	    if (rd_part == f0)
 		rd_part = 0;
 
 	    break;
 	}
     }
 
+    if (ext2 && kern_part == 0) {
+	kern_part = f0;
+	if(rd_part == 0)
+	    rd_part = f0;
+    }
+
     if (kern_part > 0 && !partitioned)
     {
 	printf("ERROR: Requesting kernel from partition %d "
@@ -507,7 +519,7 @@
 	struct diskpartition *pp;
 
 	if (kern_part >= MAXPARTS || 
-	    (partition[kern_part - 1].id != 0x83 && partition[kern_part - 1].id != 0xfd) )
+	    (partition[kern_part - 1].id != 0x83 && partition[kern_part - 1].id != 0xfd && partition[kern_part - 1].id != 0xf0) )
 	{
 	    printf("ERROR: Partition %d must be ext2\n", kern_part);
 	    while(1);

Index: lib/common.h
===================================================================
RCS file: /var/cvs/palo/lib/common.h,v
retrieving revision 1.24

common.h +3 -2
diff -u -r1.24 common.h
@@ -11,7 +11,7 @@
 #include <asm/byteorder.h>
 #include <linux/genhd.h>
 
-#define PALOVERSION "1.2"
+#define PALOVERSION "1.3"
 
 /* size of I/O block used in HP firmware */
 #define FW_BLOCKSIZE	2048
@@ -28,9 +28,10 @@
  * kern_sz = 0 or rd_sz = 0 means no kern or ramdisk respectively.
  */
 #define PALOMAGIC "PALO"
-#define PALOHDRVERSION 3
+#define PALOHDRVERSION 4
 
 #define PFLAG_INSTALL 0x1
+#define PFLAG_EXT2    0x2
 
 struct firstblock
 {

Index: palo/error.c
===================================================================
RCS file: /var/cvs/palo/palo/error.c,v
retrieving revision 1.6

error.c +7 -0
diff -u -r1.6 error.c
@@ -83,6 +83,13 @@
 	/* 17 */
 	"Too many of the same type of kernel.  %s is either the second\n"
 	"32-bit kernel or the second 64-bit one.\n",
+
+	/* 18 */
+	"For formatted palo partitions, you cannot specify a kernel\n"
+	"or a ramdisk.\n",
+
+	/* 19 */
+	"mke2fs failed."
 };
 
 #define NMESSAGES (sizeof errormessages / sizeof errormessages[0])

Index: palo/palo.c
===================================================================
RCS file: /var/cvs/palo/palo/palo.c,v
retrieving revision 1.16

palo.c +137 -12

230 lines not on this page · raw message

Index: palo/usage.txt
===================================================================
RCS file: /var/cvs/palo/palo/usage.txt,v
retrieving revision 1.3

usage.txt +9 -0
diff -u -r1.3 usage.txt
@@ -46,6 +46,15 @@
 		When -f is not specified, palo tries /etc/palo.conf.  Use
 		--configfile=/dev/null to avoid configuration files or
 		warnings when /etc/palo.conf is missing.
+    -v, --verbose
+		Provide more verbose information when running palo
+    -e, --format-as=type
+		This is only for partitioned media:  Format the palo
+		partition as an ext2 (type == 2) or ext3 (type == 3)
+		partition.  With this option, you cannot specify
+		any parameters, kernels or ramdisks to be loaded into
+		the palo partition
+		
 
 'palo' with no arguments whatsoever is equivalent to 'palo -f /etc/palo.conf'.
 
#1 lore raw
Quoted 4 lines · James Bottomley

It can be a bit of a pain having both a palo partition and a /boot partition on the root disc (and both < 2GB), so this patch allows the palo partition to be mounted as an ordinary ext2/ext3 filesystem (ideally as /boot).

Well, not if you have read the FAQ ;)
But I agree, I recently assisted someone (via IRC) reinstalling his 712, because he forgot to create a F0 partition, but he created a /boot in the first 2GB.

Quoted 4 lines

It does this by creating an ext2/3 filesystem in the palo partition but leaving a hole for the iplboot program (by telling the filesystem the blocks are bad). The kernels can be booted from this filesystem by specifying 0/ as the partition as usual.

I don't know much ext2/3 details, but is there a way that a fsck could mess things up? Eg. not an ordinary fsck, but if the user runs it manually with special options?

I suppose the same technique could be also used for other filesystems palo supports (in the future).

Quoted 5 lines

Attached is a preliminary patch for you to see what you think.

Ultimately, it should mean we can get palo to operate much more like grub (using a palo.conf file within the palo partition itself for instance).

That would be a logical consequence.

Very nice!

Keep up the good work,
Max

#2 lore raw
Quoted 3 lines · M. Grabert

I don't know much ext2/3 details, but is there a way that a fsck could mess things up? Eg. not an ordinary fsck, but if the user runs it manually with special options?

Not fsck, no. The bad blocks are treated as though they belonged to an invisible file. redoing the mke2fs, of course, would destroy the bootability.

Quoted 2 lines

I suppose the same technique could be also used for other filesystems palo supports (in the future).

As long as they have bad block support, yes---that's not a given; reiserfs doesn't seem to have it, for instance.

Also, since the command has to be run by palo and palo has to know how to format the bad block list, it's not trivial to do.

However, the ultimate argument is because palo's iplboot loader only knows about ext2/3, even if you could format the partition as anything else, you currently wouldn't be able to boot from it.

James

#3 lore raw
In reply to James Bottomley
Quoted 10 lines · James Bottomley

It can be a bit of a pain having both a palo partition and a /boot partition on the root disc (and both < 2GB), so this patch allows the palo partition to be mounted as an ordinary ext2/ext3 filesystem (ideally as /boot).

It does this by creating an ext2/3 filesystem in the palo partition but leaving a hole for the iplboot program (by telling the filesystem the blocks are bad). The kernels can be booted from this filesystem by specifying 0/ as the partition as usual.

Quoted 7 lines

Attached is a preliminary patch for you to see what you think.

Ultimately, it should mean we can get palo to operate much more like grub (using a palo.conf file within the palo partition itself for instance).

The diffs are against the palo cvs tree.

Great work James! I like the addition of verbose to the command line. This definately gets us a step closer to behaving or perhaps integrating palo into grub. The only suggestion I have is that someone should remember to update palo's debian/ files to reflect the fact that you rely on 'e2fsprogs' for mke2fs. The computer scientist in me wants to distinguish between failure cases when mke2fs exists and returns an error code versus it doesn't exist on the $PATH (e.g. check if mke2fs runs without params fist "/sbin/mke2fs -V").

c.