[SOLVED] Unable to Format brand new HPFS/NTFS drive
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The number of cylinders for this disk is set to 243199.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
You can also try this:
1. Unmount the drive.
2. do a
Code:
dd if=/dev/zero of=/dev/sdb bs=512 count=1
This will zero out the partition table.
3. Now use a partitioning tool like fdisk, cfdisk or GParted to create a new partition table and a new partition.
Before you write off that drive you might want to follow these steps;
1- TobiSGD's advice on zeroing the boot/partition table will assure that you are starting from scratch. So here it is again:
Code:
dd if=/dev/zero of=/dev/sdb bs=512 count=1
The above assumes sdb as the device you want to zero.
NOTE: By device I mean sdb NOT sdb1 or any of its partitions.
2- Reboot the machine.
3- Run the following command:
Code:
fdisk -l
This will list all of the available hard drives on the system. Verify in the output that your drive is there and has no partitions defined (i.e. sdb1, sdb2 ... ) if it has partitions defined then dd was unable to zero the partition table and there is a problem.
4- Using fdisk or whatever partitioning tool you choose, create your new partition. If you use fdisk it should go like this:
fdisk /dev/<device_here>
n
p
1
<accept default of 1>
<accept default for the last cylinder>
p (verify your partition with output here)
w (This will write your changes to disk)
The output from an actual fdisk session for a 160 GB disk follows:
Code:
$ fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x344fdc64.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-19457, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-19457, default 19457):
Using default value 19457
Command (m for help): p
Disk /dev/sdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x344fdc64
Device Boot Start End Blocks Id System
/dev/sdb1 1 19457 156288321 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
5- Now you can format the partition with the file system of your choice. For example to format as ext3:
Code:
mkfs.ext3 /dev/sdb1
Note: We now use the partition name (i.e. sdb1 ) rather than the device name (sdb) which will format the partition using an ext3 file system.
Once this is done you should be able to use your new drive (sdb) with its new partition (sdb1)
If you have questions regarding any of this please post them.
There is nothing wrong with the drive. mkfs does not automatically change the partition ID. Use fdisk to manually change the type to 83 i.e linux. FYI linux does not use the partition ID and you should be able to mount the partition as is.
11 inodes used (0.00%)
1 non-contiguous inode (9.1%)
# of inodes with ind/dind/tind blocks: 0/0/0
7713453 blocks used (1.58%)
0 bad blocks
1 large file
I read a guide that told me I had to press o and create a blank dos partition before starting? very confusing
please help
Code:
Overview
This article presents the commands used to partition and format a second hard drive in Linux using the ext3 file system. For the purpose of this example, I installed a second hard drive in a Red Had Linux system where the drive is recognized as /dev/hdb. I want to make only one partition on this hard drive which will be /dev/hdb1.
fdisk
First, you will need to run the fdisk command in order to partition the disk. For this example, I only want to create one ext3 partition. Here is an example session:
[root@linux2 etc]# fdisk /dev/hdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 4865.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-4865, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-4865, default 4865): 4865
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 83
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Create ext3 File System
The next step is to create an ext3 file system on the new partition. Provided with the distribution is a script named /sbin/mkfs.ext3. Here is an example session of using the mkfs.ext3 script:
[root@linux2 root]# mkfs.ext3 -b 4096 /dev/hdb1
mke2fs 1.27 (8-Mar-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
4889248 inodes, 9769520 blocks
488476 blocks (5.00%) reserved for the super user
First data block=0
299 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
I performed these steps with no luck. Im getting
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22: Invalid argument.
First off, I am saying sorry to my most recent post about the drive being messed up.
That being said, it really seems that you are missing something important here that you are not telling us. So a step by step guide might be good in your case.
So I tried a brand new drive and get the same result
Please post what commands/steps you accomplished.
The only obvious error I noticed was not changing the partition ID from HPFS/NTFS to linux.
Did you ever try to mounting the other drive?
You now need to set the filesystem type for your new partition with the "t" command. You are asked for the Hex code of the filesystem you wish to use. We will use the standard Linux ext2 filesystem, which is "83." If you are doing something special and know of a particular filesystem that you need to use, you can press "L" to see all the codes, which are one or two characters made up of the numbers 0 to 9 and the letters a to f.
Read more: How to Format a Hard Drive in Linux | eHow.com http://www.ehow.com/how_1000631_hard-drive-linux.html#ixzz1EBDB4ukI
However received the error when writing. ie: error22 invalid argument.
I just ran mkfs -t ext2 now on /dev/sdb1
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.