2010/03/16

[ LOS ] CentOS Linux Format/Mount Etx3 Partition

如何在 CentOS Linux 上掛載一顆 etx3 格式的硬碟 ? 為何要掛載這顆硬碟 ? 主要是當備份碟每天零晨可以使用 crontab+shellscript 自動備份資料 , 當做普通重要資料還原用 , 沒錢買好的硬體RAID只好用這最省錢的方式。


1. 查看有哪些硬碟掛在機器上
  
# fdisk -l   #除了系統主硬碟 hda 40G外我已經多放了 hdc 第二顆3G大小的硬碟

Disk /dev/hda: 41.1 GB, 41171288064 bytes
255 heads, 63 sectors/track, 5005 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        5005    40098240   8e  Linux LVM

Disk /dev/hdc: 3228 MB, 3228696576 bytes
128 heads, 63 sectors/track, 782 cylinders
Units = cylinders of 8064 * 512 = 4128768 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1   *           1         782     3152992+   b  W95 FAT32

2. 硬碟 partition 規劃

# fdisk /dev/hdc   #使用 fdisk 工具切割規劃 hdc 這顆硬碟

Command (m for help): d   #刪除 hdc1 partition

Command (m for help): n    #新增 hdc1 partition
Command action
   e   extended
   p   primary partition (1-4)  p # 打入p規劃為 primary 格式

Partition number (1-4): 1   # 因為欲規劃為 hdc1 所以選擇編號1
First cylinder (1-782, default 1):   # 開始的磁區default >> Enter
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-782, default 782): # 結束的磁區default >> Enter
Using default value 782

Command (m for help): w   # 將剛剛的規劃 save
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

# fdisk -l   # 再次查看
Disk /dev/hdc: 3228 MB, 3228696576 bytes
128 heads, 63 sectors/track, 782 cylinders
Units = cylinders of 8064 * 512 = 4128768 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1               1         782     3152992+  83  Linux

3. Format 硬碟

# mkfs.ext3 /dev/hdc1   # 將 partition 格式化為 linux ext3 檔案系統格式
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
394400 inodes, 788248 blocks
39412 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=809500672
25 block groups
32768 blocks per group, 32768 fragments per group
15776 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

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

# mkdir /disk2    # 建立 disk2 掛載資料夾
# mount /disk2   # 手動掛載資料夾

# df  # 查看 disk2 是否掛上
檔案系統               1K-區段      已用     可用 已用% 掛載點
/dev/mapper/VolGroup00-LogVol00
                      37803504   1830008  34022164   6% /
/dev/hda1               101086     18863     77004  20% /boot
tmpfs                   257668         0    257668   0% /dev/shm
/dev/hdc1              3103444     70240   2875556   3% /disk2

# umount /disk2    # 卸載 disk2

# vi /etc/fstab   # 加入開機自動掛載 hdc1
/dev/hdc1               /disk2                    ext3    defaults        1 1

0 意見: