วันศุกร์ที่ 26 ธันวาคม พ.ศ. 2551

** ตั้งค่า IP. ที่การ์ดแลน **

** ตั้งค่า IP. ที่การ์ดแลน **

# alias ที่ไฟล์ /etc/rc.conf
ifconfig_rl0="inet 192.168.0.1 netmask 255.255.255.0"
ifconfig_rl0_alias0="inet 192.168.0.2 netmask 255.255.255.255"

เสร็จแล้วใช้คำสั่ง netstart ครับ

#/etc/netstart ; เพื่อ restart network configuration

ถ้าจะ set lan card ใบเดียวให้มี หลาย ๆ ip ให้ทำแบบนี้คับ
# ifconfig rl0 alias 192.168.1.1 netmask 255.255.255.0
# ifconfig
rl0: flags=8843 mtu 1500
inet 202.29.80.130 netmask 0xffffff80 broadcast 202.29.80.255
inet6 fe80::202:44ff:fe14:ba%rl0 prefixlen 64 scopeid 0x1
inet 192.168.1.1 netmask 0xffffff00 broadcast 192.168.0.255
ether 00:02:44:14:00:ba
media: Ethernet autoselect (100baseTX )
status: active

เพียงแค่นี้ก็จะสามารถใช้ได้ 2 ip คับผม

หรือถ้าต้องการให้ ip ที่เพิ่มเข้าไปใหม่นั้นทำงานทุกครั้งที่มีการ boot เครื่องให้เพิ่มบรรทัดนี้ ในไฟล์ /etc/rc.conf นะคับ

ifconfig_rl0_alias0="192.168.1.1 netmask 255.255.255.0"

สามารถทำได้หลายแบบนะครับ
รู้สึกว่าใน Slackware จะใช้แบบนี้นะครับ

# ifconfig rl0:0 inet xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx
# ifconfig rl0:1 inet xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx

ถ้า rl0 คือชื่อ lan card ใบที่ 1 กำหนดเป็น ip address ตัวที่ 1
ส่วน :0 และ :1 ก็เป็นหมายเลข ip address ตัวที่ 2 และ 3 ตามลำดับ

ส่วน BSD น่าจะอย่างงี้นะคับ

# ifconfig_rl0="xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx"
# ifconfig_rl0_alias1="xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx"
# ifconfig_rl0_alias0="xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx"

ถ้าทำผ่าน sysinstall ก็ขั้นตอนนี้นะครับ
/stand/sysinstall -> เลือก configure -> เลือก networking -> เลือก interface -> เลือก ชื่อ lancard ที่จะใส่ค่าไอพี -> จะขึ้นหน้าจอถามค่า IPV6 ตอบ NO -> หน้าจอถามว่าจะรับค่า DHCP หรือไม่ ถ้าไม่ตอบ NO -> จากนั้นจะขึ้นหน้าจอใส่ค่า host , domain ,ip gateway , dns , ip การ์ด , subnetmask ก็ใส่ให้ถูกต้องแล้วก็ OK -> จากนั้นจะกลับมาหน้า interface ใหม่ ให้ทำตามเดิมเลือกอีกการ์ดนึงนะครับ
หรือจะสั่งที่ command line เลยก็ได้ เช่น
ifconfig <ชื่อ interface> inet <เลขไอพี> netmask <เลข netmask> up แล้ว enter ตัวอย่างนะครับ ifconfig bge0 inet 203.185.98.99 netmask 255.255.255.248 up แบบนี้อะคับ ต้อง boot ใหม่ด้วย
แล้วลอง ifconfig ดู

เอาแบบ command line เลยครับง่ายดี

# ifconfig rl0 inet xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx
# ifconfig rl1 inet xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx

# ifconfig rl0 down / up
# ifconfig rl1 down / up

rl0 คือ ชื่อการ์ดแลนใบที่ 1
rl1 คือ ชื่อการ์ดแลนใบที่ 2

http://www.thaibsd.com/webboard/search.php?Category=thaibsd

วันพฤหัสบดีที่ 25 ธันวาคม พ.ศ. 2551

เพิ่ม HDD ใหม่ใน Linux

http://9max.icspace.net/readarticle.php?article_id=25
1. Shutdown เครื่อง
2. ต่อ HDD 4 G เข้าไปเป็นแบบ IDE กว่าจะไปหามาได้

[root@mail root]#
[root@mail root]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 1.8G 1.7G 42M 98% /
none 62M 0 61M 0% /dev/shm
[root@mail root]#
[root@mail root]#
[root@mail root]# fdisk -l (ดูว่า HDD ที่ต่อไว้เห็นหรือเปล่า )

Disk /dev/sda: 255 heads, 63 sectors, 275 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 242 1943833+ 83 Linux
/dev/sda2 243 275 265072+ 82 Linux swap
[root@mail root]#
[root@mail root]#

****** ทำไมไม่เห็น งั้น shutdown แล้ว ขยับสายใหม่อีกที

ลองอีกทีคำสั่งเดิม ....

[root@mail root]# fdisk -l

Disk /dev/sda: 255 heads, 63 sectors, 275 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 242 1943833+ 83 Linux
/dev/sda2 243 275 265072+ 82 Linux swap

Disk /dev/hdc: 128 heads, 63 sectors, 1023 cylinders
Units = cylinders of 8064 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hdc1 * 1 1022 4120672+ b Win95 FAT32
[root@mail root]#
[root@mail root]#

ว่าแล้ว สายหลวมจริงๆ ได้ แร๊ะ.... อิ..อิ...

[root@mail root]# fdisk (ลืมคำสั่ง เพื่อความชัวร์ ให้คำสั่งนี้)

Usage: fdisk [-l] [-b SSZ] [-u] device
E.g.: fdisk /dev/hda (for the first IDE disk)
or: fdisk /dev/sdc (for the third SCSI disk)
or: fdisk /dev/eda (for the first PS/2 ESDI drive)
or: fdisk /dev/rd/c0d0 or: fdisk /dev/ida/c0d0 (for RAID devices)
...
[root@mail root]#
ตามตัวอย่างเลย....
[root@mail root]# fdisk /dev/hdc (เข้าไปจัดการ HDD ตัวที่เอามาต่อได้เลย)

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): p (ดูซิ ว่าเป็นอะไรอยู่)

Disk /dev/hdc: 128 heads, 63 sectors, 1023 cylinders
Units = cylinders of 8064 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hdc1 * 1 1022 4120672+ b Win95 FAT32

Command (m for help): d (จัดการ ลบออกไปซะ)
Partition number (1-4): 1 (เลือกให้ถูก อันด้วยล่ะ)

Command (m for help): p (ดูอีกที ว่ายังอยู่อีก ป่ะ)

Disk /dev/hdc: 128 heads, 63 sectors, 1023 cylinders
Units = cylinders of 8064 * 512 bytes

Device Boot Start End Blocks Id System

Command (m for help): n (ถูกลบไปแร๊ะ สร้องใหม่ด้วย n )
Command action
e extended
p primary partition (1-4)
p (เลือก p)
Partition number (1-4): 1 (และ 1 )
First cylinder (1-1023, default 1): (Enter ได้เลย)
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1023, default 1023):
Using default value 1023

Command (m for help): p (ดูอีกที)

Disk /dev/hdc: 128 heads, 63 sectors, 1023 cylinders
Units = cylinders of 8064 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hdc1 1 1023 4124704+ 83 Linux

Command (m for help): w (อย่าลืมตัวนี้ด้วยไม่งั้นที่ทำมาก็ไม่มีผล)
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@mail root]# fdisk -l (ออกมาแล้วก็ชอบดู อีกแร๊ะ ได้ยัง)

Disk /dev/sda: 255 heads, 63 sectors, 275 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 242 1943833+ 83 Linux
/dev/sda2 243 275 265072+ 82 Linux swap

Disk /dev/hdc: 128 heads, 63 sectors, 1023 cylinders
Units = cylinders of 8064 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hdc1 1 1023 4124704+ 83 Linux
[root@mail root]# (ก็ได้เป็น Linux แล้วสมใจ)
[root@mail root]# mkfs -t ext3 -c /dev/hdc1 (ต้อง format ด้วยคำสั่งนี้)
mke2fs 1.27 (8-Mar-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
516096 inodes, 1031176 blocks
51558 blocks (5.00%) reserved for the super user
First data block=0
32 block groups
32768 blocks per group, 32768 fragments per group
16128 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Checking for bad blocks (read-only test): done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done (ช่วงนี้ตัวเลขวิ่งอยู่ ครู่ใหญ่ ตามขนาด HDD ล่ะ)

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@mail root]#
[root@mail root]#
[root@mail root]# mount (mount ดูยังไม่เห็น จะเอาไว้ไหนดีน้าาา)
/dev/sda1 on / type ext3 (rw)
none on /proc type proc (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw)
[root@mail root]# mkdir /data2 (สร้าง Folder ไว้ที่นี่ ก็แล้วกัน /data2)
[root@mail root]#
[root@mail root]# mount -t ext3 /dev/hdc1 /data2 (แล้วก็ mount มันไว้ที่นี่ล่ะ /data2)
[root@mail root]#
[root@mail root]# mount (ดู อีกแร๊ะ ได้ยัง)
/dev/sda1 on / type ext3 (rw)
none on /proc type proc (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw)
/dev/hdc1 on /data2 type ext3 (rw) <=== มาแย้ว นี่ไง
[root@mail root]#
[root@mail root]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 1.8G 1.7G 42M 98% /
none 62M 0 61M 0% /dev/shm
/dev/hdc1 3.9G 33M 3.6G 1% /data2
[root@mail root]#

เหมือนว่าจะเรียบร้อยแต่ยังไม่เรียบร้อยดี

ถ้า Reboot ใหม่ มันจะไม่ยอม Mount ให้ สามารถทำได้ 2 วิธีเท่าที่ผมรู้
1. เพิ่มที่ /etc/fstab (ไม่แน่ใจว่า รูปแบบการเพิ่มจะใส่ยังไงไม่กล้า เคยทำ ครั้งนึ่ง แล้ว Boot ไม่ได้เลย ใครพอแนะนำได้ก็เรียนเชิญครับ)
2. ตามด้านล่าง คล้าย Autoexec.bat ของ windows คนรุ่นเก่า

[root@mail root]#
[root@mail root]# vi /root/auto-mount-new-hdd
ข้างในใส่แต่นี้
mount -t ext3 /dev/hdc1 /data2

จากนั้น ต้อง chmod เพื่อให้มัน run ได้ด้วยโดย
[root@mail root]# chmod 755 auto-mount-new-hdd

ต่อไปก็เอาไปใส่ใน /etc/rc.local หรือ จริงๆ ก็มาเขียนไว้ที่นีเลยก็ได้นะ แล้วแต่
[root@mail root]#vi /etc/rc.local
เพิ่ม
/root/auto-mount-new-hdd

ก็ลอง reboot แล้วใช้คำสั่ง mount ดูว่า มัน mount ให้เราหรืเปล่า
โชคดีครับผม