1. This HOWTO is a result of the discussion on debian-user beginning at

   https://lists.debian.org/debian-user/2017/04/msg00329.html

2. Some machines which have internal card readers do not expose the
   devices in them to the BIOS. When GRUB uses the BIOS it too will be
   unaware of what is inserted in the card reader. Check this from the
   GRUB menu by getting a prompt with the C key and typing 'ls'. On my
   machine 'lsusb' gives

   TEAC Corp. All-In-One Multi-Card READER CA200/B/S

   and 'ls' shows two hard disk partitions only:

   (hd0) (hd0,msdos5) (hd0,msdos1)

   This is with a Compact Flash (CF) card inserted in the reader.

3  The only way of booting a Secure Digital (SD) or a Compact Flash
   card using GRUB is to use a kernel on (hd0,msdos5) or (hd0,msdos1).
   This is very fraught if the kernels on a card and a partition are
   different and, furthermore, cannot really be described as booting
   *from* the card.

4. A solution is to use GRUB's nativedisk command. At a prompt type
   'nativedisk' followed by 'ls'. I get

   (ata0) (ata0,msdos5) (ata0,msdos1) (usb0a) (usb0a,msdos1) (usb0b) (usb0c) 
(usb0d) (ata1)

   (usb0a,msdos1) is the CF card.

   nativedisk uses GRUB's USB drivers. These work directly with the
   hardware and effectively GRUB will sever connection with the BIOS'
   firmware drivers.

5. First install a Debian OS to an SD or CF card. The install includes 
   putting GRUB in the MBR of the card. It is a good idea to label the 
   filesystem; "CFDISK" was my choice.

6. My controlling GRUB is on (hd0,msdos1). It is the first entry in the
   GRUB menu which is displayed when the machine boots. The entry was 
   activated to boot into the OS on (hd0,msdos1). 
 
   Edit /etc/grub.d/40_custom to have

   menuentry 'Debian Stretch on CF card' {
        insmod part_msdos
        insmod ext2
        echo "Running nativedisk command. Please wait."
        nativedisk
        search --label --set=root CFDISK
        linux /vmlinuz root=LABEL=CFDISK ro
        initrd /initrd.img
   }

   and do 'update-grub' *without* any of the reader's slots being
   populated.

7. Reinsert a card and restart the machine to see the new entry in the
   GRUB menu and boot from it.

8. This method can also be used for an OS on a USB stick. Useful when
   a machine will not boot from USB.

9. A card or USB stick can be plugged in before the machine boots or
   when the GRUB menu appears.

--
Brian.

Reply via email to