Cách thêm ổ đĩa mới vào CentOS

Tác giả admin+, T.Ba 14, 2011, 06:38:54 CHIỀU

« Chủ đề trước - Chủ đề tiếp »

0 Thành viên và 2 Khách đang xem chủ đề.

Cách thêm ổ đĩa mới vào CentOS


  • Sử dụng lệnh fdisk -l để xem thông tin về hệ thống phân vùng thế nào.

Mã nguồn [Chọn]
[root@ ~]# fdisk -l
Mã nguồn [Chọn]
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          19      152586   83  Linux
/dev/sda2              20        1462    11590897+  83  Linux
/dev/sda3            1463        2482     8193150   83  Linux
/dev/sda4            2483        2610     1028160    5  Extended
/dev/sda5            2483        2609     1020096   82  Linux swap / Solaris

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       10240    10485744    5  Extended
/dev/sdb5               1       10240    10485728   83  Linux

Disk /dev/sdc: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdc doesn't contain a valid partition table

  • Sau khi chạy lệnh trên thì chúng ta sẽ thấy có 3 ổ đĩa trong khi đó mới chỉ có 2 ổ đĩa đã được Mount vào. Vì vậy chúng ta sẽ định dạng và mount ổ đĩa thứ 3 vào. Nó có tên là /dev/sdc
  • Tiến hành phân vùng cho ổ đĩa mới /dev/sdc

Mã nguồn [Chọn]
[root@~]# fdisk /dev/sdc
Mã nguồn [Chọn]
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

The number of cylinders for this disk is set to 10240.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0×0000 of partition table 4 will be corrected by w(rite)

Command (m for help):

  • Các bạn hãy chọn m.

Mã nguồn [Chọn]
Command action
a   toggle a bootable flag
b   edit bsd disklabel
c   toggle the dos compatibility flag
d   delete a partition
l   list known partition types
m   print this menu
n   add a new partition
o   create a new empty DOS partition table
p   print the partition table
q   quit without saving changes
s   create a new empty Sun disklabel
t   change a partition's system id
u   change display/entry units
v   verify the partition table
w   write table to disk and exit
x   extra functionality (experts only)

Command (m for help):

  • Tại đây các bạn hãy chọn n để thêm phân vùng mới.

Mã nguồn [Chọn]
Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-10240, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-10240, default 10240):
Using default value 10240

Command (m for help):

  • Các bạn cứ để giá trị mặc đinh và chọn p để in ra phân vùng mà chúng ta vừa tạo.

Mã nguồn [Chọn]
Command (m for help): p

Disk /dev/sdc: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       10240    10485744    5  Extended

Command (m for help):

  • Như vậy chúng ta đã tạo được phân vùng Extended. Bây giờ chúng ta hãy tạo thêm phân vùng Logical.

Mã nguồn [Chọn]
Command (m for help): n
Command action
l   logical (5 or over)
p   primary partition (1-4)
l
First cylinder (1-10240, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-10240, default 10240):
Using default value 10240

Command (m for help): p

Disk /dev/sdc: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       10240    10485744    5  Extended
/dev/sdc5               1       10240    10485728   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

  • Bây giờ chúng ta sẽ định dạng bằng lệnh sau đây.

Mã nguồn [Chọn]
[root@~]# mkfs -t ext3 /dev/sdc5
Mã nguồn [Chọn]
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1310720 inodes, 2621432 blocks
131071 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

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

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

  • Bây giờ chúng ta sẽ ánh xạ ổ đĩa mới này vào bằng lệnh sau đây.

Mã nguồn [Chọn]
[root@~]# mkdir /vietnetwork
[root@~]# mount -t ext3 /dev/sdc5 /vietnetwork

  • Cuối cùng cần phải cập nhật tập tin /etc/fstab để hệ thống tự ánh xạ khi boot. Thêm dòng sau vào /etc/fstab.

Mã nguồn [Chọn]
[root@~]# vi /etc/fstab
Mã nguồn [Chọn]
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/home             /home                   ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda5         swap                    swap    defaults        0 0
/dev/sdb5               /home/www/              ext3    defaults        1 2
/dev/sdc5               /home/vietnetwork              ext3    defaults        1 2

Như vậy là chúng ta đã thêm được ổ đĩa mới vào hệ điều hành Linux xong rồi.