LINUX 云服务器分区挂载

新腾讯云服务器,这台有一块800G的数据盘要挂载到指定的/data目录下但是因为没有挂载,所以用df -h还看不出来:
[root@VM_50_115_centos ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        20G  1.2G   18G   7% /

先用fdisk -l查看数据盘信息:
[root@VM_50_115_centos data]# fdisk -l

Disk /dev/vda: 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: 0x000736d7

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

Disk /dev/vdb: 859.0 GB, 858993459200 bytes                //这就是需要挂载的数据盘/dev/vdb
16 heads, 63 sectors/track, 1664406 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

下面我们就用fdisk /dev/vdb对/dev/vdb实施分区:
[root@VM_50_115_centos data]# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x20564baf.
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
First cylinder (1-1664406, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1664406, default 1664406):
Using default value 1664406

Command (m for help): wq
The partition table has been altered!

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

分区完成后再次查看数据盘信息:
[root@VM_50_115_centos data]# fdisk -l

Disk /dev/vda: 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: 0x000736d7

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

Disk /dev/vdb: 859.0 GB, 858993459200 bytes
16 heads, 63 sectors/track, 1664406 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x20564baf

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1     1664406   838860592+  83  Linux                //这里多了一个/dev/vdb1就是上面分好的区

接着对这个/dev/vdb1新区格式化就行(格式化的时候不进行任何操作,直到页面自动停止到如下位置):
mkfs -t ext3 /dev/vdb1
[root@VM_50_115_centos data]# mkfs -t ext3 /dev/vdb1
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
52428800 inodes, 209715148 blocks
10485757 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
6400 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, 71663616, 78675968,
    102400000

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

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

接着创建指定的挂载目录/data:
mkdir /data
把数据盘/vdb1挂载到/data目录
mount /dev/vdb1 /data
最后设置开机自动挂载(插入最后一行即可):
vim /etc/fstab
/dev/vda1            /                    ext3       noatime,acl,user_xattr 1 1
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
/dev/vdb1            /data                ext3       defaults              1 0
~                                                                               

 

以下为具体操作步骤:

fdisk -l        查看数据盘信息
fdisk /dev/vdb        分区时先后输入 n p 1 空格 空格 wq
fdisk -l        再次查看数据盘信息
mkfs -t ext3 /dev/vdb1    格式化
mkdir /data        创建挂载目录
mount /dev/vdb1 /data    把数据盘/vdb1挂载到/data目录
vim /etc/fstab         设置开启自动挂载(/dev/vdb1 /data ext3 defaults 1 0)

 

 

 

你可能感兴趣的:(系统)