linux掛載新硬碟

來源:互聯網
上載者:User

標籤:des   style   color   os   io   使用   strong   ar   for   

  註:紅色部分表示相關命令1、查看資料盤  在沒有分區和格式化資料盤之前,使用 “df –h”命令,是無法看到資料盤的,可以使用“fdisk -l”命令查看  #df -h     Filesystem Size Used Avail Use% Mounted on    /dev/xvda1 20G 1.4G 18G 8% /      tmpfs 498M 0 498M 0% /dev/shm     #fdisk -l

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00060953

Device Boot Start End Blocks Id System
/dev/xvda1 * 1 2611 20970496 83 Linux

Disk /dev/xvdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x00000000

如果沒有就不用掛載了。

2、 對資料盤進行分區執行“fdisk -S 56 /dev/xvdb”命令,對資料盤進行分區;根據提示,依次輸入“n”,“p”“1”,兩次斷行符號,“wq”,分區就開始了,很快就會完成。

#fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xb419e799.
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)

WARNING: DOS-compatible mode is deprecated. It‘s strongly recommended to
switch off the mode (command ‘c‘) and change display units to
sectors (command ‘u‘).

Command (m for help):    n

Command action

  e extended

  p primary partition (1-4)

p

Partition number(1-4): 1 //這裡說明下,這裡真寫的是分區號,預設直接按1 Enter

First cylinder(1-6527,default 1):  //Enter

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} {1-6527, default 6527): //Enter

Using default value 6527

Command (m for help):  wq

3、 查看新的分區使用“fdisk -l”命令可以看到,新的分區xvdb1已經建立完成了。#fdisk -l

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00060953

Device Boot Start End Blocks Id System
/dev/xvda1 * 1 2611 20970496 83 Linux

Disk /dev/xvdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x85df9f2e

Device Boot Start End Blocks Id System
/dev/xvdb1 1 6527 52428096 83 Linux

4、格式化新分區

使用“mkfs.ext3 /dev/xvdb1”命令對新分區進行格式化,格式化的時間根據硬碟大小有所不同。#mkfs.ext3 /dev/xvdb1

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
3276800 inodes, 13107024 blocks
655351 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 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

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

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

5、添加分區資訊 #echo ‘/dev/xvdb1  /mnt ext3    defaults    0  0‘ >> /etc/fstab然後查看寫入是否成功。#cat /etc/fstab


#
# /etc/fstab
# Created by anaconda on Thu Jul 3 10:43:14 2014
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=2a348234-4a73-491c-98e9-47900d88697b / ext4 defaults,barrier=0 1 1
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
none /proc/xen xenfs defaults 0 0
/dev/xvdb1 /mnt ext3 defaults 0 0

6、掛載新分區使用“mount -a”命令掛載新分區#mount -a     然後查看是否掛載成功#df -h

Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 1.7G 18G 9% /
tmpfs 498M 0 498M 0% /dev/shm
/dev/xvdb1 50G 180M 47G 1% /mnt

完成。

linux掛載新硬碟

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.