因為網路上的文章大多不合初學的朋友.
於是自己整理了一下,希望大家一同研究研究.
(也為自己保存一份筆記 ^^)
我是在 VMESXI 5.1 上 , CentOS 5.8 及 6.3 測試
1) 磁碟分割:
開機完後,首先如何知道剛剛新加入的硬碟有被 CentOS 抓到呢?
可以使用 fdisk -l 指令來查看目前硬碟的狀況。
# fdisk -l
Disk /dev/sda: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2088 16667437+ 8e Linux LVM
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
其中可以看到 Disk /dev/sdb: 4294 MB, 4294967296 bytes 就是我們剛加入的硬碟,
目前還沒有分割任何的磁區,所以我們就開始分割吧。
# fdisk /dev/sdb
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.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
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/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
我這直接將它切割為單一個主磁區,分割完後,可以再透過 fdisk -l 確認一次。
# fdisk -l
Disk /dev/sda: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2088 16667437+ 8e Linux LVM
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
2) 格式化磁碟:
再來就是使用 mkfs.ext3 對剛切出來的 /dev/sdb 進行格式化。
# mkfs.ext3 /dev/sdb
mke2fs 1.39 (29-May-2006)
/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)
524288 inodes, 1048576 blocks
52428 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
三) 自動開機掛載:
先在 / 下建立 disk2 資料夾,供掛載 /dev/sdb 使用。
# mkdir /disk2
修改開機自動掛載設定檔 /etc/fstab
把 "/dev/sdb /disk2 ext3 defaults 1 2 " 加入檔案的最後一行
如下面的例子:
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
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
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/dev/sdb /disk2 ext3 defaults 1 2
透過 mount -a 方式直接重新掛載。
# mount -a
# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sdb on /disk2 type ext3 (rw)
最後再透過 df 指令確認是不是已經掛載成功。
# df
檔案系統 1K-區段 已用 可用 已用% 掛載點
/dev/mapper/VolGroup00-LogVol00
14378704 4053196 9583316 30% /
/dev/sda1 101086 23608 72259 25% /boot
tmpfs 449552 0 449552 0% /dev/shm
/dev/sdb 4128448 139392 3779344 4% /disk2
祝:大福
友:小漢上
2012年11月15日 星期四
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言