banner
 .::*nix::. Thêm HardDisk vào Linux Go to original post Author: tranvanminh - Translator:  - Entry Date: 16/02/2009 00:24:14
Bài viết này được sao chép từ memo của tôi khi ráp ổ cứng IDE vào Linux (Fedora Core 2) .
Phần fdisk có khả năng hiển thị sai khi copy từ shell, có thể khi bạn làm theo bài viết sẽ không hiển thị ra các thông số giống trong bài viết. Vì đã cho HD vào hoạt động, việc kiểm chứng lại kết quả hơi khó khăn , mong được thông cảm . Bài viết này sẽ hướng dẫn bạn thêm ổ cứng vào máy khi khặp phải trường hợp, đầy ổ hoặc hỏng ổ cứng . Ngoài ra , cách này có thể áp dụng cho các loại ổ cứng ATA, SATA và SCSI .

- 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
(e.g., DOS FDISK, OS/2 FDISK)

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

0 Empty 1c Hidden Win95 FA 70 DiskSecure Mult bb Boot Wizard hid
1 FAT12 1e Hidden Win95 FA 75 PC/IX be Solaris boot
2 XENIX root 24 NEC DOS 80 Old Minix c1 DRDOS/sec (FAT-
3 XENIX usr 39 Plan 9 81 Minix / old Lin c4 DRDOS/sec (FAT-
4 FAT16 <32M 3c PartitionMagic 82 Linux swap c6 DRDOS/sec (FAT-
5 Extended 40 Venix 80286 83 Linux c7 Syrinx
6 FAT16 41 PPC PReP Boot 84 OS/2 hidden C: da Non-FS data
7 HPFS/NTFS 42 SFS 85 Linux extended db CP/M / CTOS / .
8 AIX 4d QNX4.x 86 NTFS volume set de Dell Utility
9 AIX bootable 4e QNX4.x 2nd part 87 NTFS volume set df BootIt
a OS/2 Boot Manag 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access
b Win95 FAT32 50 OnTrack DM 93 Amoeba e3 DOS R/O
c Win95 FAT32 (LB 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor
e Win95 FAT16 (LB 52 CP/M 9f BSD/OS eb BeOS fs
f Win95 Ext'd (LB 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT
10 OPUS 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/
11 Hidden FAT12 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b
12 Compaq diagnost 56 Golden Bow a7 NeXTSTEP f1 SpeedStor
14 Hidden FAT16 <3 5c Priam Edisk a8 Darwin UFS f4 SpeedStor
16 Hidden FAT16 61 SpeedStor a9 NetBSD f2 DOS secondary
17 Hidden HPFS/NTF 63 GNU HURD or Sys ab Darwin boot fd Linux raid auto
18 AST SmartSleep 64 Novell Netware b7 BSDI fs fe LANstep
1b Hidden Win95 FA 65 Novell Netware b8 BSDI swap ff BBT 



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:
done

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/
lost+found 


- 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 

[digg] [delicious] [google] [yahoo] [technorati] [reddit] [stumbleupon]
Go to top Go to original post  

Powered by JForum - Extended by HVAOnline
 hvaonline.net  |  hvaforum.net  |  hvazone.net  |  hvanews.net  |  vnhacker.org
1999 - 2013 © v2012|0504|218|