LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-04-2013, 05:06 AM   #1
chesschi
Member
 
Registered: May 2011
Posts: 41

Rep: Reputation: 0
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!
 
Old 03-04-2013, 05:39 AM   #2
goumba
Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Debian Wheezy (7.0), Jessie (future 8) and Sid (unstable)
Posts: 551
Blog Entries: 3

Rep: Reputation: 66
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.
 
Old 03-04-2013, 06:26 AM   #3
chesschi
Member
 
Registered: May 2011
Posts: 41

Original Poster
Rep: Reputation: 0
Thank you for your reply.

Quote:
Originally Posted by goumba View Post
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 View Post
#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.

Last edited by chesschi; 03-04-2013 at 06:28 AM. Reason: Add greeting :)
 
Old 03-04-2013, 07:54 AM   #4
goumba
Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Debian Wheezy (7.0), Jessie (future 8) and Sid (unstable)
Posts: 551
Blog Entries: 3

Rep: Reputation: 66
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.
 
Old 03-04-2013, 08:22 AM   #5
chesschi
Member
 
Registered: May 2011
Posts: 41

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by goumba View Post
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!
 
Old 03-04-2013, 09:21 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,969

Rep: Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752
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?
 
Old 03-04-2013, 09:25 AM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,270
Blog Entries: 3

Rep: Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445
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!
 
Old 03-05-2013, 04:22 AM   #8
chesschi
Member
 
Registered: May 2011
Posts: 41

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
Can you provide a manufacture/part number for your embedded device?
It is an ICOP vortex board.

Quote:
Originally Posted by michaelk View Post
What happens when you boot to DOS and try a cd c: command?
It says "Invalid Drive C:"
 
Old 03-05-2013, 04:31 AM   #9
chesschi
Member
 
Registered: May 2011
Posts: 41

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by onebuck View Post
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".
 
Old 03-05-2013, 05:49 PM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,969

Rep: Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752
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:?
 
Old 03-05-2013, 07:15 PM   #11
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,270
Blog Entries: 3

Rep: Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445Reputation: 1445
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.
 
Old 03-06-2013, 04:26 AM   #12
chesschi
Member
 
Registered: May 2011
Posts: 41

Original Poster
Rep: Reputation: 0
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
 
  


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 to format a usb device? topheraholic Linux - Newbie 6 05-10-2009 08:16 AM
how to access /dev/hdx ngan_yine Slackware 10 10-22-2004 04:23 PM
hdx changed rmdnet Linux - Hardware 1 10-22-2004 07:30 AM
use vi to convert linux format to windows format intolinux Linux - Software 2 12-10-2003 10:20 PM
Format a device in Linux? subnet Linux - General 8 09-17-2003 04:40 AM


All times are GMT -5. The time now is 01:42 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration