Tuesday, November 12, 2013

Formatting Linux system Hard Disks

step 1:
first check weather the disks are partitioned or not by the following command

"fdisk -l "  we can get the following information

#fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x00068038

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1175     9436160   83  Linux
/dev/sda2            1176        1306     1046529    5  Extended
/dev/sda5            1176        1306     1046528   82  Linux swap / Solaris

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0xc0e14f21

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         605     4859631   83  Linux
/dev/sdb2             606        1305     5622750   83  Linux

Disk /dev/sdc: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0xf0bfae39

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         605     4859631   83  Linux
/dev/sdc2             606        1305     5622750    5  Extended
/dev/sdc5             800        1305     4064445   83  Linux
/dev/sdc6             606         799     1558273+  83  Linux

Partition table entries are not in disk order


step 2 : 

formating using mkfs tool 

#mkfs -t ext4 /dev/sdb1
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
351568 inodes, 1405687 blocks
70284 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1442840576
43 block groups
32768 blocks per group, 32768 fragments per group
8176 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables:  done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override. 


formatting sdb5 partition with ntfs format


#mkfs -t ntfs /dev/sdb5
Cluster size has been automatically set to 4096 bytes.
Initializing device with zeroes:  Done.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.

step 3 :
Checking all the partitions and their file system types

By using the command tool " blkid " we can get the file system type of all block devices that mounted or not mounted

#blkid
/dev/sda1: UUID="c99f3da5-e8a1-4236-ac74-5464b862fa2e" TYPE="ext4"
/dev/sda5: UUID="0323dd58-19bd-4c1b-84a0-5f11bfb09012" TYPE="swap"
/dev/sdb1: UUID="73bcc908-29ac-4f35-ac5d-a7f8ef129bc8" TYPE="ext4"
/dev/sdb2: UUID="9bb0643c-b44f-42aa-b421-c77982d62dc3" TYPE="ext4"
/dev/sdc1: UUID="47A5FD69713DD7A7" TYPE="ntfs"
/dev/sdc5: UUID="3CDB914277A4D94D" TYPE="ntfs"
/dev/sdc6: UUID="A561-50B5" TYPE="vfat" 


by using the command tool " parted " we can get detailed file system details of the mounted and unmounted file systems 

#parted -l
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system     Flags
 1      1049kB  9664MB  9663MB  primary   ext4            boot
 2      9665MB  10.7GB  1072MB  extended
 5      9665MB  10.7GB  1072MB  logical   linux-swap(v1)


Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  4976MB  4976MB  primary  ext4
 2      4976MB  10.7GB  5758MB  primary  ext4


Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  Flags
 1      32.3kB  4976MB  4976MB  primary   ntfs
 2      4976MB  10.7GB  5758MB  extended
 6      4976MB  6572MB  1596MB  logical   fat32
 5      6572MB  10.7GB  4162MB  logical   ntfs



No comments:

Post a Comment