Tuesday, June 16, 2009

Thêm HardDisk vào Linux

- Khái quát về việc cần làm -
1. Gắn HD vào máy
2. Tạo phần vùng cho HD mới
3. Tạo ext3 cho /dev/hdb
5. Copy dữ liệu của HD cũ sang HD mới
6. Cấu hình cho HD tự khởi động

- Tạo phần vùng cho HD mới -
[root@localhost src]# fdisk /dev/hdb

The number of cylinders for this disk is set to 20023.
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

Command (m for help): m
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): l

Command (m for help): n

Command action
e extended
p primary partition (1-4)
p <--- và Enter Partition number (1-4): First cylinder (1-20023, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-20023, default 20023): Using default value 20023
Command (m for help): p

Disk /dev/hdb: 164.6 GB, 164696555520 bytes
255 heads, 63 sectors/track, 20023 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb 1 20023 160834716 83 Linux

- Thoát ra fdisk -
Command (m for help): q

- Tạo ext3 cho /dev/hdb -

[root@localhost src]# mke2fs -jc /dev/hdb

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
20119552 inodes, 40209120 blocks
2010456 blocks (5.00%) reserved for the super user
First data block=0

Writing superblocks and filesystem accounting information:

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

- Mount /dev/hdb vào /mnt/hdb bằng ext3 -
[root@localhost src]# mkdir /mnt/hdb
[root@localhost src]# mount -t ext3 /dev/hdb /mnt/hdb/
[root@localhost src]# ls /mnt/hdb/

- Copy dữ liệu sang HD mới và xóa /home trên HD cũ -
[root@localhost src]# cd /home
[root@localhost src]# tar cvf - . | tar xvf - -C /mnt/hdb
[root@localhost src]#rm -rf /home
[root@localhost src]#mkdir /home
[root@localhost src]#reboot

- Kiểm tra -
[root@localhost root]# df -h

Filesystem size Used Avail Use% Mounted on
/dev/hda3 150G 1.5G 141G 2% /
/dev/hda1 99M 8.3M 86M 9% /boot
none 504M 0 504M 0% /dev/shm
/dev/hdb 151G 33M 144G 1% /home

No comments:

Post a Comment