LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   formating a disk (https://www.linuxquestions.org/questions/linux-software-2/formating-a-disk-242517/)

onionkn1ght 10-14-2004 07:18 AM

formating a disk
 
I'm trying to format /dev/hdd but don't know how to do. If I were using X I could do it, but this computer doesn't have X installed. Is there any program for the console that can format disks? It's running on Mandrake 10.0

I have searched around a bit but all I could find was fdformat, which formats floppy disks.

Gort32 10-14-2004 07:22 AM

mkfs is the typical format command for Linux.

To what filesystem are you trying to format? To format to a specific filesystem, there should be commands like mkfs.ext2, mkfs.ext3, mkfs.reiser, mkfs.vfat, etc.

mritch 10-14-2004 10:31 AM

you have to partition the disk first. here are a few console programs to do so:
cfdsik, fdisk, parted /dev/hdd
read the manpages before, since you can mess up a lot with such tools. on ide drives you can have up to four primary partitions but more extended ones. if you want to read more 'bout this read some of the howtos at www.tldp.org .now create your partitions. example: one big for the system, one small (128MB-2G) for swap and one medium for your /home directory. they will get called hdd1, hdd2 and hdd3. now it's up to formatting the partitions. there are different tools for the kind of filesystem you want to use. linux old filoesystem was ext2 which now got a journal and is called ext3. it's often used on standard linux installations.

here is how to create a ext3 partition:
mke2fs -j -c /dev/hdd1
the -c option only tells mke2fs to check the disk readonly (non destructive) for bad blocks, so you can leave it away. the -j option is used to create a new journalled filesystem.

here is how to create a swap partition:
mkswap -c -v1 /dev/hdd2
-v1 is the newer format needed for 2.6 linux-kernels.

there are other filesystems like reiserfs (mkreiserfs), dos (forget about unless for diskettes), xfs and other, but i think going with ext3 is ok unless you need special performance for some kind of application.

mke2fs will adjust blocksize (and other) for best usage of the disk automatically, however if you want to run the disk as a mail or news spool you'll like to tune it for your needs. read the manpage for more info.

if it's formated you can mount it for example with:
mount -t ext3 /dev/hdd1 /mountpoint
and when everything is right and you want the partition to get mounted at bootup put the following line in your /etc/fstab:
/dev/hdd1 /mountpoint ext3 defaults 0 2

note: the directory where you want to mount the partition must exist.

sl mritch.


All times are GMT -5. The time now is 06:35 PM.