Saturday 12 July 2014

USB PARTITIONING-Using LINUX Terminal ( Partion your USB like your HardDisk)

HOW TO PARTITION A HARD-DISK AND USB-DRIVE IN LINUX:

The partitioning process is same for both hard-disk and USB.

STEP1:

      Use lsblk command to list all block devices attached to the system.

STEP 2:

       Find the name of the corresponding hard disk or USB drive(ex. SDA or SDB or SDC ).
(Be careful while locating the name because if partitioned wrongly, it may result in loss of data ).

STEP 3:

      Use fdisk Commands to create and view partitions.

      fdisk <path to the hard-disk>

ex.     fdisk /dev/sdb




List of fdisk commands:

      p : print the partition table
      n : create a new partition
      d : delete a partition
      q : exit without saving the changes in partition table
      w : exit with saving
      a : to make a corresponding partition as bootable
      t : to set a corresponding partition as Swap Area

STEP 4:

In order to create a new partition, we must delete the existing partition.
the below diagrams shows creation of new partition and finally writing the partition using W command.



STEP 5:

       After partitioning we need to specify the file format for each partitions.Each Filesystem has its own utility.

List of File Formats:
SCO bfs, CPM, ext2, ext3, ext4, minix, fat (vfat), HFS, VXFS, RF disk, RK disk, DECtape, and NTFS.


For example, assume that we have created four partitions.
If required file format is ext2 in first partition, the utility is mke2fs.

Command:
             mke2fs /dev/sdb1 -L 'NAME_FOR_THIS_PART'



If required file format is ext3 in second partition, we need to create ext2 filesystem first and then change it to ext3 using tune2fs command.

Command:
             mke2fs /dev/sdb2 -L 'NAME_FOR_THIS_PART'
             tune2fs -j /dev/sdb2


If the required file format is FAT in third partition,
then the command is

             mkfs.vfat -n 'NAME_FOR_THIS_PART' -I  /dev/sdb3

Partioned disk can be seen below:


  Meet you in the next Knowledge Sharing Session!!!!!!!


Author
Sandheep Kumar M
Project Engineer
 

No comments:

Post a Comment