Difference between revisions of "Linux USB"
Line 52: | Line 52: | ||
sudo mkdir /mnt/isoimage #create mounting point | sudo mkdir /mnt/isoimage #create mounting point | ||
sudo mount -o loop,ro -t iso9660 image.iso /mnt/isoimage/ #-o options, loop -loop,ro device /dev/loop in read-only mode, -t type eg. ntfs, vfat | sudo mount -o loop,ro -t iso9660 image.iso /mnt/isoimage/ #-o options, loop -loop,ro device /dev/loop in read-only mode, -t type eg. ntfs, vfat | ||
= Create FreeDOS bootable USB from Linux = | |||
This is often required for a server BIOS updates when the patch comes in DOS/Windows format. The following tutorial in essence brings all the above together therefore it will be valuable for you to read a whole article. Let's start. | |||
Partition USB flash using fdisk | |||
sudo fdisk /dev/sdb | |||
d -delete current partions | |||
n - create a partition, use defaults | |||
p - primary (0 primary, 0 extended, 4 free) with all defaults by pressing enter | |||
a - set bootbale flag on partition 1 | |||
t - select type | |||
c - fat32, (W95 FAT32 (LBA) | |||
w - write changes | |||
[[Create_filesystem_on_USB_stick]] - you may need to re plug in your USB flash to a laptop | |||
sudo mkfs.msdos -F 32 -n FREEDOS /dev/'''sdb1''' #creates fat32 filesystem where USB stick partition is /dev/sda1 | |||
Install syslinux bootloader and make USB flash bootable | |||
sudo syslinux -i /dev/sdb1 #overwrites previous bootloader GRUB like | |||
Download [http://www.freedos.org/download/ FreeDOS] | |||
wget http://www.freedos.org/download/download/fd11src.iso #FreeDOS 1.1 Base CD+several useful utilities, 40MB | |||
Mount FreeDOS image and copy boot files to USB | |||
sudo mount -i loop ~/Downloads/fd11src.iso /mnt/FREEDOS #you need create FREEDOS folder in advance | |||
# cp -r /mnt/FREEDOS/* /media/username/FREEDOS #not required, /media/username/FREEDOS where the USB is mounted | |||
unzip /mnt/FREEDOS/freedos/packages/boot/syslnxx.zip -d /media/username/FREEDOS #extract from .iso boot files to USB | |||
find /mnt/FREEDOS/freedos/packages/base/*.zip | xargs -l unzip -d /media/username/FREEDOS #extract FreeDOS base utilities | |||
cd /media/username/FREEDOS #change current directory to root USB directory (where USB is mounted) | |||
cp autoexec.txt autoexec.bat #create autoexec.bat using preconfigured autoexec.txt | |||
cp config.txt config.sys #create config.sys using preconfigured config.txt | |||
= Resources = | = Resources = | ||
*[http://www.syslinux.org/wiki/index.php/Isohybrid Isohybrid] Wiki | *[http://www.syslinux.org/wiki/index.php/Isohybrid Isohybrid] Wiki |
Revision as of 14:35, 29 June 2014
Set bootable flag on USB drive
First you need to partition your USB drive using fdisk
then set a bootable flag:
$ sudo fdisk /dev/sdb #/dev device needs to be a hard drive(sdb) not a partition(sdb1) Command (m for help): a Partition number (1-4): 1 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. $ sudo fdisk -l <--- output omitted -----> Disk /dev/sdb: 2002 MB, 2002747392 bytes 255 heads, 63 sectors/track, 243 cylinders, total 3911616 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sdb1 * 63 3911615 1955776+ c W95 FAT32 (LBA)
Create filesystem on USB stick
You should mark a partition in fdisk as FAT16 (type 0E) if the size is up to 2GB or FAT32 (type 0C) if bigger or needs long filenames support.
df -h #find your usb device lsblk #another way to find your device umount /dev/sdb1 mkfs.vfat /dev/sdb1 #create fat32 mkfs.ext3 /dev/sdb1 #create ext3 mkfs.msdos -F 32 -n FREEDOS /dev/sdb1 #format device to fat16, use -F 16 for fat16 mkdosfs -F 32 -n FREEDOS -I /dev/sdb1 #format device to fat32, use -F 16 for fat16, -n partition label
Make bootable USB from .iso image
Copy image to USB
DD can copy a whole image to the desired device but only a hybrid ISOs image will boot.
sudo umount /dev/sdb sudo dd if=image.iso of=/dev/sdb #output file of= needs pointing to USB drive not a partition (eg .sdb1) sync #forces changed blocks to disk, updates the super block and flushes file system buffers
Convert .iso to hybrid image
Starting in version 3.72, ISOLINUX supports a "hybrid mode" which can be booted from either CD-ROM or from a device which BIOS considers a hard disk or ZIP disk, e.g. a USB key or similar. Hybrid images are special as in addition to the normal CD-based ISO9660 filesystem, they also contain a valid-looking DOS-style partition table. The isohybrid contains MBR code which has to match the version of the ISOLINUX file isolinux.bin. Therefore always use the program from the same SYSLINUX installation which .iso has been created by mkisofs, genisoimage, or xorriso and then treat it by:
apt-cache pkgnames syslinux | grep -A 1 Version #check isolinux version isohybrid isolinuximage.iso #convert to hybrid image
The above operation will append necessary information to the image file thus the file check-sum will change.
Mount .iso
If you have .iso image and want to access its file system you can simply mount it. This is equivalent Windows virtual CD.
sudo mkdir /mnt/isoimage #create mounting point sudo mount -o loop,ro -t iso9660 image.iso /mnt/isoimage/ #-o options, loop -loop,ro device /dev/loop in read-only mode, -t type eg. ntfs, vfat
Create FreeDOS bootable USB from Linux
This is often required for a server BIOS updates when the patch comes in DOS/Windows format. The following tutorial in essence brings all the above together therefore it will be valuable for you to read a whole article. Let's start.
Partition USB flash using fdisk
sudo fdisk /dev/sdb d -delete current partions n - create a partition, use defaults p - primary (0 primary, 0 extended, 4 free) with all defaults by pressing enter a - set bootbale flag on partition 1 t - select type c - fat32, (W95 FAT32 (LBA) w - write changes
Create_filesystem_on_USB_stick - you may need to re plug in your USB flash to a laptop
sudo mkfs.msdos -F 32 -n FREEDOS /dev/sdb1 #creates fat32 filesystem where USB stick partition is /dev/sda1
Install syslinux bootloader and make USB flash bootable
sudo syslinux -i /dev/sdb1 #overwrites previous bootloader GRUB like
Download FreeDOS
wget http://www.freedos.org/download/download/fd11src.iso #FreeDOS 1.1 Base CD+several useful utilities, 40MB
Mount FreeDOS image and copy boot files to USB
sudo mount -i loop ~/Downloads/fd11src.iso /mnt/FREEDOS #you need create FREEDOS folder in advance # cp -r /mnt/FREEDOS/* /media/username/FREEDOS #not required, /media/username/FREEDOS where the USB is mounted unzip /mnt/FREEDOS/freedos/packages/boot/syslnxx.zip -d /media/username/FREEDOS #extract from .iso boot files to USB find /mnt/FREEDOS/freedos/packages/base/*.zip | xargs -l unzip -d /media/username/FREEDOS #extract FreeDOS base utilities cd /media/username/FREEDOS #change current directory to root USB directory (where USB is mounted) cp autoexec.txt autoexec.bat #create autoexec.bat using preconfigured autoexec.txt cp config.txt config.sys #create config.sys using preconfigured config.txt
Resources
- Isohybrid Wiki