立即注册 找回密码

QQ登录

只需一步,快速开始

查看: 4366|回复: 0

[Linux主机系统教程] linux的VPS如何快速分区

[复制链接]
发表于 2015-4-15 22:29:32 | 显示全部楼层 |阅读模式
道勤网-数据www.daoqin.net

亲注册登录道勤网-可以查看更多帖子内容哦!(包涵精彩图片、文字详情等)请您及时注册登录-www.daoqin.net

您需要 登录 才可以下载或查看,没有账号?立即注册

x


>在新手购买购买的云vps,由于处于数据保护机制,都会给客户准备2块硬盘,一块用来存放用户数据,一块用来存放系统,这样在后台选择重做系统之后,另外一个磁盘分区的数据就不会丢失了..所以在购买VPS之后,要手动将另外一块硬盘激活,于是乎,就有了这个如何启用分区的教程:
通过fdisk -l我们可以看到/dev/xvdb(此名称因系统而异)容量有23.6G,
而且没有分区,接下来我们对它进行分区和挂载
fdisk -l

[root@MyVPS ~]# fdisk -lDisk /dev/xvda: 8589 MB, 8589934592 bytes255 heads, 63 sectors/track, 1044 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes    Device Boot      Start         End      Blocks   Id  System/dev/xvda1   *           1          13      104391   83  linux/dev/xvda2              14        1044     8281507+  8e  Linux LVMDisk /dev/xvdb: 23.6 GB, 23622320128 bytes255 heads, 63 sectors/track, 2871 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot      Start         End      Blocks   Id  System
  • [root@MyVPS ~]# fdisk -l
  • Disk /dev/xvda: 8589 MB, 8589934592 bytes
  • 255 heads, 63 sectors/track, 1044 cylinders
  • Units = cylinders of 16065 * 512 = 8225280 bytes
  • Device Boot Start End Blocks Id System
  • /dev/xvda1 * 1 13 104391 83 Linux
  • /dev/xvda2 14 1044 8281507+ 8e Linux LVM
  • Disk /dev/xvdb: 23.6 GB, 23622320128 bytes
  • 255 heads, 63 sectors/track, 2871 cylinders
  • Units = cylinders of 16065 * 512 = 8225280 bytes
  • Device Boot Start End Blocks Id System

对/dev/xvdb(此名称因系统而异)进行分区:
fdisk /dev/xvdb

[root@MyVPS ~]# fdisk /dev/xvdbThe number of cylinders for this disk is set to 2871.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)输入n新建分区Command (m for help): nCommand action   e   extended   p   primary partition (1-4)p/dev/xvdb中第1个分区Partition number (1-4): 1First cylinder (1-2871, default 1):Using default value 1Last cylinder or +size or +sizeM or +sizeK (1-2871, default 2871):Using default value 2871输入W保存退出Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.
  • [root@MyVPS ~]# fdisk /dev/xvdb
  • The number of cylinders for this disk is set to 2871.
  • 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)
  • 输入n新建分区
  • Command (m for help): n
  • Command action
  • e extended
  • p primary partition (1-4)
  • p
  • /dev/xvdb中第1个分区
  • Partition number (1-4): 1
  • First cylinder (1-2871, default 1):
  • Using default value 1
  • Last cylinder or +size or +sizeM or +sizeK (1-2871, default 2871):
  • Using default value 2871
  • 输入W保存退出
  • Command (m for help): w
  • The partition table has been altered!
  • Calling ioctl() to re-read partition table.
  • Syncing disks.


将新分区xvdb1(此名称因系统而异)格式化为ext3格式


mkfs -t ext3 /dev/xvdb1

[root@MyVPS ~]# mkfs -t ext3 /dev/xvdb1mke2fs 1.39 (29-May-2006)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)2883584 inodes, 5765319 blocks288265 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=4294967296176 block groups32768 blocks per group, 32768 fragments per group16384 inodes per groupSuperblock backups stored on blocks:        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,        4096000Writing inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 24 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.
  • [root@MyVPS ~]# mkfs -t ext3 /dev/xvdb1
  • mke2fs 1.39 (29-May-2006)
  • Filesystem label=
  • OS type: Linux
  • Block size=4096 (log=2)
  • Fragment size=4096 (log=2)
  • 2883584 inodes, 5765319 blocks
  • 288265 blocks (5.00%) reserved for the super user
  • First data block=0
  • Maximum filesystem blocks=4294967296
  • 176 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,
  • 4096000
  • Writing inode tables: done
  • Creating journal (32768 blocks): done
  • Writing superblocks and filesystem accounting information: done
  • This filesystem will be automatically checked every 24 mounts or
  • 180 days, whichever comes first. Use tune2fs -c or -i to override.


我们示范将新分区xvdb1挂载到目录/home
因为home已经存在,所以我们挂载
mount /dev/xvdb1 /home
如果你需要挂载在别的目录.可以新建一个目录挂载.如:home1,使用如下命令:
mkdir /home1 mount /dev/xvdb1 /home1
完成后我们通过df -hal可以看到,新分区已经挂载到目录/home上了

    [root@MyVPS ~]# df -hal    Filesystem            Size  Used Avail Use% Mounted on    /dev/mapper/VolGroup00-LogVol00                          5.7G  1.4G  4.1G  25% /    proc                     0     0     0   -  /proc    sysfs                    0     0     0   -  /sys    devpts                   0     0     0   -  /dev/pts    /dev/xvda1             99M   28M   67M  30% /boot    tmpfs                 256M     0  256M   0% /dev/shm    none                     0     0     0   -  /proc/sys/fs/binfmt_misc    sunrpc                   0     0     0   -  /var/lib/nfs/rpc_pipefs    /dev/xvdb1             22G  173M   21G   1% /home
  • [root@MyVPS ~]# df -hal
  • Filesystem Size Used Avail Use% Mounted on
  • /dev/mapper/VolGroup00-LogVol00
  • 5.7G 1.4G 4.1G 25% /
  • proc 0 0 0 - /proc
  • sysfs 0 0 0 - /sys
  • devpts 0 0 0 - /dev/pts
  • /dev/xvda1 99M 28M 67M 30% /boot
  • tmpfs 256M 0 256M 0% /dev/shm
  • none 0 0 0 - /proc/sys/fs/binfmt_misc
  • sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs
  • /dev/xvdb1 22G 173M 21G 1% /home


最后添加开机自动挂载:

echo "/dev/xvdb1 /home ext3 defaults 1 2" >> /etc/fstab
这样就完成了!
通过后台控制系统重做系统之后,只需要重新挂载一次即可
mount /dev/xvdb1 /home
最后,重新添加自动挂载即可:
echo "/dev/xvdb1 /home ext3 defaults 1 2" >> /etc/fstab


道勤主机提供365天*24小时全年全天无休、实时在线、零等待的售后技术支持。竭力为您免费处理您在使用道勤主机过程中所遇到的一切问题! 如果您是道勤主机用户,那么您可以通过QQ【792472177】、售后QQ【59133755】、旺旺【诠释意念】、微信:q792472177免费电话、后台提交工单这些方式联系道勤主机客服! 如果您不是我们的客户也没问题,点击页面最右边的企业QQ在线咨询图标联系我们并购买后,我们为您免费进行无缝搬家服务,让您享受网站零访问延迟的迁移到道勤主机的服务!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

道勤网- 推荐内容!上一条 /2 下一条

!jz_fbzt! !jz_sgzt! !jz_xgzt! 快速回复 !jz_fhlb! !jz_lxwm! !jz_gfqqq!

关于我们|手机版|小黑屋|地图|【道勤网】-www.daoqin.net 软件视频自学教程|免费教程|自学电脑|3D教程|平面教程|影视动画教程|办公教程|机械设计教程|网站设计教程 ( 皖ICP备15000319号-1 )

GMT+8, 2024-12-20 19:26

Powered by DaoQin! X3.4 © 2016-2063 Dao Qin & 道勤科技

快速回复 返回顶部 返回列表