购买LINUX系统VPS及云主机产品后的空间挂载方法

2013-12-05  人阅读

2013-12-05  人阅读

购买LINUX系统VPS及云主机产品后,由于用户选择的空间大小不同,后台云存储分配的实际存储盘符也会发生相应的变化,所以这时候需要用户自行做挂载处理,处理步骤如下(//以及后面的都是注释,不用输入):

1、  查看新硬盘:

[root@~]# df -h                 //检查当前挂载磁盘

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda3              14G  3.4G  9.4G  27% /

/dev/sda1              99M   12M   83M  13% /boot

tmpfs                 252M     0  252M   0% /dev/shm

[root@~]#

[root@~]# fdisk -l             //检查当前分区,下面红色的sbd是没有分区的,需要下一步操作

Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14         144     1052257+  82  Linux swap / Solaris

/dev/sda3             145        1958    14570955   83  Linux


Disk /dev/sdb: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


Disk /dev/sdb doesn’t contain a valid partition table

[root@~]#

这时会看到有16G的sdb(Disk /dev/sdb: 16.1 GB)没有分配,可以按照下面的方法继续分配,由于实际分配的不一定是sdb(有可能是hdc或hdd等),下面的操作都是以系统显示为sdb来做下面的操作。

2、  对sdb做分区:

[root@ ~]# fdisk  /dev/sdb           //对sdb做分区

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won’t be recoverable.

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

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)

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n          //继续下一步输入n

Command action

  e   extended

  p   primary partition (1-4)p              //输入p

Partition number (1-4):             //输入1

First cylinder (1-1958, default 1):              //回车

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-1958, default 1958):                   //回车

Using default value 1958


Command (m for help): w                 //输入w

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.

You have mail in /var/spool/mail/root

[root@ ~]#


3、  格式化:

[root@ ~]# fdisk -l      //确认刚分区的是否存在(下面红色部分就是我们刚分区并要继续格式化的磁盘点)

Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


  Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14         144     1052257+  82  Linux swap / Solaris

/dev/sda3             145        1958    14570955   83  Linux


Disk /dev/sdb: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


  Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        1958    15727603+  83  Linux

[root@ ~]#

[root@~]# mkfs.ext3 /dev/sdb1              //格式化sdb1

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

1966080 inodes, 3931900 blocks

196595 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4026531840

120 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

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.

[root@~]#


4、  挂载分区:

[root@~]# mkdir /user1                                      //创建需要挂载的分区目录,可以自定义

[root@~]# mount /dev/sdb1 /user1/               //挂载刚创建的目录

[root@~]# df -h                                                      //确定是否挂载成功,和第一步比较

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda3              14G  3.5G  9.4G  27% /

/dev/sda1              99M   12M   83M  13% /boot

tmpfs                 252M     0  252M   0% /dev/shm

/dev/sdb1              15G  166M   14G   2% /user1

[root@~]#


5、  配置自动挂载(重启服务器会后自动加载上):

[root@ ~]# cat /etc/fstab                   //查看当前加载情况

LABEL=/                 /                       ext3    defaults        1 1

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-sda2         swap                    swap    defaults        0 0

[root@ ~]#vi /etc/fstab           //编辑fatab文件并加入下面一行

/dev/sdb1             /user1                   ext3     defaults,noatime         0 0

[root@SZNC-DB-4120 ~]# cat /etc/fstab                 //确认是否已加入(红色部分)

LABEL=/                 /                       ext3    defaults        1 1

LABEL=/boot             /boot                   ext3    defaults        1 2


/dev/sdb1             /user1                   ext3     defaults,noatime         0 0

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-sda2         swap                    swap    defaults        0 0

[root@SZNC-DB-4120 ~]#



返回列表页  

Copyright©2011-2024 北京富源汇丰科技有限公司 版权所有 北京市东城区东直门外东中街32号楼五层

京ICP备11039801号-3京公网安备11010102000564号

金寨县在外北京创业者协会

  • 企业微信

  • 售前咨询

Copyright©2011-2024
北京富源汇丰科技有限公司 版权所有

京ICP备11039801号-3京公网安备11010102000564号