Support up to 256 SCSI disks on Linux
PATCH 1/1 Support up to 256 SCSI disks on Linux
Linux's Documentation/devices.txt file says that up to 256 SCSI disks are supported. GRUB currently only supports the first 16. Wikimedia filed an Ubuntu bug report about this
(https://bugs.launchpad.net/bugs/335174), so here's a patch to extend this. (I really haven't been able to test this much at all beyond compile-testing as I don't have a suitable system myself ...)
I suppose it might be nice to macroify the stuff in grub_util_getdiskname, but TBH I'm not sure it would shorten it all that much or make it much more readable, so I didn't bother.
Thanks,
Signature · 1 line
Colin Watson [[email protected]]
raid.c +41 -1
@@ -32,6 +32,16 @@#include <linux/raid/md_p.h> #include <linux/raid/md_u.h> +static void +grub_util_getdiskname_scsi (char *name,int scsi_major,int scsi_minor) +{ +int unit = scsi_major *16 + scsi_minor; +if (unit <26 ) +sprintf (name,"/dev/sd%c" ,'a' + unit); +else +sprintf (name,"/dev/sd%c%c" ,'a' + unit /26 -1 ,'a' + unit %26 ); +} +static char *grub_util_getdiskname (int major,int minor) {
@@ -48,7 +58,37 @@ grub_util_getdiskname (int major, int minor)else if (major ==IDE3_MAJOR )sprintf (name,"/dev/hd%c" ,'g' + minor /64 );else if (major ==SCSI_DISK0_MAJOR ) -sprintf (name,"/dev/sd%c" ,'a' + minor /16 ); +grub_util_getdiskname_scsi (name,0 , minor /16 ); +else if (major ==SCSI_DISK1_MAJOR ) +grub_util_getdiskname_scsi (name,1 , minor /16 ); +else if (major ==SCSI_DISK2_MAJOR ) +grub_util_getdiskname_scsi (name,2 , minor /16 ); +else if (major ==SCSI_DISK3_MAJOR ) +grub_util_getdiskname_scsi (name,3 , minor /16 ); +else if (major ==SCSI_DISK4_MAJOR ) +grub_util_getdiskname_scsi (name,4 , minor /16 ); +else if (major ==SCSI_DISK5_MAJOR ) +grub_util_getdiskname_scsi (name,5 , minor /16 ); +else if (major ==SCSI_DISK6_MAJOR ) +grub_util_getdiskname_scsi (name,6 , minor /16 ); +else if (major ==SCSI_DISK7_MAJOR ) +grub_util_getdiskname_scsi (name,7 , minor /16 ); +else if (major ==SCSI_DISK8_MAJOR ) +grub_util_getdiskname_scsi (name,8 , minor /16 ); +else if (major ==SCSI_DISK9_MAJOR ) +grub_util_getdiskname_scsi (name,9 , minor /16 ); +else if (major ==SCSI_DISK10_MAJOR ) +grub_util_getdiskname_scsi (name,10 , minor /16 ); +else if (major ==SCSI_DISK11_MAJOR ) +grub_util_getdiskname_scsi (name,11 , minor /16 ); +else if (major ==SCSI_DISK12_MAJOR ) +grub_util_getdiskname_scsi (name,12 , minor /16 ); +else if (major ==SCSI_DISK13_MAJOR ) +grub_util_getdiskname_scsi (name,13 , minor /16 ); +else if (major ==SCSI_DISK14_MAJOR ) +grub_util_getdiskname_scsi (name,14 , minor /16 ); +else if (major ==SCSI_DISK15_MAJOR ) +grub_util_getdiskname_scsi (name,15 , minor /16 );else grub_util_error ("Unknown device number: %d, %d" , major, minor);
grub-mkdevicemap.c +8 -1
@@ -231,7 +231,10 @@ get_scsi_disk_name (char *name, int unit) {#if defined(__linux__)/* GNU/Linux */ -sprintf (name,"/dev/sd%c" , unit +'a' ); +if (unit <26 ) +sprintf (name,"/dev/sd%c" , unit +'a' ); +else +sprintf (name,"/dev/sd%c%c" , unit /26 -1 +'a' , unit %26 +'a' );#elif defined(__GNU__)/* GNU/Hurd */ sprintf (name,"/dev/sd%d" , unit);
@@ -516,7 +519,11 @@ make_device_map (const char *device_map, int flopp#endif /* __linux__ */ /* The rest is SCSI disks. */ +#ifdef __linux__ +for (i =0 ; i <256 ; i++) +#else for (i = 0; i < 16; i++) +#endif /* __linux__ */ {char name[16 ];
hostdisk.c +6 -2
@@ -709,8 +709,12 @@ convert_system_partition_to_system_disk (const cha || strncmp ("sd", p, 2) == 0) && p[2] >= 'a' && p[2] <= 'z') { -/* /dev/[hsv]d[a-z][0-9]* */ - p[3 ] ='\0' ; +if (p[3 ] >='a' && p[3 ] <='z' ) +/* /dev/[hsv]d[a-z][a-z][0-9]* */ + p[4 ] ='\0' ; +else +/* /dev/[hsv]d[a-z][0-9]* */ + p[3 ] ='\0' ;return path; }
Quoted 10 lines · Colin Watson
Linux's
Documentation/devices.txtfile says that up to 256 SCSI disks are supported. GRUB currently only supports the first 16. Wikimedia filed an Ubuntu bug report about this
(https://bugs.launchpad.net/bugs/335174), so here's a patch to extend this. (I really haven't been able to test this much at all beyond compile-testing as I don't have a suitable system myself ...)I suppose it might be nice to macroify the stuff in
grub_util_getdiskname, but TBH I'm not sure it would shorten it all that much or make it much more readable, so I didn't bother.
Hi Colin,
I feel some dejavu. I think this is not the first max disk limit you find ;-)
raid.c grub_util_getdiskname (int major, int minor) · line 63
Quoted 6 lines
else if (major == SCSI_DISK0_MAJOR)raid.c +3
-1-sprintf (name,"/dev/sd%c" ,'a' + minor /16 ); +grub_util_getdiskname_scsi (name,0 , minor /16 ); + else if (major == SCSI_DISK1_MAJOR) + grub_util_getdiskname_scsi (name, 1, minor / 16);
Can this be factorized somehow? Space in raid.mod is quite critical; when used it usually ends up in core.img, which needs to fit in the embed area.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 9 lines · Robert Millan
raid.c grub_util_getdiskname (int major, int minor) · line 63
Quoted 6 lines
else if (major == SCSI_DISK0_MAJOR)raid.c +3
-1-sprintf (name,"/dev/sd%c" ,'a' + minor /16 ); +grub_util_getdiskname_scsi (name,0 , minor /16 ); + else if (major == SCSI_DISK1_MAJOR) + grub_util_getdiskname_scsi (name, 1, minor / 16);Can this be factorized somehow? Space in raid.mod is quite critical; when used it usually ends up in core.img, which needs to fit in the embed area.
Oh, I'm sorry. I thought you were editting disk/raid.c. util/raid.c has no size issues. A macro would still be nice though.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 7 lines · Robert Millan
Quoted 6 lines · Robert Millan
Quoted 6 lines
else if (major == SCSI_DISK0_MAJOR)raid.c +3
-1-sprintf (name,"/dev/sd%c" ,'a' + minor /16 ); +grub_util_getdiskname_scsi (name,0 , minor /16 ); + else if (major == SCSI_DISK1_MAJOR) + grub_util_getdiskname_scsi (name, 1, minor / 16);
Quoted 6 lines
Quoted 2 lines
Can this be factorized somehow? Space in raid.mod is quite critical; when used it usually ends up in core.img, which needs to fit in the embed area.
Oh, I'm sorry. I thought you were editting
disk/raid.c.util/raid.chas no size issues. A macro would still be nice though.
What about making an array of SCSI_DISK?_MAJOR and then just go through it?
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko
Quoted 8 lines · phcoder
Quoted 7 lines · Robert Millan
Quoted 6 lines · Robert Millan
Quoted 6 lines
else if (major == SCSI_DISK0_MAJOR)raid.c +3
-1-sprintf (name,"/dev/sd%c" ,'a' + minor /16 ); +grub_util_getdiskname_scsi (name,0 , minor /16 ); + else if (major == SCSI_DISK1_MAJOR) + grub_util_getdiskname_scsi (name, 1, minor / 16);
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Can this be factorized somehow? Space in raid.mod is quite critical; when used it usually ends up in core.img, which needs to fit in the embed area.
Oh, I'm sorry. I thought you were editting
disk/raid.c.util/raid.chas no size issues. A macro would still be nice though.What about making an array of SCSI_DISK?_MAJOR and then just go through it?
Sounds good.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."