Formatting Hard Drive In Linux
Bob Shaffer
fedora at bobshafferscomputer.com
Tue Apr 13 17:24:16 UTC 2004
You don't really format hard drives, you format partitions (unless you're
talking about a low-level format, which I doubt). The first thing you
have to do is look at the partition table:
[root at orinoco root]# fdisk -l /dev/hda
Disk /dev/hda: 4099 MB, 4099866624 bytes
128 heads, 63 sectors/track, 993 cylinders
Units = cylinders of 8064 * 512 = 4128768 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 163 657184+ 6 FAT16
/dev/hda2 164 169 24192 83 Linux
/dev/hda3 170 186 68544 82 Linux swap
/dev/hda4 187 993 3253824 83 Linux
You will see something similar, though not exactly the same as that.
If I wanted to format my FAT16 (Windows) partition, I would type:
[root at orinoco root]# mkfs.msdos /dev/hda1
It would take it a few seconds to format the partition.
If I wanted to format my swap partition for some reason, I would type:
[root at orinoco root]# swapoff -a ; mkswap /dev/hda2 ; swapon -a
Which would disable the swap, format it, then re-enable it.
Fedora uses volume labels to identify a linux partition's mount-point. To
see what the mount point of 'hda2' is, you would type:
[root at orinoco root]# e2label /dev/hda2
In my case, it would print '/boot'. You can actually format this one with
linux running, though I'm not sure why you would want to. Do so by
typing:
[root at orinoco root]# umount /boot ; mkfs.ext3 /dev/hda2
It would format your boot partition and render your system unbootable in
seconds. Now, if I was to type:
[root at orinoco root]# e2label /dev/hda4
I would see that 'hda4' is my root (/) partition. I can't really format
this while linux is running, although it would probably let me do it
anyway. What I would do is boot from the Fedora CD in rescue mode or from
my helix CD and type:
[root at orinoco root]# mkfs.ext3 /dev/hda4
And that would format my root partition...
Now, in case you really did want to low-level format your drive, I'll just
go ahead and tell you how to do that. I haven't done this in a long time,
so it might not be 100% right. I'm pretty sure it will work, though:
[root at orinoco root]# fdisk -l /dev/hda
Disk /dev/hda: 4099 MB, 4099866624 bytes
128 heads, 63 sectors/track, 993 cylinders
Units = cylinders of 8064 * 512 = 4128768 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 163 657184+ 6 FAT16
/dev/hda2 164 169 24192 83 Linux
/dev/hda3 170 186 68544 82 Linux swap
/dev/hda4 187 993 3253824 83 Linux
It says that my drive is 4099 MB, so I'll use this in my next command.
[root at orinoco root]# dd if=/dev/zero bs=1024k blocks=4099 of=/dev/hda
That will write zeroes to the whole drive. It might miss a few bytes at
the end, but I don't think so or even think it would matter. It will wipe
out your entire drive including the partition table. I don't really
suggest doing it, though.
The real answer, btw, probably should have been "Why would you want to?"
Have fun.
jack Garcia said:
> Hi!
>
> I need to format the hard drive. I know how to do that in Windows. I don't
> know how to do it in Linux. I'm using Fedora 9.
>
> Thanks
> jackservant at msn.com --
> fedora-list mailing list
> fedora-list at redhat.com
> To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list
>
More information about the fedora-list
mailing list