-- ** Derek J Witt ** * Email: mailto:djw@flinthills.com * * Home Page: http://www.flinthills.com/~djw/ * *** "...and on the eighth day, God met Bill Gates." - Unknown **
--- Begin Message ---
- To: Derek James Witt <djw@flinthills.com>
- Subject: lilo-xfs patch
- From: Derek James Witt <djw@flinthills.com>
- Date: 25 Mar 2002 15:26:32 -0600
- In-reply-to: <1017080744.2172.6.camel@saiya-jin.flinthills.com>
- References: <20020324075637.4021C5C268@mail.blaze.homeip.net> <1016971074.7957.2.camel@mdew> <1017080744.2172.6.camel@saiya-jin.flinthills.com>
Hey, everyone. I just hacked up a quick patch for lilo to behave correctly with XFS. This just checks the file system type of the current root partition. If XFS is detected, lilo aborts with an error. I also included a -F parameter to force XFS to install on XFS partitions. Let me know how this looks. On Mon, 2002-03-25 at 12:25, Derek James Witt wrote: > Hi, there. I got the same behavior. I found LILO does overwrite the XFS > superblock. Evidently, XFS's superblock even includes the boot sector. > So, could lilo be modified not to run on a XFS root partition? I can > try to modify lilo to include a XFS-detection routine and abort if XFS > is detected on root. I could also put in a parameter to override this > (if anyone would be bold enough to overwrite the SB). > On Sun, 2002-03-24 at 05:57, mdew wrote: > > Yeah I've checkout the CVS, and indeed its br0k3n... same Problem. > > > > Debian Sid+Preemptive+GCC 3.0.4 > > > > Once repairing the drive, its bootable again. > > > > > > On Sun, 2002-03-24 at 19:56, Paul Blazejowski wrote: > > > Hi Eric, > > > > > > I have a bug i think...i was able to reproduce the sb corruption after > > > compiling new kernel. > > > > > > Updated my xfs tree with todays CVS (no changes) then i generated a diff > > > against clean 2.4.18 kernel patched with xfs and jfs patches,did make dep > > > then make bzImage followed by make modules...all of these steps went fine. > > > I rerun /sbin/lilo to update the loader and made a quick boot disk using: > > > dd if=/dev/sda2 of=/dev/fd0 ibs=1440 count=1 (sda2 is the partition with xfs). > > > Again there was no crashes or forced shutdowns...rebooted the box and when > > > new kernel booted it showed these errors: > > > > > > XFS: bad magic number > > > XFS: SB validate failed > > > VFS: unable to mount block device on (8,2) or something close. > > > > > > Again this is on Slackware Linux 8.0 with kernel 2.4.18 and gcc 2.95.3. > > > > > > This is what xfs_repair shows: > > > > > > xfs_repair -n /dev/sda2 > > > Phase 1 - find and verify superblock... > > > bad primary superblock - bad magic number !!! > > > > > > attempting to find secondary superblock... > > > ...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................! > > ..! > > > ....................found > > > candidate secondary superblock... > > > verified secondary superblock... > > > would write modified primary superblock > > > primary superblock would have been modified. > > > cannot proceed further in no_modify mode. > > > exiting now. > > > > > > I did not make any changes to the fs yet...how would i pull the first few kb > > > off of the fs you mentioned earlier? Thanks again for your help. > > > > > > Regards, > > > > > > Paul > > > > > -- > > ph33r! > > Linux mdew 2.4.18-xfs-preemptive #4 Sun Mar 24 21:44:59 NZST 2002 i686 > > unknown > > > -- > ** Derek J Witt ** > * Email: mailto:djw@flinthills.com * > * Home Page: http://www.flinthills.com/~djw/ * > *** "...and on the eighth day, God met Bill Gates." - Unknown ** -- ** Derek J Witt ** * Email: mailto:djw@flinthills.com * * Home Page: http://www.flinthills.com/~djw/ * *** "...and on the eighth day, God met Bill Gates." - Unknown **--- lilo-22.2/lilo.c Sun Dec 30 16:10:26 2001 +++ lilo-xfs.c Mon Mar 25 15:17:53 2002 @@ -755,16 +755,49 @@ fprintf(errstd,"%7s%s -A /dev/XXX [ N ]\t\tactivate a partition\n","",name); fprintf(errstd,"%7s%s -M /dev/XXX [ mbr_file ]\tinstall master boot record\n","",name); fprintf(errstd,"%7s%s -T help \t\t\tlist additional options\n", "", name); + fprintf(errstd,"%7s%s -F \t\t\t\tforce install on XFS partition\n\t\t\t\t\tWARNING: This will corrupt\n\t\t\t\t\tthe superblock on XFS partitions.\n\n", "", name); fprintf(errstd,"%7s%s -V [ -v ]\t\t\tversion information\n\n","",name); exit(1); } +int is_xfs(char* device) +{ + FILE* mounts; + + if ((mounts = fopen("/etc/mtab", "r")) == NULL) + { /* Just some insurance. If this does not exists, there's something + seriously wrong here. How are you even in Linux in the first place? + */ + fprintf(errstd, "ERROR: I cannot find /etc/mtab! Nothing done.\n"); + exit(-1); + } + else + { + while (! feof(mounts)) + { + char mount_line[255],*fs_type,*mount_device,*mount_point; + fgets(mount_line, 255, mounts); + if (strlen(mount_line) == 0) break; + mount_device = strtok(mount_line, " "); + mount_point = strtok(NULL, " "); + fs_type = strtok(NULL, " "); + if (fs_type == NULL) break; + if ((strcmp(fs_type, "xfs") == 0) && (strcmp(mount_device,device) == 0)) + return 1; + } + fclose(mounts); + } + return 0; +} + int main(int argc,char **argv) { char *name,*reboot_arg,*identify,*ident_opt,*new_root; char *tell_param, *uninst_dev, *param, *act1, *act2, ch; int query,more,version,uninstall,validate,activate,instmbr,geom; + int force_xfs; + char *boot_device = NULL; struct stat st; int fd; long raid_offset; @@ -775,6 +808,7 @@ reboot_arg = identify = ident_opt = new_root = uninst_dev = NULL; lowest = do_md_install = zflag = query = version = uninstall = validate = activate = instmbr = 0; + force_xfs = 0; verbose = -1; name = *argv; argc--; @@ -806,6 +840,9 @@ break; case 'b': cfg_set(cf_options,"boot",param,NULL); + boot_device = (char*)malloc((sizeof (char)) * 255); + strcpy(boot_device,param); + // if (is_xfs(boot_device) == 1) die("root (%s) is XFS. Aborted.",boot_device); break; case 'c': cfg_set(cf_options,"compact",NULL,NULL); @@ -823,6 +860,11 @@ case 'f': cfg_set(cf_options,"disktab",param,NULL); break; + case 'F': + if (!nowarn) + fprintf(errstd,"WARNING: Forcing install on XFS partitions...\nBe prepared to run xfs_repair\non any XFS root partitions\nthat LILO selects as boot.\n"); + force_xfs = 1; + break; case 'g': geometric |= 1; break; @@ -1104,6 +1146,13 @@ if (verbose >=2 && do_md_install) printf("raid flags: at bsect_open 0x%02X\n", raid_flags); + if (boot_device == NULL) + { + boot_device = (char*)malloc((sizeof (char)) * 255); + strcpy(boot_device,cfg_get_strg(cf_options,"boot")); + } + if ((is_xfs(boot_device) == 1) && (force_xfs == 0)) die("root (%s) is XFS. Aborted.",boot_device); + bsect_open(cfg_get_strg(cf_options,"boot"),cfg_get_strg(cf_options,"map") ? cfg_get_strg(cf_options,"map") : MAP_FILE,cfg_get_strg(cf_options, "install"),cfg_get_strg(cf_options,"delay") ? to_number(cfg_get_strg(Attachment: signature.asc
--- End Message ---
Description: This is a digitally signed message part
Attachment:
signature.asc
Description: This is a digitally signed message part