LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to make thumbdrive bootable (https://www.linuxquestions.org/questions/linux-general-1/how-to-make-thumbdrive-bootable-4175617548/)

bilkay 11-13-2017 12:44 PM

How to make thumbdrive bootable
 
I've copied an upgraded system (ubuntu 16.04) to a thumbdrive and want to make it bootable. I mount the thumbdrive (/dev/sdc1) and chroot to it. I make necessary changes to /etc/fstab to mount the thumbdrive as /. I then run mkinitramfs to create a new initrd.img-{version}. The problem is trying to install grub in /dev/sdc. When I try, I get "grub-install: error: cannot find a device for /boot/grub (is /dev mounted?)." In a normal installation, the fstype of /dev is udev, but I don't know how to make that happen in these circumstances. Any help will be appreciated.

jefro 11-13-2017 03:08 PM

Most modern usb flash drives can be made bootable. Might take some steps. Can you see if syslinux will install?

Otherwise I'd remove internal hard drive and install Ubuntu from DVD to this usb and see if that works. A normal install. If it then boots correctly then maybe copy over your install.

Guess you could try reducing the original partition and use a clone program/distro.

Might try using grub command to install to the usb may assume you have the /sdb1 mounted maybe.

frankbell 11-13-2017 08:27 PM

Have you looked at unetbootin?

colorpurple21859 11-13-2017 09:02 PM

did you run the following before chroot?
Code:

mount --bind /dev /<sdc1 mountpoint>/dev
mount --bind /proc /<sdc1 mountpoint/proc
mount --bind /sys /<sdc1 mountpoint/sys


bilkay 11-14-2017 10:20 AM

Quote:

Originally Posted by colorpurple21859 (Post 5780404)
did you run the following before chroot?
Code:

mount --bind /dev /<sdc1 mountpoint>/dev
mount --bind /proc /<sdc1 mountpoint/proc
mount --bind /sys /<sdc1 mountpoint/sys


Thanks! I should have remembered that - and would have 50 years ago. Now I have good news and bad news:

The good news: The mounts did what I wanted.

The bad news: grub-install didn't work - gave me the following errors:
Code:

grub-install: warning: your embedding area is unusually small.  core.img won't fit in it..
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.

Would this be possible with a newer thumbdrive?

colorpurple21859 11-14-2017 10:36 AM

Is this an efi system, is the usb gpt or msdos layout, are you installing to sdc or sdc1?

bilkay 11-14-2017 11:04 AM

To answer my own question, judging by the reviews on a usb 3.0 flash drive at Best Buy, it is bootable.

colorpurple21859 11-14-2017 11:45 AM

Quote:

grub-install: warning: your embedding area is unusually small. core.img won't fit in it
Grub core.img is larger then the mbr boot loader space and grub uses the empty space between the mbr and the first partition for the core.img on a msdos disk installing grub-i386pc(legacy mode). A gpt disk doesn't have that empty space and have to create a small boot-bios partition for grub to install in legacy mode. Some partition tools don't leave enough space between the mbr and first partition to fit the core.img. Maybe try using syslinux or lilo as boot loader.

bilkay 11-14-2017 02:26 PM

Quote:

Originally Posted by colorpurple21859 (Post 5780592)
Is this an efi system,

Are you referring to the flash drive?
Quote:

Originally Posted by colorpurple21859 (Post 5780592)
is the usb gpt or msdos layout,

It came as vfat, reformatted as ext4.
Quote:

Originally Posted by colorpurple21859 (Post 5780592)
are you installing to sdc or sdc1?

/dev/sdc

bilkay 11-14-2017 03:15 PM

Quote:

Originally Posted by colorpurple21859 (Post 5780617)
Grub core.img is larger then the mbr boot loader space and grub uses the empty space between the mbr and the first partition for the core.img on a msdos disk installing grub-i386pc(legacy mode). A gpt disk doesn't have that empty space and have to create a small boot-bios partition for grub to install in legacy mode. Some partition tools don't leave enough space between the mbr and first partition to fit the core.img. Maybe try using syslinux or lilo as boot loader.

Lilo certainly brings back memories. I'll give it a shot.

bilkay 11-15-2017 11:56 AM

I couldn't apt-get lilo after chroot to /mnt so I installed it in the un-upgraded system and ran liloconfig. Following is the /etc/lilo.conf file with (most) changes I think I need. Not sure about the line "map = /boot/map". I'm guessing it might be "/mnt/boot/System.map-4.4.0-93-generic".


Code:

# /etc/lilo.conf  -  systemwide LILO configuration (LILO 23)
# details see in manpages: lilo(8) and lilo.conf(5)

# +-------------------------------------------------------------+
# |                        !! Reminder !!                      |
# |                                                            |
# | Don't forget to run 'lilo' after you make changes to this  |
# | conffile or you have installed a new kernel.                |
# +-------------------------------------------------------------+


# #################### LILO global section ######################

# With all newer systems (until year 2004) you can use the RAM
# above 15 MB. This option allows the use of this range of RAM.
#large-memory

# With all newer systems you can boot from any partition on disks
# with more than 1024 cylinders. This option allows the use of
# partitions above 1024 cylinders.

lba32

# Specifies the boot device.  This is where Lilo installs its boot
# block.  It can be either a partition, or the raw device, in which
# case it installs in the MBR, and will overwrite the current MBR.
# With newer kernel you should use the ID of the boot device, which
# can be found here: /dev/disks/by-id/ata*.
#boot = /dev/sdd

boot = /dev/disk/by-id/usb-SanDisk_Ultra_4C530001170919109453-0:0

# This option may be needed for some software RAID installs.
#raid-extra-boot = mbr-only

# Enable map compaction.  This tries to merge read requests for
# adjacent sectors into a single read request. This drastically
# reduces load time and keeps the map smaller.  Using 'compact'
# is especially recommended when booting from a floppy disk. 
# It is disabled here by default because it doesn't always work.
#compact

# Set the verbose level for bootloader installation. Value range:
# 0 to 5. Default value is 0.
#verbose = 1

# Specifies the location of the map file. Lilo creates the (sector)
# map file of direct sector addresses which are independent of any
# filesystem.

map = /boot/map

# ---------------------------------------------------------------

# Specifies the menu interface. You have the choice between:
#  text: simple text menu with black background and white text
#  menu: configurable text menu with background and text colors.
#  bmp:  graphical menu with 640x480 bitmap background.

install = menu

# A) Customized boot message for choice 'text'.
# For the simple text menu you can set an extra message in the
# created file. Its text will be displayed before boot prompt.
#message = /boot/message.txt

# B) Configuration of the scheme for choice 'menu'.
# Use following coding: <text>:<highlight>:<border>:<title>
# The first character of each part sets the text frontcolor,
# the second character of earch part sets the text backcolor,
# an upper-case character sets bold face text (frontcolor).
# i.g. 'menu-scheme=wm:rw:wm:Wm'. Possible colors:
# k=black, b=blue, g=green, c=cyan, r=red, m=magenta, y=yellow, w=white.

menu-scheme = Wb:Yr:Wb:Wb
#menu-title = " DESDEMONA Boot-Manager "

# C) Configuration of the image for choice 'bmp'.
# For the graphical menu you need a bitmap file, which needs a special
# menu configuration in the file header (see: lilo -E). Ideally you
# use one of the delivered images of the lilo package.
#  with 16 colors:    onlyblue, tuxlogo, inside
#  with 256 colors:  coffee
#  for Debian:        debianlilo, debian, debian-de
#bitmap = /boot/tuxlogo.bmp

# ---------------------------------------------------------------

# Specifies the number of deciseconds (0.1 seconds) how long LILO
# should wait before booting the first image.  LILO doesn't wait if
# 'delay' is omitted or set to zero. You do not see the defined menu.
#delay = 20

# Prompt to start one certain kernel from the displayed menu.
# It is very recommeded to also set 'timeout'. Without timeout boot
# will not take place unless you hit return. Timeout is the number
# of deciseconds (0.1 seconds) after there the default image will
# be started. With 'single-key' alias numbers for each menu line can
# be used.

prompt
timeout = 100
#single-key

# ---------------------------------------------------------------

# Specifying the VGA text mode that should be selected when booting.
# The following values are recognized (case is ignored):
#  vga=normal    80x25 text mode (default)
#  vga=extended  80x50 text mode (abbreviated to 'ext')
#  vga=ask      stop and ask for user input: choice of text mode
#  vga=<mode>    use the corresponding text mode number. A list of 
#                  available modes can be obtained by booting with 
#                  vga=ask'  and then pressing [Enter].
# Another way is the use of frame buffer mode. Then the kernel
# will switch from the normal vga text mode (80x25) to the frame
# buffer mode (if frame buffer support is in the kernel):
#  vga=0x314      800x600 @ 16 bit
#  vga=0x317    1024x768 @ 16 bit
#  vga=0x318    1024x768 @ 24 bit
#vga = ask

vga = normal
#vga = 0x317

# ---------------------------------------------------------------

# Kernel command line options that apply to all installed images go
# here.  See 'kernel-parameters.txt' in the Linux kernel 'Documentation'
# directory. I.g. for start into 'init 5' write:  append="5"
#append = ""
 
# If you used a serial console to install Debian, this option should be
# enabled by default.
#serial = 0,9600

# Set the image which should be started after delay or timeout.
# If not set, the first defined image will be started.
#default = Linux


# ################### LILO per-image section ####################

# Each image is configured with the linux kernel (=image) and
# usually with the initrd file. Configure all GNU/Linux systems
# on other partitions, too.


image = /mnt/boot/vmlinuz-4.4.0-93-generic
        label = "Linux"
        #root = /dev/sdd1
        root = "UUID=4822fb51-8757-4525-9cd4-0ff1e14582aa"
        read-only
#        restricted
#        alias = 1
#        optional

        initrd = /mnt/boot/initrd.img-4.4.0-93-generic


mrmazda 11-16-2017 12:43 AM

Shrike is over 14 years old! If the original installation was done with it, and the original partition "CHS" configuration remains, it explains lack of room for core.img, a combination of inadequate space in the legacy "boot track", and sdc1 starting immediately following the "boot track" instead of leaving 1MB of freespace to permit bootloader code to overflow the "boot track". If you start installation from scratch (wiping the stick first) with any modern distro, its partitioner will leave unpartitioned space following the "boot track" for core.img to use. Using GPT instead of MBR partitioning after wiping is an alternative.

To keep the old installation in place and functional, instead of sdc, you could try installing Grub to sdc1, and setting sdc1 active/bootable. Ignore Grub's complaint about unreliability of blocklists, as I do, in multibooting many PCs. All mine have Grub installed, but none have it installed to an MBR. Boot here is always initialized from a primary partition (no GPT disks here).

bilkay 11-17-2017 02:40 PM

Quote:

Originally Posted by mrmazda (Post 5781247)
Shrike is over 14 years old! If the original installation was done with it, and the original partition "CHS" configuration remains, it explains lack of room for core.img, a combination of inadequate space in the legacy "boot track", and sdc1 starting immediately following the "boot track" instead of leaving 1MB of freespace to permit bootloader code to overflow the "boot track". If you start installation from scratch (wiping the stick first) with any modern distro, its partitioner will leave unpartitioned space following the "boot track" for core.img to use. Using GPT instead of MBR partitioning after wiping is an alternative.

To keep the old installation in place and functional, instead of sdc, you could try installing Grub to sdc1, and setting sdc1 active/bootable. Ignore Grub's complaint about unreliability of blocklists, as I do, in multibooting many PCs. All mine have Grub installed, but none have it installed to an MBR. Boot here is always initialized from a primary partition (no GPT disks here).

Great! I ran fdisk to delete the first partition and then add a primary partition. I reformatted it and copied everything back to it and viola! I was able to install grub.

Thanks!


All times are GMT -5. The time now is 01:06 PM.