[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#498568: Debian cannot be installed on bootable SD cards



On Thu, Sep 11, 2008 at 02:15:11PM +0200, Frans Pop wrote:
> > The actual distribution installation program needs to
> > 1. recognize /dev/mmcblk* as block devices that can be used as
> >    target device
> 
> This is the main issue. As Debian Installer uses libparted for 
> partitioning the real question is whether or not libparted supports these 
> devices. If that is true then very minor adjustments in partman should 
> suffice to support partitioning them.

As I wrote in my last mail, the usual 'generic' block device handling
in libparted works fine with SD/MMC devices.  However, the enumerator
to find and enumerate over all block devices on a Linux system did not 
yet find the device.

I have now implemented this as a trivial patch (see below) and also sent the
patch to upstream git for inclusion.

Using the patch, parted shows:

> Model: SD/MMC Storage Card (sd/mmc)
> Disk /dev/mmcblk0: 2013MB
> Sector size (logical/physical): 512B/512B
> Partition Table: msdos
> 
> Number  Start  End     Size    Type     File system  Flags
>  1      131kB  2013MB  2013MB  primary  fat16             

-------------

commit f08cf81fad42a6c9c8bca83dc91a0fe1cdf9081a
Author: Harald Welte <laforge@gnumonks.org>
Date:   Wed Sep 17 08:44:54 2008 +0800

    Ad SD/MMC Storage Card support on Linux
    
    This patch adds a new SDMMC device type to represent SD/MMC
    cards.  There is nothing special about handling those devices,
    they are just standard block devices with different names.
    
    They use device major ID 179 and are usually called
    /dev/mmcblkN (where N is the card number) and the individual partitions
    /dev/mmcblkNpM (where M is the partition number).
    
    This patch was developed as part of an effort to make debian-installer
    support installation of Debian GNU/Linux on SD/MMC cards, as boot-from-SD
    is becoming a feature seen in mobile x86 devices.

:100644 100644 e955e6f... 568e019... M	AUTHORS
:100644 100644 fdfcb1f... 2a3421f... M	include/parted/device.h
:100644 100644 333f818... 983f232... M	libparted/arch/linux.c
:100644 100644 5e67584... d7c0292... M	parted/parted.c

diff --git a/AUTHORS b/AUTHORS
index e955e6f..568e019 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -231,3 +231,6 @@ Debarshi Ray            <rishi@gnu.org>
         * Introduce 'print devices' and alias 'print list' to 'print all'.
         * Alias 'mktable' to 'mklabel'.
         * Code and API clean-up, bug fixes, and other miscellaneous stuff.
+
+Harald Welte            <laforge@gnumonks.org>
+        * SD/MMC Storage card support on Linux
diff --git a/include/parted/device.h b/include/parted/device.h
index fdfcb1f..2a3421f 100644
--- a/include/parted/device.h
+++ b/include/parted/device.h
@@ -44,7 +44,8 @@ typedef enum {
         PED_DEVICE_VIODASD      = 10,
         PED_DEVICE_SX8          = 11,
         PED_DEVICE_DM           = 12,
-        PED_DEVICE_XVD          = 13
+        PED_DEVICE_XVD          = 13,
+        PED_DEVICE_SDMMC        = 14
 } PedDeviceType;
 
 typedef struct _PedDevice PedDevice;
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 333f818..983f232 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -255,6 +255,7 @@ struct blkdev_ioctl_param {
 #define SX8_MAJOR1              160
 #define SX8_MAJOR2              161
 #define XVD_MAJOR               202
+#define SDMMC_MAJOR             179
 
 #define SCSI_BLK_MAJOR(M) (                                             \
                 (M) == SCSI_DISK0_MAJOR                                 \
@@ -537,6 +538,8 @@ _device_probe_type (PedDevice* dev)
 #endif
         } else if (dev_major == XVD_MAJOR && (dev_minor % 0x10 == 0)) {
                 dev->type = PED_DEVICE_XVD;
+        } else if (dev_major == SDMMC_MAJOR && (dev_minor % 0x08 == 0)) {
+                dev->type = PED_DEVICE_SDMMC;
         } else {
                 dev->type = PED_DEVICE_UNKNOWN;
         }
@@ -1259,6 +1262,11 @@ linux_new (const char* path)
                         goto error_free_arch_specific;
                 break;
 
+        case PED_DEVICE_SDMMC:
+                if (!init_generic (dev, _("SD/MMC Storage Card")))
+                        goto error_free_arch_specific;
+                break;
+
         default:
                 ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
                                 PED_EXCEPTION_CANCEL,
diff --git a/parted/parted.c b/parted/parted.c
index 5e67584..d7c0292 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1268,10 +1268,10 @@ do_print (PedDevice** dev)
         int             has_free_arg = 0;
         int             has_list_arg = 0;
         int             has_num_arg = 0;
-        const char *const transport[14] = {"unknown", "scsi", "ide", "dac960",
+        const char *const transport[15] = {"unknown", "scsi", "ide", "dac960",
 					   "cpqarray", "file", "ataraid", "i2o",
 					   "ubd", "dasd", "viodasd", "sx8", "dm",
-					   "xvd"};
+					   "xvd", "sd/mmc"};
         char*           peek_word;
         char*           start;
         char*           end;


-- 
- Harald Welte <HaraldWelte@viatech.com>	    http://linux.via.com.tw/
============================================================================
VIA Open Source Liaison



Reply to: