<h2 style="color:#444444;font-family:微软雅黑, 'Microsoft Yahei', Tahoma, SimHei, Verdana, Arial, sans-serif;font-size:14px;text-align:center;background-color:#FFFFFF;">

<span style="font-family:'Microsoft YaHei';font-size:14px;color:#E56600;"><span style="font-family:'Microsoft YaHei';font-size:14px;color:#E56600;"><span style="font-family:'Microsoft YaHei';font-size:14px;color:#E56600;"><span style="font-weight:700;font-family:'Microsoft YaHei';font-size:14px;color:#E56600;"><span style="font-size:18px;">举例把数据盘挂载到/home&nbsp;目录,</span><span style="color:#E53333;font-size:18px;">如果/home目录已有数据,请先备份到其他位置!!</span></span></span></span></span>

</h2>
<p style="color:#444444;font-family:微软雅黑, 'Microsoft Yahei', Tahoma, SimHei, Verdana, Arial, sans-serif;font-size:14px;background-color:#FFFFFF;">

<span></span> 

</p>
<h3 style="color:#444444;font-family:微软雅黑, 'Microsoft Yahei', Tahoma, SimHei, Verdana, Arial, sans-serif;font-size:14px;background-color:#FFFFFF;">

<span><span><span><span style="font-weight:700;"><span style="font-family:'Microsoft YaHei';font-size:14px;">通过fdisk -l我们可以看到/dev/xvdb(此名称因系统而异)容量有23.6G,而且没有分区,接下来我们对它进行分区和挂载</span></span></span></span></span>

</h3>
<p>

<br />

</p>
<p>

<span><span><span><span style="font-weight:700;"><span style="font-family:'Microsoft YaHei';font-size:14px;"> </span></span></span></span></span> 

</p>

fdisk -l

<p>
</p> <span style="background-color:#FFFFFF;"><span><span>

<span><span style="font-family:'Microsoft YaHei';font-size:14px;">[root@MyVPS ~]# </span><span style="font-weight:700;font-family:'Microsoft YaHei';font-size:14px;">fdisk -l</span></span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">Disk /dev/xvda: 8589 MB, 8589934592 bytes</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> 255 heads, 63 sectors/track, 1044 cylinders</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> Units = cylinders of 16065 * 512 = 8225280 bytes</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">     Device Boot      Start         End      Blocks   Id  System</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> /dev/xvda1   *           1          13      104391   83  Linux</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> /dev/xvda2              14        1044     8281507+  8e  Linux LVM</span>

<span style="font-family:'Microsoft YaHei';font-size:14px;"> Disk /dev/xvdb: 23.6 GB, 23622320128 bytes</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> 255 heads, 63 sectors/track, 2871 cylinders</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> Units = cylinders of 16065 * 512 = 8225280 bytes</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> Device Boot      Start         End      Blocks   Id  System</span>

</span></span>

</span>
<p style="color:#444444;font-family:微软雅黑, 'Microsoft Yahei', Tahoma, SimHei, Verdana, Arial, sans-serif;font-size:14px;background-color:#FFFFFF;">

<span style="font-family:'Microsoft YaHei';font-weight:700;line-height:1.5;">对/dev/xvdb(此名称因系统而异)进行分区:</span>

</p>
<p>

<span><span><span><span style="font-weight:700;"><span style="font-family:'Microsoft YaHei';font-size:14px;"> </span></span></span></span></span> 

</p>

fdisk /dev/xvdb
<span style="background-color:#FFFFFF;"><span><span>

<span><span style="font-family:'Microsoft YaHei';font-size:14px;">[root@MyVPS ~]# </span><span style="font-weight:700;font-family:'Microsoft YaHei';font-size:14px;">fdisk /dev/xvdb</span></span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">The number of cylinders for this disk is set to 2871.</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">There is nothing wrong with that, but this is larger than 1024,</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">and could in certain setups cause problems with:</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">1) software that runs at boot time (e.g., old versions of LILO)</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">2) booting and partitioning software from other OSs</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">   (e.g., DOS FDISK, OS/2 FDISK)</span>

<span style="font-weight:700;font-family:'Microsoft YaHei';font-size:14px;">输入n新建分区</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">Command (m for help): </span><span style="font-weight:700;"><span style="font-family:'Microsoft YaHei';font-size:14px;">n</span>
</span><span style="font-family:'Microsoft YaHei';font-size:14px;">Command action</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">   e   extended</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">   p   primary partition (1-4)</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">p</span>

<span style="font-weight:700;font-family:'Microsoft YaHei';font-size:14px;">/dev/xvdb中第1个分区</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">Partition number (1-4): </span><span style="font-weight:700;font-family:'Microsoft YaHei';font-size:14px;">1</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">First cylinder (1-2871, default 1):</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">Using default value 1</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">Last cylinder or +size or +sizeM or +sizeK (1-2871, default 2871):</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">Using default value 2871</span>

<span style="font-weight:700;font-family:'Microsoft YaHei';font-size:14px;">输入W保存退出</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">Command (m for help): </span><span style="font-weight:700;font-family:'Microsoft YaHei';font-size:14px;">w</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">The partition table has been altered!</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">Calling ioctl() to re-read partition table.</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">Syncing disks.</span>

</span></span></span>
<p style="color:#444444;font-family:微软雅黑, 'Microsoft Yahei', Tahoma, SimHei, Verdana, Arial, sans-serif;font-size:14px;background-color:#FFFFFF;">

<span style="font-family:'Microsoft YaHei';font-weight:700;line-height:1.5;">将新分区xvdb1(此名称因系统而异)格式化为ext4格式</span>

</p>
<p>

<span><span><span><span style="font-weight:700;font-family:'Microsoft YaHei';font-size:14px;"> </span></span></span></span> 

</p>

mkfs -t ext4 /dev/xvdb1
<span style="background-color:#FFFFFF;"><span><span><span>

<span style="font-family:'Microsoft YaHei';font-size:14px;"> [root@MyVPS ~]# </span><span style="font-weight:700;"><span style="font-family:'Microsoft YaHei';font-size:14px;">mkfs -t ext4 /dev/xvdb1</span>
</span><span style="font-family:'Microsoft YaHei';font-size:14px;">mke2fs 1.39 (29-May-2006)</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> Filesystem label=</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> OS type: Linux</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> Block size=4096 (log=2)</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> Fragment size=4096 (log=2)</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> 2883584 inodes, 5765319 blocks</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> 288265 blocks (5.00%) reserved for the super user</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> First data block=0</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> Maximum filesystem blocks=4294967296</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> 176 block groups</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> 32768 blocks per group, 32768 fragments per group</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> 16384 inodes per group</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> Superblock backups stored on blocks:</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">         32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">         4096000</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> Writing inode tables: done</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> Creating journal (32768 blocks): done</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> Writing superblocks and filesystem accounting information: done</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> This filesystem will be automatically checked every 24 mounts or</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> 180 days, whichever comes first.  Use tune2fs -c or -i to override.</span>

</span></span></span>

</span>
<p style="color:#444444;font-family:微软雅黑, 'Microsoft Yahei', Tahoma, SimHei, Verdana, Arial, sans-serif;font-size:14px;background-color:#FFFFFF;">

<span style="font-family:'Microsoft YaHei';font-weight:700;line-height:1.5;">我们示范将新分区xvdb1挂载到目录/home</span>

</p>
<p>

<br />

</p>

mount /dev/xvdb1 /home
<p>
</p> <p style="color:#444444;font-family:微软雅黑, 'Microsoft Yahei', Tahoma, SimHei, Verdana, Arial, sans-serif;font-size:14px;background-color:#FFFFFF;"> <span><span><span> <span style="font-weight:700;"><span style="font-family:'Microsoft YaHei';font-size:14px;">完成后我们通过df -hal可以看到,新分区已经挂载到目录/home1上了</span>
</span></span></span></span> </p> <span style="background-color:#FFFFFF;"><span><span><span>

<span style="font-family:'Microsoft YaHei';font-size:14px;"> [root@MyVPS ~]# </span><span style="font-weight:700;"><span style="font-family:'Microsoft YaHei';font-size:14px;">df -hal</span>
</span><span style="font-family:'Microsoft YaHei';font-size:14px;">Filesystem            Size  Used Avail Use% Mounted on</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> /dev/mapper/VolGroup00-LogVol00</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;">                       5.7G  1.4G  4.1G  25% /</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> proc                     0     0     0   -  /proc</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> sysfs                    0     0     0   -  /sys</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> devpts                   0     0     0   -  /dev/pts</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> /dev/xvda1             99M   28M   67M  30% /boot</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> tmpfs                 256M     0  256M   0% /dev/shm</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> none                     0     0     0   -  /proc/sys/fs/binfmt_misc</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> sunrpc                   0     0     0   -  /var/lib/nfs/rpc_pipefs</span>
<span style="font-family:'Microsoft YaHei';font-size:14px;"> /dev/xvdb1             22G  173M   21G   1% /data</span>

</span></span></span>

</span>
<p style="color:#444444;font-family:微软雅黑, 'Microsoft Yahei', Tahoma, SimHei, Verdana, Arial, sans-serif;font-size:14px;background-color:#FFFFFF;">

<span><span><span><span style="font-family:'Microsoft YaHei';font-size:14px;">最后添加开机自动挂载:</span></span></span></span> 

</p>

echo "/dev/xvdb1 /home ext4 defaults 1 2" >> /etc/fstab
<p> <span style="font-family:'Microsoft YaHei';font-size:14px;color:#444444;line-height:1.5;background-color:#FFFFFF;">这样就完成了!</span> </p> <p> <span style="font-family:'Microsoft YaHei';font-size:14px;font-weight:700;line-height:1.5;background-color:#FFFFFF;">通过面板重装后的处理</span> </p> <p> <span style="background-color:#FFFFFF;"><span style="font-weight:700;font-family:'Microsoft YaHei';"></span></span> </p>
<span style="font-size:14px;">重新挂载,xvdb1的文件内容不受影响 mkdir /data mount /dev/xvdb1 /data </span>
<span style="line-height:1.5;font-size:14px;">最后,重新添加自动挂载即可: echo "/dev/xvdb1 /data ext3 defaults 1 2" >> /etc/fstab</span>



<p>

<br />

</p>
<span style="background-color:#FFFFFF;"><span><span> </span></span></span>

Last modification:December 13th, 2017 at 11:43 pm