天天看點

【主機】mount 建立磁盤到指定目錄

因為安裝資料庫,需要較大的磁盤容量,需要把一塊新磁盤挂載到/opt上

1 對磁盤做分區:

root@rac1:/root>fdisk /dev/sdb 

The number of cylinders for this disk is set to 182024.

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): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-182024, default 1): 

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-182024, default 182024): 

Using default value 182024

Command (m for help): p

Disk /dev/sdb: 1497.1 GB, 1497198755840 bytes

255 heads, 63 sectors/track, 182024 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1      182024  1462107748+  83  Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

2 建立ext3 檔案系統:

root@rac1:/root>mkfs.ext3 /dev/sdb1     

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

182763520 inodes, 365526937 blocks

18276346 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

11155 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, 20480000, 23887872, 71663616, 78675968, 

        102400000, 214990848

Writing inode tables: done                            

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

3 建立标簽

root@rac1:/root>e2label /dev/sdb1 /opt

root@rac1:/root>mount  /dev/sdb1 /opt

4 mount 到/opt (如果opt裡面有資料,則需要先做備份,mount之後,再拷貝到/opt目錄)

root@rac1:/root>df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda2             9.5G  3.0G  6.1G  33% /

/dev/sda3             4.8G  138M  4.4G   4% /tmp

/dev/sda6             255G   27G  215G  12% /home

/dev/sda1              99M   14M   80M  15% /boot

tmpfs                  12G     0   12G   0% /dev/shm

/dev/sdb1             1.4T  198M  1.3T   1% /opt

5 修改/etc/fstab 檔案

root@rac1:/root>vi /etc/fstab

LABEL=/                 /                       ext3    defaults        1 1

LABEL=/tmp              /tmp                    ext3    defaults        1 2

LABEL=/home             /home                   ext3    defaults        1 2

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

LABEL=SWAP-sda5         swap                    swap    defaults        0 0

LABEL=/opt              /opt                    ext3    defaults        1 2

"/etc/fstab" 11L, 761C written

測試:

root@rac1:/root>umount /opt/

root@rac1:/root>mount -a

root@rac1:/root>ls /opt/

lost+found

root@rac1:/root>