1

Become root

You will need super user privileges, do and enter authorize as needed

1su -

2

Where on Linux is my new hard disk?

One way to find new, avalaible but not partitioned device, is to use ls /dev/s*

1[root@thinkplexx ~]# ls /dev/s*
2/dev/sda   /dev/sda2  /dev/sdb1  /dev/sg1  /dev/snapshot  /dev/stdin   /dev/systty
3/dev/sda1  /dev/sdb   /dev/sdc   /dev/sg0   /dev/sg2  /dev/stderr    /dev/stdout

Here, we can see that /dev/sda, /dev/sdb etc all have been partitioned:

1/dev/sda
2/dev/sda1
3...
4/dev/sdb
5/dev/sdb1
6...

/dev/sdc is available as a phisical device but has no partitions like /dev/sdc1, /dev/sdc2 etc.

3

Use fdisk to make partitions

3.1

Start fdisk

fdisk /dev/sdc :

1[root@thinkplexx ~]# fdisk /dev/sdc
2The number of cylinders for this disk is set to 33418.
3There is nothing wrong with that, but this is larger than 1024,
4and could in certain setups cause problems with:
51) software that runs at boot time (e.g., old versions of LILO)
62) booting and partitioning software from other OSs
7   (e.g., DOS FDISK, OS/2 FDISK)

Message is common for newer disks and selfexplaining. Says that you might have problems with older LILO’s and double booting systems.

3.2

Get disk info

You are inside fdisk now

1Command (m for help): [type p]
2 
3Disk /dev/sdc: 274.8 GB, 274877906944 bytes
4255 heads, 63 sectors/track, 33418 cylinders
5Units = cylinders of 16065 * 512 = 8225280 bytes

Yep, disk is there, but no partitions.

3.3

Add a primary partition

We just take all space for one partition:

01Command (m for help): [type n]
02Command action
03   e   extended
04   p   primary partition (1-4)
05[type p]
06Partition number (1-4): [type 1]
07First cylinder (1-621, default 1): [type RETURN]
08Using default value 1
09Last cylinder or +size or +sizeM or +sizeK (1-33418, default 33418):  [typeRETURN]
10Using default value 33418

Verify new partition table, in my case it would be:

1Command (m for help): p
2...
3   Device Boot      Start         End      Blocks   Id  System
4/dev/sdc1               1       33418   268430053+  83  Linux

3.4

Write table to disk and exit

After you verified that your changes are ok, use w to write new partition table.
If you don’t use “w”, no changes will happen, no new partitions will be creted.

4

Format disk

now, if you try ls /dev/s* , there will be /dev/sdc1 partition available:

1[root@thinkplexx ~]# ls /dev/s*
2/dev/sda   /dev/sda2  /dev/sdb1  /dev/sdc1 /dev/sg1  /dev/snapshot  /dev/stdin   /dev/systty
3/dev/sda1  /dev/sdb   /dev/sdc   /dev/sg0   /dev/sg2  /dev/stderr    /dev/stdout

Run mkfs.ext3 to format using ext3 filesystem.

01[root@thinkplexx ~]# mkfs.ext3 /dev/sdc1
02mke2fs 1.39 (8-May-2006)
03Filesystem label=
04OS type: Linux
05Block size=4096 (log=2)
06Fragment size=4096 (log=2)
07...
08Writing inode tables: done
09Creating journal (268430053 blocks): done
10Writing superblocks and filesystem accounting information: done
11 
12This filesystem will be automatically checked every 36 mounts or
13180 days, whichever comes first.  Use tune2fs -c or -i to override.

5

Mount

Create a new mount point
mkdir /mnt/storage

Now edit fstab so that mounted device will be available after reboot and mount command may be applied on mount point.

vim /etc/fstab

You are in vim, type [e].

State that /dev/sdc1 partition should be mounted to /mnt/storage :

1/dev/sdc1               /mnt/storage            ext3    defaults        1 2

After line is added, use key combination [esc][:wq!]. Vim saves new fstab.

Mount now:
mount /mnt/storage

6

Done, new hard disk partition can be used

1[root@thinkplexx ~]# cd /
2[root@thinkplexx ~]# df -k
3Filesystem           1K-blocks      Used Available Use% Mounted on
4...
5/dev/sdc1            264218344         0  89411780  0% /mnt/storage
6...

device is ready to be used.

Have fun!

출 처 : http://www.thinkplexx.com/learn/howto/linux/system/add-partition-format-and-mount-hard-disks-on-linux-fast-and-simple-step-by-step-guide

댓글을 달아 주세요

 «이전 1 2 3 4 5 6 ··· 98  다음»