LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions
User Name
Password
Linux - Distributions This forum is for Distribution specific questions.
Red Hat, Slackware, Debian, Novell, LFS, Mandriva, Ubuntu, Fedora - the list goes on and on... Note: An (*) indicates there is no official participation from that distribution here at LQ.

Notices


Reply
  Search this Thread
Old 08-19-2016, 04:35 AM   #1
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 268
Blog Entries: 2

Rep: Reputation: 49
DOS access for System Rescue CD USB-drive


I'd like to make a system rescue bootable USB-stick for my brother. The distribution named "System Rescue CD" seems good. There's just one caveat. He has been having trouble with the BIOS and would need to run a DOS program to flash it to fix it.
Does anyone know how/where to place files that are accessible by the DOS alternatives on that disk? The internet does not seem to know. The DOS substitutes provided on the disk are: DOSEmu and FreeDOS. Would anyone know whether those are fit to run a BIOS flash utility?
The internet does not seem to provide quick answers to those questions. Here is the file hierarchy of the System Rescue CD's .iso file:
Code:
/mnt/
├── boot
│** └── grub
│**     ├── efi.img
│**     ├── font.pf2
│**     ├── grub-480.cfg
│**     └── x86_64-efi
│**         ├── acpi.mod
│**         ├── adler32.mod
│**         ├── affs.mod
│**         ├── afs.mod
│**         ├── ahci.mod
│**         ├── all_video.mod
│**         ├── aout.mod
│**         ├── appleldr.mod
│**         ├── archelp.mod
│**         ├── ata.mod
│**         ├── at_keyboard.mod
│**         ├── backtrace.mod
│**         ├── bfs.mod
│**         ├── bitmap.mod
│**         ├── bitmap_scale.mod
│**         ├── blocklist.mod
│**         ├── boot.mod
│**         ├── bsd.mod
│**         ├── btrfs.mod
│**         ├── bufio.mod
│**         ├── cat.mod
│**         ├── cbfs.mod
│**         ├── cbls.mod
│**         ├── cbmemc.mod
│**         ├── cbtable.mod
│**         ├── cbtime.mod
│**         ├── chain.mod
│**         ├── cmdline_cat_test.mod
│**         ├── cmp.mod
│**         ├── command.lst
│**         ├── configfile.mod
│**         ├── cpio_be.mod
│**         ├── cpio.mod
│**         ├── cpuid.mod
│**         ├── crc64.mod
│**         ├── cryptodisk.mod
│**         ├── crypto.lst
│**         ├── crypto.mod
│**         ├── cs5536.mod
│**         ├── datehook.mod
│**         ├── date.mod
│**         ├── datetime.mod
│**         ├── diskfilter.mod
│**         ├── disk.mod
│**         ├── div_test.mod
│**         ├── dm_nv.mod
│**         ├── echo.mod
│**         ├── efifwsetup.mod
│**         ├── efi_gop.mod
│**         ├── efinet.mod
│**         ├── efi_uga.mod
│**         ├── ehci.mod
│**         ├── elf.mod
│**         ├── eval.mod
│**         ├── exfat.mod
│**         ├── exfctest.mod
│**         ├── ext2.mod
│**         ├── extcmd.mod
│**         ├── fat.mod
│**         ├── file.mod
│**         ├── fixvideo.mod
│**         ├── font.mod
│**         ├── fshelp.mod
│**         ├── fs.lst
│**         ├── functional_test.mod
│**         ├── gcry_arcfour.mod
│**         ├── gcry_blowfish.mod
│**         ├── gcry_camellia.mod
│**         ├── gcry_cast5.mod
│**         ├── gcry_crc.mod
│**         ├── gcry_des.mod
│**         ├── gcry_dsa.mod
│**         ├── gcry_idea.mod
│**         ├── gcry_md4.mod
│**         ├── gcry_md5.mod
│**         ├── gcry_rfc2268.mod
│**         ├── gcry_rijndael.mod
│**         ├── gcry_rmd160.mod
│**         ├── gcry_rsa.mod
│**         ├── gcry_seed.mod
│**         ├── gcry_serpent.mod
│**         ├── gcry_sha1.mod
│**         ├── gcry_sha256.mod
│**         ├── gcry_sha512.mod
│**         ├── gcry_tiger.mod
│**         ├── gcry_twofish.mod
│**         ├── gcry_whirlpool.mod
│**         ├── geli.mod
│**         ├── gettext.mod
│**         ├── gfxmenu.mod
│**         ├── gfxterm_background.mod
│**         ├── gfxterm_menu.mod
│**         ├── gfxterm.mod
│**         ├── gptsync.mod
│**         ├── gzio.mod
│**         ├── halt.mod
│**         ├── hashsum.mod
│**         ├── hdparm.mod
│**         ├── hello.mod
│**         ├── help.mod
│**         ├── hexdump.mod
│**         ├── hfs.mod
│**         ├── hfspluscomp.mod
│**         ├── hfsplus.mod
│**         ├── http.mod
│**         ├── iorw.mod
│**         ├── iso9660.mod
│**         ├── jfs.mod
│**         ├── jpeg.mod
│**         ├── keylayouts.mod
│**         ├── keystatus.mod
│**         ├── ldm.mod
│**         ├── legacycfg.mod
│**         ├── legacy_password_test.mod
│**         ├── linux16.mod
│**         ├── linux.mod
│**         ├── loadbios.mod
│**         ├── loadenv.mod
│**         ├── loopback.mod
│**         ├── lsacpi.mod
│**         ├── lsefimmap.mod
│**         ├── lsefi.mod
│**         ├── lsefisystab.mod
│**         ├── lsmmap.mod
│**         ├── ls.mod
│**         ├── lspci.mod
│**         ├── lssal.mod
│**         ├── luks.mod
│**         ├── lvm.mod
│**         ├── lzopio.mod
│**         ├── macbless.mod
│**         ├── macho.mod
│**         ├── mdraid09_be.mod
│**         ├── mdraid09.mod
│**         ├── mdraid1x.mod
│**         ├── memdisk.mod
│**         ├── memrw.mod
│**         ├── minicmd.mod
│**         ├── minix2_be.mod
│**         ├── minix2.mod
│**         ├── minix3_be.mod
│**         ├── minix3.mod
│**         ├── minix_be.mod
│**         ├── minix.mod
│**         ├── mmap.mod
│**         ├── moddep.lst
│**         ├── morse.mod
│**         ├── mpi.mod
│**         ├── msdospart.mod
│**         ├── multiboot2.mod
│**         ├── multiboot.mod
│**         ├── nativedisk.mod
│**         ├── net.mod
│**         ├── newc.mod
│**         ├── nilfs2.mod
│**         ├── normal.mod
│**         ├── ntfscomp.mod
│**         ├── ntfs.mod
│**         ├── odc.mod
│**         ├── offsetio.mod
│**         ├── ohci.mod
│**         ├── part_acorn.mod
│**         ├── part_amiga.mod
│**         ├── part_apple.mod
│**         ├── part_bsd.mod
│**         ├── part_dfly.mod
│**         ├── part_dvh.mod
│**         ├── part_gpt.mod
│**         ├── partmap.lst
│**         ├── part_msdos.mod
│**         ├── part_plan.mod
│**         ├── part_sun.mod
│**         ├── part_sunpc.mod
│**         ├── parttool.lst
│**         ├── parttool.mod
│**         ├── password.mod
│**         ├── password_pbkdf2.mod
│**         ├── pata.mod
│**         ├── pbkdf2.mod
│**         ├── pbkdf2_test.mod
│**         ├── pcidump.mod
│**         ├── play.mod
│**         ├── png.mod
│**         ├── priority_queue.mod
│**         ├── probe.mod
│**         ├── procfs.mod
│**         ├── progress.mod
│**         ├── raid5rec.mod
│**         ├── raid6rec.mod
│**         ├── read.mod
│**         ├── reboot.mod
│**         ├── regexp.mod
│**         ├── reiserfs.mod
│**         ├── relocator.mod
│**         ├── romfs.mod
│**         ├── scsi.mod
│**         ├── search_fs_file.mod
│**         ├── search_fs_uuid.mod
│**         ├── search_label.mod
│**         ├── search.mod
│**         ├── serial.mod
│**         ├── setjmp.mod
│**         ├── setjmp_test.mod
│**         ├── setpci.mod
│**         ├── sfs.mod
│**         ├── signature_test.mod
│**         ├── sleep.mod
│**         ├── sleep_test.mod
│**         ├── spkmodem.mod
│**         ├── squash4.mod
│**         ├── syslinuxcfg.mod
│**         ├── tar.mod
│**         ├── terminal.lst
│**         ├── terminal.mod
│**         ├── terminfo.mod
│**         ├── test_blockarg.mod
│**         ├── testload.mod
│**         ├── test.mod
│**         ├── testspeed.mod
│**         ├── tftp.mod
│**         ├── tga.mod
│**         ├── time.mod
│**         ├── trig.mod
│**         ├── tr.mod
│**         ├── true.mod
│**         ├── udf.mod
│**         ├── ufs1_be.mod
│**         ├── ufs1.mod
│**         ├── ufs2.mod
│**         ├── uhci.mod
│**         ├── usb_keyboard.mod
│**         ├── usb.mod
│**         ├── usbms.mod
│**         ├── usbserial_common.mod
│**         ├── usbserial_ftdi.mod
│**         ├── usbserial_pl2303.mod
│**         ├── usbserial_usbdebug.mod
│**         ├── usbtest.mod
│**         ├── verify.mod
│**         ├── video_bochs.mod
│**         ├── video_cirrus.mod
│**         ├── video_colors.mod
│**         ├── video_fb.mod
│**         ├── videoinfo.mod
│**         ├── video.lst
│**         ├── video.mod
│**         ├── videotest_checksum.mod
│**         ├── videotest.mod
│**         ├── xfs.mod
│**         ├── xnu.mod
│**         ├── xnu_uuid.mod
│**         ├── xnu_uuid_test.mod
│**         ├── xzio.mod
│**         ├── zfscrypt.mod
│**         ├── zfsinfo.mod
│**         └── zfs.mod
├── bootdisk
│** ├── aida.img
│** ├── dban.bzi
│** ├── freedos.img
│** ├── gag.img
│** ├── grubdisk.img
│** ├── hdt.img
│** ├── memtestp
│** └── mhdd.img
├── bootprog
│** ├── grub4dos-0.4.4.zip
│** └── syslinux-4.06.zip
├── efi
│** └── boot
│**     └── bootx64.efi
├── isolinux
│** ├── altker32
│** ├── altker64
│** ├── boot.cat
│** ├── chain.c32
│** ├── f1boot.msg
│** ├── f2images.msg
│** ├── f3params.msg
│** ├── f4arun.msg
│** ├── f5troubl.msg
│** ├── f6pxe.msg
│** ├── f7net.msg
│** ├── ifcpu64.c32
│** ├── initram.igz
│** ├── isolinux.bin
│** ├── isolinux.cfg
│** ├── isolinux.old
│** ├── kbdmap.c32
│** ├── maps
│** │** ├── azerty.ktl
│** │** ├── be.ktl
│** │** ├── bg.ktl
│** │** ├── by.ktl
│** │** ├── cf.ktl
│** │** ├── croat.ktl
│** │** ├── cz.ktl
│** │** ├── de.ktl
│** │** ├── dk.ktl
│** │** ├── dvorak.ktl
│** │** ├── es.ktl
│** │** ├── et.ktl
│** │** ├── fi.ktl
│** │** ├── fr_CH.ktl
│** │** ├── fr.ktl
│** │** ├── genlist.sh
│** │** ├── gr.ktl
│** │** ├── hu.ktl
│** │** ├── il.ktl
│** │** ├── it.ktl
│** │** ├── lt.ktl
│** │** ├── mk.ktl
│** │** ├── nl.ktl
│** │** ├── no.ktl
│** │** ├── pl.ktl
│** │** ├── ru.ktl
│** │** ├── sg.ktl
│** │** ├── slovene.ktl
│** │** ├── trf.ktl
│** │** ├── trq.ktl
│** │** ├── ua.ktl
│** │** ├── uk.ktl
│** │** ├── us.ktl
│** │** └── wangbe.ktl
│** ├── memdisk
│** ├── menu.c32
│** ├── netboot
│** ├── pxelinux.0
│** ├── reboot.c32
│** ├── rescue32
│** ├── rescue64
│** └── vesamenu.c32
├── ntpasswd
│** ├── initrd.cgz
│** ├── scsi.cgz
│** └── vmlinuz
├── readme.txt
├── sysrcd.dat
├── sysrcd.md5
├── usb_inst
│** ├── dialog
│** ├── install-mbr
│** ├── mkfs.vfat
│** ├── mtools
│** ├── parted
│** ├── syslinux
│** ├── syslinux.exe
│** └── xorriso
├── usb_inst.sh
├── usbstick.htm
└── version
Here is the script (contained in the ISO) to make a bootable USB-drive:
Code:
#!/bin/bash
# Project page: http://www.system-rescue-cd.org/
# (C) 2010 Francois Dupoux
# This scipt is available under the GPL-2 license

###############################################################################

logfile="/var/tmp/usb_inst.log"
TMPDIR="/var/tmp/usb_inst.tmp"
MINSIZEMB=512
PROGIMG="${0}"
PROGLOC="$(dirname ${0})"
CDFILES=('sysrcd.dat' 'sysrcd.md5' 'version' '???linux/initram.igz' 
	'???linux/rescue32' '???linux/rescue64' '???linux/f1boot.msg'
	'???linux/???linux.bin' '???linux/???linux.cfg')

###############################################################################

usage()
{
	cat <<EOF
${PROGIMG}: SystemRescueCd installation script for USB-sticks
Syntax: ${PROGIMG} <command> ...

Please, read the manual for help about how to use this script.
http://www.system-rescue-cd.org/Online-Manual-EN

You can either run all sub-commands in the appropriate order, or you
can just use the semi-graphical menu which requires less effort:

A) Semi-graphical installation (easy to use):
   Just run "${PROGIMG} dialog" and select the USB device

B) Sub-commands for manual installation (execute in that order):
   1) listdev               Show the list of removable media
   2) writembr <devname>    Recreate the MBR + partition table on the stick
   3) format <partname>     Format the USB-stick device (overwrites its data)
   4) copyfiles <partname>  Copy all the files from the cdrom to the USB-stick
   5) syslinux <partname>   Make the device bootable

C) Extra sub-commands:
   -h|--help	            Display these instructions

Distributed under the GNU Public License version 2 - http://www.system-rescue-cd.org
EOF
}

###############################################################################

help_readman()
{
	echo "$1"
	echo "Please, read the manual for more help about this script"
	echo "Web: http://www.system-rescue-cd.org"
	exit 1
}

cleanup_tmpdir()
{
	if [ -d "${TMPDIR}" ]
	then
		rm -rf ${TMPDIR}/{parted,install-mbr,mkfs.vfat,syslinux,syslinux.exe,dialog,mtools,mcopy,mattrib,mmove,xorriso}
		rmdir ${TMPDIR}
	fi
}

die()
{
	if [ -n "$1" ]
	then
		echo "$(basename ${PROGIMG}): error: $1"
	else
		echo "$(basename ${PROGIMG}): aborting."
	fi
	cleanup_tmpdir
	exit 1
}

###############################################################################

# check that there is one partition and one only on block-device $1
find_first_partition()
{
	devname="$1"
	if [ -z "${devname}" ] || [ ! -d "/sys/block/$(basename ${devname})" ]
	then
		die "${devname} is not a valid device name (1)"
	fi
	
	partcnt=0
	firstpart=0
	for i in $(seq 1 4)
	do
		partname="${devname}${i}"
		if [ -b "${partname}" ]
		then
			[ "${firstpart}" = '0' ] && firstpart="$i"
			partcnt=$((partcnt+1))
		fi
	done
	
	if [ "${partcnt}" = '1' ]
	then
		return ${partcnt}
	else
		return 0
	fi
}

# check $1 is a valid partition name
check_valid_partname()
{
	if [ -z "${partname}" ]
	then
		die "you have to provide a valid partition device-name as argument of this command"
	fi

	if [ -z "${partname}" ] || [ ! -b "${partname}" ]
	then
		die "${partname} is not a valid partition name"
	fi
	
	if ! echo "${partname}" | grep -qE '^/dev/[a-z]*[1-4]+$'
	then
		die "device [${partname}] is not a valid partition. Expect something like [/dev/sdf1]"
	fi

	if is_dev_mounted "${partname}"
	then
		die "${partname} is already mounted, cannot continue"
	fi
	
	return 0
}

# check $1 is a valid block device name
check_valid_blkdevname()
{
	if [ -z "${devname}" ]
	then
		die "you have to provide a valid device name as argument of this command"
	fi
	
	if [ ! -b "${devname}" ] || [ ! -d "/sys/block/$(basename ${devname})" ]
	then
		die "${devname} is not a valid device name (2)"
	fi
	
	if is_dev_mounted "${devname}"
	then
		die "${devname} is already mounted, cannot continue"
	fi
	
	return 0
}

check_sysresccd_files()
{
    rootdir="$1"
    [ -z "${rootdir}" ] && die "invalid rootdir"
	for curfile in ${CDFILES[*]}
	do
		curcheck="${rootdir}/${curfile}"
		if ! ls ${curcheck} >/dev/null 2>&1
		then
			die "Cannot find ${curcheck}, cannot continue"
		fi
	done
	return 0
}

# returns 0 if the device is big enough
check_sizeof_dev()
{
	devname="$1"

	if [ -z "${devname}" ]
	then
		die "check_sizeof_dev(): devname is empty"
	fi

	if [ -z "$(which blockdev)" ]
	then
		echo "blockdev not found, assuming the size is ok"
		return 0
	fi
	
	secsizeofdev="$(blockdev --getsz ${devname})"
	mbsizeofdev="$((secsizeofdev/2048))"
	if [ "${mbsizeofdev}" -lt "${MINSIZEMB}" ]
	then
		die "The device [${devname}] is only ${mbsizeofdev} MB. It is too small to copy all the files, an USB-stick of at least ${MINSIZEMB}MB is recommended"
	else
		echo "The device [${devname}] seems to be big enough: ${mbsizeofdev} MB."
		return 0
	fi
}

# say how much freespace there is on a mounted device
check_disk_freespace()
{
	freespace=$(\df -m -P ${1} | grep " ${1}$" | tail -n 1 | awk '{print $4}')
	sysrcdspc=$(\du -csm ${1}/{sysrcd.dat,bootdisk,bootprog,isolinux,ntpasswd,usb_inst} 2>/dev/null | awk 'END{print $1}')
	realfreespace=$((freespace+sysrcdspc))
	echo "DEBUG: diskspace($1): freespace=${freespace}, sysrcdspc=${sysrcdspc}, realfreespace=${realfreespace}"
	echo "Free space on ${1} is ${realfreespace}MB"
	if [ "${realfreespace}" -lt "${MINSIZEMB}" ]
	then
		die "There is not enough free space on the USB-stick to copy the SystemRescuecd files."
	fi
	return 0
}

# check that device $1 is an USB-stick
is_dev_usb_stick()
{
	curdev="$1"
	
	remfile="/sys/block/${curdev}/removable"
	vendor="$(cat /sys/block/${curdev}/device/vendor 2>/dev/null)"
	model="$(cat /sys/block/${curdev}/device/model 2>/dev/null)"
	if [ -f "${remfile}" ] && cat ${remfile} 2>/dev/null | grep -qF '1' \
		&& cat /sys/block/${curdev}/device/uevent 2>/dev/null | grep -qF 'DRIVER=sd'
	then
		return 0
	else
		return 1
	fi
}

do_writembr()
{
	devname="$1"
	shortname="$(echo ${devname} | sed -e 's!/dev/!!g')"
	
	check_valid_blkdevname "${devname}"
	if ! is_dev_usb_stick "${shortname}"
	then
		die "Device [${devname}] does not seem to be an usb-stick. Cannot continue."
	fi
	
	check_sizeof_dev "${devname}"
	
	if [ ! -x "${PROG_INSTMBR}" ] || [ ! -x "${PROG_PARTED}" ]
	then
		die "install-mbr and parted must be installed, check these programs first."
	fi
	
	cmd="${PROG_INSTMBR} ${devname} --force"
	echo "--> ${cmd}"
	if ! ${cmd}
	then
		die "${cmd} --> failed"
	fi
	
	cmd="${PROG_PARTED} -s ${devname} mklabel msdos"
	echo "--> ${cmd}"
	if ! ${cmd} 2>/dev/null
	then
		die "${cmd} --> failed"
	fi
	
	cmd="${PROG_PARTED} -s ${devname} mkpart primary fat32 0 100%"
	echo "--> ${cmd}"
	if ! ${cmd} 2>/dev/null
	then
		die "${cmd} --> failed"
	fi
	
	cmd="${PROG_PARTED} -s ${devname} set 1 boot on"
	echo "--> ${cmd}"
	if ! ${cmd} 2>/dev/null
	then
		die "${cmd} --> failed"
	fi
}

do_format()
{
	partname="$1"
	check_valid_partname "${partname}"

	check_sizeof_dev "${partname}"

	if [ ! -x "${PROG_MKVFATFS}" ]
	then
		die "mkfs.vfat not found on your system, please install dosfstools first."
	fi
	
	if ${PROG_MKVFATFS} -F 32 -n SYSRESC ${partname}
	then
		echo "Partition ${partname} has been successfully formatted"
		return 0
	else
		echo "Partition ${partname} cannot be formatted"
		return 1
	fi
}

do_copyfiles()
{
	partname="$1"
	check_valid_partname "${partname}"
	
	# check the important files are available in ${LOCATION}
	check_sysresccd_files "${LOCATION}"
	
	check_sizeof_dev "${partname}"
	
	mkdir -p /mnt/usbstick 2>/dev/null
	if ! mount -t vfat ${partname} /mnt/usbstick
	then
		die "cannot mount ${partname} on /mnt/usbstick"
	fi
	echo "${partname} successfully mounted on /mnt/usbstick"
	
	check_disk_freespace "/mnt/usbstick"
	
	echo "cp -v -r --remove-destination ${LOCATION}/* /mnt/usbstick/"	
	if cp -v -r --remove-destination ${LOCATION}/* /mnt/usbstick/ && sync
	then
		echo "Files have been successfully copied to ${partname}"
	else
		echo "Cannot copy files to ${partname}"
	fi
	
	if ! ls -l /mnt/usbstick/???linux/???linux.cfg >/dev/null 2>&1
	then
		umount /mnt/usbstick
		die "isolinux/syslinux configuration file not found, cannot continue"
	fi
	
	# check the important files have been copied
	check_sysresccd_files "/mnt/usbstick"
	
	# move isolinux files to syslinux files
	if [ -f /mnt/usbstick/isolinux/isolinux.cfg ]
	then
		[ -d /mnt/usbstick/syslinux ] && rm -rf /mnt/usbstick/syslinux
		if ! mv /mnt/usbstick/isolinux/isolinux.cfg /mnt/usbstick/isolinux/syslinux.cfg \
			|| ! mv /mnt/usbstick/isolinux /mnt/usbstick/syslinux
		then
			umount /mnt/usbstick
			die "cannot move isolinux to syslinux, failed"
		fi
		sed -i -e 's!/isolinux/!/syslinux/!g' /mnt/usbstick/boot/grub/grub*.cfg
	fi
	
	# add scandelay option which allows the usb devices to be detected
	sed -i -e 's!scandelay=.!scandelay=5!g' /mnt/usbstick/syslinux/syslinux.cfg
	
	umount /mnt/usbstick
}

do_syslinux()
{
	partname="$1"
	check_valid_partname "${partname}"
	
	if [ ! -x "${PROG_SYSLINUX}" ]
	then
		die "syslinux not found on your system, please install syslinux first."
	fi
	
	${PROG_SYSLINUX} --install --directory syslinux ${partname}
	res=$?
	sync
	if [ ${res} -eq 0 ]
	then
		echo "syslinux has successfully prepared ${partname}"
	else
		echo "syslinux failed to prepare ${partname}"
	fi
	return ${res}
}

is_dev_mounted()
{
	curdev="$1"
	
	if cat /proc/mounts | grep -q "^${curdev}"
	then
		return 0
	else
		return 1
	fi
}

do_dialog()
{
    if [ ! -x ${PROG_DIALOG} ]
    then
        die "Program dialog not found, cannot run the semi-graphical installation program"
    fi
	devsallcnt=0
	devsmntcnt=0
	devsokcnt=0
	for curpath in /sys/block/*
	do
		curdev="$(basename ${curpath})"
		devname="/dev/${curdev}"
		if is_dev_usb_stick ${curdev}
		then
			if [ -n "$(which blockdev)" ]
			then
				secsizeofdev="$(blockdev --getsz /dev/${curdev})"
				mbsizeofdev="$((secsizeofdev/2048))"
				sizemsg=" and size=${mbsizeofdev}MB"
			fi
			echo "Device [${devname}] detected as [${vendor} ${model}] is removable${sizemsg}"
			if is_dev_mounted "${devname}"
			then
				echo "* Device [${devname}] is mounted: cannot use it"
				devsmnttxt="${devsmnttxt} * Device [${devname}] is mounted: cannot use it"
				devsmntcnt=$((devsmntcnt+1))
				devsallcnt=$((devsallcnt+1))
			else
				echo "* Device [${devname}] is not mounted"
				devsoktxt="${devsoktxt} \"${devname}\" \"[${vendor} ${model}] ${sizemsg}\" off"
				devsokcnt=$((devsokcnt+1))
				devsallcnt=$((devsallcnt+1))
			fi
		fi
	done
	if [ ${devsallcnt} -eq 0 ]
	then
		echo "No valid USB/Removable device has been detected on your system"
		return 1	
	fi
	if [ ${devsokcnt} -eq 0 ]
	then
		echo "All valid USB/Removable devices are currently mounted, unmount these devices first"
		return 1
	fi

	if [ ${devsmntcnt} -gt 0 ]
        then
		message="${message}The following USB/Removable devices cannot be used:\n"
		message="${message}${devsmnttxt}\n\n"
	fi
	message="${message}Select the USB/Removable devices where you want to install it.\n"
	message="${message}Files on these devices will be lost if you continue.\n"

	lwselection="/tmp/usb_inst_$$.tmp"
	[ ! -d /tmp ] && mkdir -p /tmp
	[ -f ${lwselection} ] && rm -f ${lwselection}
	selection='${PROG_DIALOG} --backtitle "Select USB/Removable device" --checklist "${message}" 20 70 5'
	eval "${selection} ${devsoktxt}" 2>$lwselection
	if [ -s $lwselection ]
	then
		status=""
		output=""
		echo "" > ${logfile}
		for devname2 in $(cat $lwselection | tr -d \" | sort)
		do
			echo "Installation on ${devname2} at $(date +%Y-%m-%d_%H:%M)" >> ${logfile}
			status="${status}Installation on ${devname2} in progress\n\n"
			status="${status}details will be written in ${logfile}\n"
			dialog_status "${status}"
			status="${status}* Writing MBR on ${devname2}\n"
			dialog_status "${status}"
			do_writembr ${devname2} >> ${logfile} 2>&1
			[ $? -ne 0 ] && dialog_die "Failed to write the MBR on ${devname2}"
			sleep 1
			output="$(find_first_partition ${devname2})\n"
			devname2="${devname2}$?"
			dialog_status "${status}"
			sleep 5
			status="${status}* Creating filesystem on ${devname2}...\n"
			dialog_status "${status}"
			do_format ${devname2} >> ${logfile} 2>&1
			[ $? -ne 0 ] && dialog_die "Failed to create the filesystem on ${devname2}"
			status="${status}* Copying files (please wait)...\n"
			dialog_status "${status}"
			do_copyfiles ${devname2} >> ${logfile} 2>&1
			[ $? -ne 0 ] && dialog_die "Failed to copy files on ${devname2}"
			status="${status}* Installing the boot loader on ${devname2}...\n"
			dialog_status "${status}"
			do_syslinux ${devname2} >> ${logfile} 2>&1
			[ $? -ne 0 ] && dialog_die "Failed to install the boot loader ${devname2}"
			status="${status}* Installation on ${devname2} successfully completed\n"
			dialog_status "${status}"
			sleep 5
		done
		${PROG_DIALOG} --title "Success" --msgbox "Installation successfully completed" 10 50
	fi
	rm -f $lwselection
}

dialog_status()
{
	${PROG_DIALOG} --infobox "$1" 20 75
}

dialog_die()
{
	readlog="Read the logfile (${logfile}) for more details"
	${PROG_DIALOG} --title "Error" --msgbox "$1\n${readlog}" 20 70
	cleanup_tmpdir
	exit 1
}

do_listdev()
{
	devcnt=0
	for curpath in /sys/block/*
	do
		curdev="$(basename ${curpath})"
		devname="/dev/${curdev}"
		if is_dev_usb_stick ${curdev}
		then
			if [ -n "$(which blockdev)" ]
			then
				secsizeofdev="$(blockdev --getsz /dev/${curdev})"
				mbsizeofdev="$((secsizeofdev/2048))"
				sizemsg=" and size=${mbsizeofdev}MB"
			fi	
			echo "Device [${devname}] detected as [${vendor} ${model}] is removable${sizemsg}"
			if is_dev_mounted "${devname}"
			then
				echo "Device [${devname}] is mounted"
			else
				echo "Device [${devname}] is not mounted"
			fi
			find_first_partition ${devname}
			firstpart="$?"
			if [ "${firstpart}" != '0' ]
			then
				echo "Device [${devname}] has one partition: ${devname}${firstpart}"
			else
				echo "Cannot identify which partition to use on ${devname}"
			fi
			devcnt=$((devcnt+1))
		fi
	done
	if [ "${devcnt}" = '0' ]
	then
		echo "No USB-stick has been detected."
	fi
}

## Main
###############################################################################

export TERMINFO_DIRS=$TERMINFO_DIRS:/lib/terminfo:/etc/terminfo:/usr/share/terminfo

if [ "$(basename $0)" = 'usb_inst.sh' ] && [ -d "${PROGLOC}/usb_inst" ]
then
	RUN_FROM_ISOROOT='1'

	# copy programs to a temp dir on the disk since exec from cdrom may fail
	cleanup_tmpdir
	mkdir -p ${TMPDIR} || die "Cannot create temp directory: ${TMPDIR}"
	if ! cp -r ${PROGLOC}/usb_inst/* ${TMPDIR}/
	then
		rm -rf ${TMPDIR} 2>/dev/null
		die "Cannot write programs in temp directory: ${TMPDIR}"
	else
		chmod 777 ${TMPDIR}/*
	fi
	LOCATION="${PROGLOC}"
	# programs directly used by this script
	PROG_PARTED="${TMPDIR}/parted"
	PROG_INSTMBR="${TMPDIR}/install-mbr"
	PROG_MKVFATFS="${TMPDIR}/mkfs.vfat"
	PROG_SYSLINUX="${TMPDIR}/syslinux"
	PROG_DIALOG="${TMPDIR}/dialog"
	export DIALOGRC="/dev/null"
	# syslinux requires mtools
	ln -s mtools ${TMPDIR}/mcopy
	ln -s mtools ${TMPDIR}/mmove
	ln -s mtools ${TMPDIR}/mattrib
	export PATH=${TMPDIR}:${PATH}
else
	LOCATION="/livemnt/boot"
	PROG_PARTED="$(which parted)"
	PROG_INSTMBR="$(which install-mbr)"
	PROG_MKVFATFS="$(which mkfs.vfat)"
	PROG_SYSLINUX="$(which syslinux)"
	PROG_DIALOG="$(which dialog)"
fi

if [ "$1" = "-h" ] || [ "$1" = "--help" ]
then
	usage
	exit 1
fi

if [ "$(whoami)" != "root" ]
then
	help_readman "$0: This script requires root privileges to operate."
fi

if [ -z "${RUN_FROM_ISOROOT}" ] && ! cat /proc/mounts | awk '{print $2}' | grep -q -F '/memory'
then
	help_readman "$0: This script must be executed from SystemRescueCd"
	exit 1
fi

if [ -n "${RUN_FROM_ISOROOT}" ] && [ -z "${1}" ]
then
    COMMAND='dialog'
else
    COMMAND="${1}"
    shift
fi

case "${COMMAND}" in
	listdev)
		do_listdev
		;;
	writembr)
		do_writembr "$@"
		;;
	format)
		do_format "$@"
		;;
	copyfiles)
		do_copyfiles "$@"
		;;
	syslinux)
		do_syslinux "$@"
		;;
	dialog)
		do_dialog "$@"
		;;
	*)
		usage
		exit 1
		;;
esac
cleanup_tmpdir
exit 0
Looking at this now myself, I think I could tinker with the file freedos.img. I'm sorry, but I don't have much time at the moment.
 
Old 08-19-2016, 04:45 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,393

Rep: Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192
FreeDOS certainly used to work (on a floppy in my case, so it was a while ago). These days I use the M/Board manufacturers CD to flash - or directly from the BIOS (EFI - been a while since I bought a BIOS m/Board) itself.
 
Old 11-10-2016, 03:36 AM   #3
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 9.0 Custom, Merged Usr, Linux 4.19.x
Posts: 616

Rep: Reputation: 167Reputation: 167
When you say DOS, in relation to modern versions of Windows, it can mean one of several things...

Legacy DOS programs: These are programs actually meant to run under the classic, real-mode, 16-bit MS-DOS kernel. (IO.SYS, MSDOS.SYS & COMMAND.COM)
This kind of program is extremely rare and is nothing any modern computer manufacturer would ask a consumer to do. This kind of program can run under FreeDOS, etc. (Most of the time.)

Windows Native Console Applications: These look like DOS applications, but they aren't. They're just console (shell) applications that run against the modern (32/64-bit) Windows native C library & NT OS Kernel. (Win32 & SysWoW64) This is likely what your BIOS update utility uses. Note that there are some Linux LiveCDs that try to emulate a PXE environment in order to do technician work on a Windows installation via emulation. These might work for accessing NTFS partitions and editing a registry, but something like a BIOS update utility is attempting to speak natively to the hardware. YMMV!

.Net Console Applications: This is what you're friend wrote that neat text-based tic-tac-toe application with, it won't run outside of a fully booted Windows machine.

How to get to the second one to update your BIOS...

If you have a Windows DVD you can boot into the recovery console.

If your computer has a diagnostic and recovery partition you can try to use that.

Last, you can boot a Win PXE environment. This is what Windows boots from when its installing the OS. It basically replaces the old DOS boot disk from the Windows 95 era. Technicians use them all the time. There are official ones from Microsoft, but you need to download Windows Deployment Server to make one. Finally, a commonly freely available one is called you make yourself:

https://en.wikipedia.org/wiki/WinBuilder

Last edited by Luridis; 11-10-2016 at 03:40 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I make a bootable DOS usb drive in Linux? archieval Linux - Newbie 13 07-21-2021 05:40 PM
Mounting 1.72MB MS-DOS floppy (USB drive) Disket Linux - Newbie 8 06-16-2013 03:41 PM
LXer: Create a Bootable Live USB Thumb Drive or Rescue Drive Using UNetbootin LXer Syndicated Linux News 0 08-06-2012 03:10 AM
Clone 8 GB USB DOS boot disk to 4 GB USB drive agntsgotnosecret Linux - General 2 03-22-2010 09:40 AM
Why do file names keep getting changed to dos 8.3 format on my usb drive? firehawk256 Linux - Newbie 1 02-25-2005 03:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions

All times are GMT -5. The time now is 08:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration