แค่เว็บๆหนึ่ง ! ที่อยากเก็บประสบการณ์
Home
 

How to Format a Linux Disk

Instructions
  1. Set Up a New Partition

    • 1

      Open a terminal window and log in as root:

      $ su (or “sudo su” on some distributions)

    • 2

      Find out the name of your hard drive. To do this, enter the following from the command prompt as root:

      # fdisk -l

      3.  Choose your newly installed drive after fdisk lists the current drives. The current hard drive will already have partitions assigned, and the output will look like this:

    • Disk /dev/sda: 16.1 GB, 16139354112 bytes
      /dev/sda1 * 1 1874 15052873+ 83 Linux

      /dev/sda2 1875 1962 706860 5 Extended

      /dev/sda5 1875 1962 706828+ 82 Linux swap / Solaris

      Your new hard drive will not have partitions, so all you will see will be a line such as:

      Disk /dev/sdb: 16.1 GB, 16139354112 bytes

    • 4

      Check to see if your disk is already mounted with this command:

      # df

    • 5

      Unmount your drive if it is mounted using this command:

      # umount /dev/sdb

    • 6

      Create a new partition by typing this command:

      # fdisk /dev/sdb

    • 7

      The fdisk prompt will open. Press “n” to make the new partition, and then press “Enter.”

    • 8

      Press “p” to create a primary partition, and then press “Enter.”

    • 9

      Press “1” to create the first partition followed by “Enter.”

    • 10

      Enter the default for both the first and last cylinders when your computer asks for this information. This will make the partition cover the entire disk rather than just part of it.

    • 11

      Press “t” to change the file system type followed by “Enter.”

    • 12

      Type “L” to see a list of known types followed by “Enter.”

    • 13

      Type “83” for “Linux” followed by “Enter.”

    • 14

      Press “w” to write the partition to the disk (this cannot be undone), and then press “Enter.”

    Format the New Partition

    • 15

      Format the new partition that you created with the following command:

      # mkfs.ext4 /dev/sdb1

    • 16

      Create a new directory and mount the new drive with these commands:

      # mkdir /media/newdrive (or whatever name you prefer)

      # mount /dev/sdb1 /media/newdrive

    • 17

      Edit your fstab file so that the new drive will be mounted at boot. Fstab is the Linux file system configuration file to mount partitions at boot. You can edit /etc/fstab with the “nano” command or “vi” depending on which editor you prefer.

      # nano /etc/fstab or # vi /etc/fstab

    • 18

      Add the following line to the end of fstab:

      /dev/sdb1 /media/newdrive ext4 defaults 1 2

    • 19

      Save the fstab file.

ที่มา : http://www.ehow.com/how_5853059_format-linux-disk.html#ixzz2giFXJfrs
Off 

October 4, 2013 This post was written by Categories: เรื่องเล่ารายวัน No comments yet


Top