天天看點

ubuntu 12.04 server 挂載硬碟

買的虛拟機添加硬碟需要手動挂載,下面列下簡單步驟,作為記錄:

1、檢視下目前檔案系統

# df

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/vda1 8254240 1099340 6735608 15% /

隻有一個/dev/vda1挂在了根下邊,也就是系統軟體裝在這裡

2、檢視下目前硬碟情況

# fdisk -l

Disk /dev/vda: 8589 MB, 8589901824 bytes

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xcd6e8236

Device Boot Start End Blocks Id System

/dev/vda1 * 1 1044 8385898+ 83 Linux

Disk /dev/vdb: 268.4 GB, 268435456000 bytes

16 heads, 63 sectors/track, 520126 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk /dev/vdb doesn't contain a valid partition table

Disk /dev/vdc: 2147 MB, 2147483648 bytes

16 heads, 63 sectors/track, 4161 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk /dev/vdc doesn't contain a valid partition table

看到一個盤,/dev/vdb,270G。現在格式化下。

3、格式化

# mkfs -t ext4 /dev/vdb

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

16384000 inodes, 65536000 blocks

3276800 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

2000 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or

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

-t 是指分區類型 這裡用ext4

4、把磁盤挂載到 /edx

mount /dev/vdb /edx

# df

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/vda1 8254240 1099384 6735564 15% /

/dev/vdb 258030980 191708 244732072 1% /edx

5、設定開機自動挂載

vim /etc/fstab

添加一條

/dev/vdb /edx ext4 noatime,acl,user_xattr 1 0

(fstab的檔案格式,以後記錄)