Hadyai Internet R&D LAB
แหล่งความรู้ => Server => Linux Server System => ข้อความที่เริ่มโดย: admin ที่ 07 พฤษภาคม 2008, 04:56:29
-
ในการติดตั้ง HDD เพิ่มเข้าไปอีก 1 ตัว เพื่อเพิ่มขนาดเนื้อที่สำหรับเก็บข้อมูล หรือสำหรับแยก Cache File สำหรับ squid ก็สามารถทำได้โดย
root@cpluszone:~# fdisk -l
Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x54bf54bf
Device Boot Start End Blocks Id System
/dev/sda1 * 1 9327 74919096 83 Linux
/dev/sda2 9328 9729 3229065 5 Extended
/dev/sda5 9328 9729 3229033+ 82 Linux swap / Solaris
Disk /dev/sdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x8f800000
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 1913 15366141 7 HPFS/NTFS
/dev/sdb2 1914 9729 62782020 f W95 Ext'd (LBA)
/dev/sdb5 1914 9053 57352018+ 7 HPFS/NTFS
/dev/sdb6 9054 9729 5429938+ 7 HPFS/NTFS
root@cpluszone:~#
จาก ตัวอย่าง จะเห็นว่า HDD ลูกแรก /dev/sda ขนาด 80GB ติดตั้ง Ubuntu 7.10 และ
HDD ตัวที่สอง /dev/sdb ขนาด 80GB ยังไม่ได้ทำการ Format ยังคงมี Partition ของ Windows XP อยู่
ทำการ format โดยใช้คำสั่ง
root@cpluszone:~# fdisk /dev/sdb <--- คำสั่ง fdisk เพื่อทำการลบและสร้าง partition ใหม่
The number of cylinders for this disk is set to 9729.
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): d <-- กด d เพื่อ ลบ patition ที่มีอยู่
Partition number (1-6): 1 <-- เลือก partition ที่ต้องการลบ
Command (m for help): p <-- กด p เพื่อดู partition
Disk /dev/sdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x8f800000
Device Boot Start End Blocks Id System
Command (m for help): n <-- สร้าง patition ใหม่ขึ้นมา
Command action
e extended
p primary partition (1-4)
p <-- เป็นแบบ primary
Partition number (1-4): 1
First cylinder (1-9729, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-9729, default 9729):
Using default value 9729
Command (m for help): w <-- ทำการบันทึก partition ใหม่
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
เมื่อแบ่ง partition เสร็จแล้ว ต่อไปก็ต้องทำการ make filesystem หรือ format นั่นเอง
root@cpluszone:~# mkfs.ext3 /dev/sdb
mke2fs 1.40.2 (12-Jul-2007)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
9781248 inodes, 19537686 blocks
976884 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
597 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, 2654208,
4096000, 7962624, 11239424
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
-
เมื่อทำการสั่ง fdisk -l ก็จะได้ผลลัพธ์ ออกมาดัง code ตัวอย่าง
root@cpluszone:~# fdisk -l
Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x54bf54bf
Device Boot Start End Blocks Id System
/dev/sda1 * 1 9327 74919096 83 Linux
/dev/sda2 9328 9729 3229065 5 Extended
/dev/sda5 9328 9729 3229033+ 82 Linux swap / Solaris
Disk /dev/sdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x24891f1e
Device Boot Start End Blocks Id System
/dev/sdb1 1 9729 78148161 83 Linux
root@cpluszone:~#
ต่อไปก็เข้าไปเพิ่มในไฟล์ /etc/fstab เพื่อให้ทำการ mount อัตโนม้ติทุกครั้งที่ boot
ทดลองใช้คำสั่ง df เพื่อดูการ mount ให้อัตโนมัติทุกครั้ง
root@cpluszone:~# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 73742752 2203828 67792972 4% /
varrun 1037824 64 1037760 1% /var/run
varlock 1037824 0 1037824 0% /var/lock
udev 1037824 56 1037768 1% /dev
devshm 1037824 0 1037824 0% /dev/shm
/dev/sdb1 76920416 184220 72828788 1% /data
root@cpluszone:~#
-
ในกรณีนี้ จะใช้ HDD ตัวที่ 2 ทำหน้าที่เก็บ cache ของ Squid และ frox
เพื่อแยกการทำงานระหว่าง system กับ cache เป็นการเพิ่มความเร็วให้การระบบ filesystem