LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Format hdx device for Windows (https://www.linuxquestions.org/questions/linux-newbie-8/format-hdx-device-for-windows-4175452617/)

chesschi 03-04-2013 05:06 AM

Format hdx device for Windows
 
Hi,

I had a kit that has a SCSI device built-in and it starts up in DOS. I also attach a hard disk (hda) to it. My goal is to deploy a linux operating system to the kit.

So I proposed to use a bootable USB for Linux and it will load the kernel I have built. My idea is to format a small part of the hard disk which can be seen as a drive in DOS (e.g. /dev/hda1 as C drive) and the remaining will be formatted as ext3 (e.g. /dev/hda2). When the kit starts and finds A drive for the SCSI, the autoexec.bat in A drive will contain the instructions to change directory to C drive and start the grub for the Linux operating system.

I am a newbie in Linux. I roughly knew the concepts but had no idea how to write my kernel scripts to achieve the goal. How should I write my scripts? e.g.

1. fdisk /dev/hda to create /dev/hda1 and /dev/hda2
2. mkfs.ext3 /dev/hda2 to format the hard disk for linux
3. mkdosfs -F xx /dev/hda1 for Windows?
4. What's next?

Many thanks!

goumba 03-04-2013 05:39 AM

While I don't know what you mean by kernel scripts, you have everything ok there. You can skip #2, as when you install Linux it will allow you to do so in the installer, so save yourself the extra work there.

Also, you can omit "-F xx" in #3 if you choose. mkfs.msdos will choose which FAT size to use based on the size of the partition, and I would let it do so, unless you have a specific need (I noticed a mention of DOS, but do not know what specific DOS and what it supports). If you do need to use a specific FAT size, keep that in mind when you set the size of the partition.

#4. Install your OS(es) of choice.

chesschi 03-04-2013 06:26 AM

Thank you for your reply.

Quote:

Originally Posted by goumba (Post 4904240)
While I don't know what you mean by kernel scripts, you have everything ok there.

When you use a bootable USB for linux like UNetbootin, syslinux.cfg will tell what image to load. I have written some scripts to instruct how to format the hard disk at startup, build the kernel image with those scripts, and then put the kernel image into the USB drive (like initramfs).

Quote:

Originally Posted by goumba (Post 4904240)
#4. Install your OS(es) of choice.

Unfortunately, my kit is an embedded device which uses busybox as the Linux operating system. When the kit starts, it will decompress the kernel image from the USB drive and load the scripts I have written. The scripts aim to format /dev/hda1 that is recognised from DOS and put the grub into it. So when I unplug the USB drive and reboot the kit, /dev/hda1 will be seen as C drive and so the autoexec.bat in the SCSI can find the grub in the C drive.

goumba 03-04-2013 07:54 AM

Ok.

Just make sure the FAT size you're using is supported by your DOS and your kit/BIOS. This may affect the maximum partition size you can use as well.

chesschi 03-04-2013 08:22 AM

Quote:

Originally Posted by goumba (Post 4904336)
Just make sure the FAT size you're using is supported by your DOS and your kit/BIOS.

I did format the hard disk using the correct FAT size but it is still *NOT* recognised as C drive after unplugging the USB drive and reboot. Do I have to do some extra steps after formatting?

Many thanks!

michaelk 03-04-2013 09:21 AM

Can you provide a manufacture/part number for your embedded device?

Being recognized as a c: drive is a function of the BIOS. What happens when you boot to DOS and try a cd c: command?

onebuck 03-04-2013 09:25 AM

Member Response
 
Hi,

Whenever creating a partition for Windows FAT that is to be boot-able be sure to set the 'boot' flag for that partition. Then format either using a Windows/Dos tool or for Linux you can use mkfs.vfat;
Quote:

mkdosfs - create an MS-DOS file system under Linux

SYNOPSIS
mkdosfs|mkfs.msdos|mkfs.vfat [ -a ] [ -A ] [ -b sector-of-backup ] [ -c ] [ -l filename ] [ -C ] [ -f number-of-FATs ] [ -F FAT-size ] [ -h number-of-
hidden-sectors ] [ -i volume-id ] [ -I ] [ -m message-file ] [ -n volume-name ] [ -r root-dir-entries ] [ -R number-of-reserved-sectors ] [ -s sectors-
per-cluster ] [ -S logical-sector-size ] [ -v ] device [ block-count ]

DESCRIPTION
mkdosfs is used to create an MS-DOS file system under Linux on a device (usually a disk partition). device is the special file corresponding to the
device (e.g /dev/hdXX). block-count is the number of blocks on the device. If omitted, mkdosfs automatically determines the file system size.

OPTIONS
-a Normally, for any filesystem except very small ones, mkdosfs will align all the data structures to cluster size, to make sure that as long as
the partition is properly aligned, so will all the data structures in the filesystem. This option disables alignment; this may provide a hand-
ful of additional clusters of storage at the expense of a significant performance degradation on RAIDs, flash media or large-sector hard disks.

-A Use Atari variation of the MS-DOS file system. This is default if mkdosfs is run on an Atari, then this option turns off Atari format. There are
some differences when using Atari format: If not directed otherwise by the user, mkdosfs will always use 2 sectors per cluster, since GEMDOS
doesn't like other values very much. It will also obey the maximum number of sectors GEMDOS can handle. Larger file systems are managed by
raising the logical sector size. Under Atari format, an Atari-compatible serial number for the file system is generated, and a 12 bit FAT is
used only for file systems that have one of the usual floppy sizes (720k, 1.2M, 1.44M, 2.88M), a 16 bit FAT otherwise. This can be overridden
with the -F option. Some PC-specific boot sector fields aren't written, and a boot message (option -m) is ignored.

-b sector-of-backup
Selects the location of the backup boot sector for FAT32. Default depends on number of reserved sectors, but usually is sector 6. The backup
must be within the range of reserved sectors.

-c Check the device for bad blocks before creating the file system.

-C Create the file given as device on the command line, and write the to-be-created file system to it. This can be used to create the new file sys-
tem in a file instead of on a real device, and to avoid using dd in advance to create a file of appropriate size. With this option, the block-
count must be given, because otherwise the intended size of the file system wouldn't be known. The file created is a sparse file, which actually
only contains the meta-data areas (boot sector, FATs, and root directory). The data portions won't be stored on the disk, but the file neverthe-
less will have the correct size. The resulting file can be copied later to a floppy disk or other device, or mounted through a loop device.

-f number-of-FATs
Specify the number of file allocation tables in the file system. The default is 2. Currently the Linux MS-DOS file system does not support
more than 2 FATs.

-F FAT-size
Specifies the type of file allocation tables used (12, 16 or 32 bit). If nothing is specified, mkdosfs will automatically select between 12, 16
and 32 bit, whatever fits better for the file system size.

Note the bold information above from 'man mkfs.vfat' or 'man mkdosfs'.

Hope this helps!

chesschi 03-05-2013 04:22 AM

Quote:

Originally Posted by michaelk (Post 4904390)
Can you provide a manufacture/part number for your embedded device?

It is an ICOP vortex board.

Quote:

Originally Posted by michaelk (Post 4904390)
What happens when you boot to DOS and try a cd c: command?

It says "Invalid Drive C:"

chesschi 03-05-2013 04:31 AM

Quote:

Originally Posted by onebuck (Post 4904393)
Whenever creating a partition for Windows FAT that is to be boot-able be sure to set the 'boot' flag for that partition.

Here are the steps that I create the partition:
  1. fdisk /dev/hda
  2. new a primary partition 1 and 2
  3. write table to disk and exit

I did try to use the option "toggle a bootable flag" on partition 1. However, when I reboot the kit, it shows the error "This is not a bootable disk".

michaelk 03-05-2013 05:49 PM

Formatting the partition nor setting the boot flag will create a bootable drive. It does not copy the system files i.e. command.com, io.sys, msdos.sys. I'm not familiar with the hardware to know how to get DOS to recognise the IDE drive as C:. If that worked you could possibly use grub4dos to boot linux from the autoexec.bat file on the A drive.
Have you tried to see if it is recognised as B: vs C:?

onebuck 03-05-2013 07:15 PM

Member Response
 
Hi,

Personally, I would use MS tools to create the MS partition(s) using fdisk, here you would set the primary as active after creating the partition. You can then format with the format command as 'format c: /s' this would prepare the partition for booting and placing the needed system files.

You could use the Microsoft OS System DVD to create the necessary partitions and this would provide the system boot files.

chesschi 03-06-2013 04:26 AM

The solution is:
When I use fdisk to partition the disk, I need to use the option 't' to alter the partition type (i.e. FAT size) after I create a new partition. When I use the option 'p' to print the partition table, the System column will be changed from 'Linux' to 'FATxx' when the partition type is altered.

After that, I can use mkdosfs -F xx /dev/hda to format the partition.

Thank you for all your kind help ;)


All times are GMT -5. The time now is 09:29 PM.