Linux VPS新硬盘分区与挂载教程(面板重装不丢失数据)

林继 VPS 知识 2,932 共写了688个字 (2012-03-16 22:34:25) 没有评论 打印 扫描二维码 百度已收录

通过fdisk -l我们可以看到/dev/xvdb(此名称因系统而异)容量有23.6G,而且没有分区,接下来我们对它进行分区和挂载

  1. fdisk -l
  1. [root@MyVPS ~]# fdisk -l
  2. Disk /dev/xvda: 8589 MB, 8589934592 bytes
  3. 255 heads, 63 sectors/track, 1044 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5.     Device Boot      Start         End      Blocks   Id  System
  6. /dev/xvda1   *           1          13      104391   83  Linux
  7. /dev/xvda2              14        1044     8281507+  8e  Linux LVM
  8.  
  9. Disk /dev/xvdb: 23.6 GB, 23622320128 bytes
  10. 255 heads, 63 sectors/track, 2871 cylinders
  11. Units = cylinders of 16065 * 512 = 8225280 bytes
  12. Device Boot      Start         End      Blocks   Id  System

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

  1. fdisk /dev/xvdb
  1. [root@MyVPS ~]# fdisk /dev/xvdb
  2. The number of cylinders for this disk is set to 2871.
  3. There is nothing wrong with that, but this is larger than 1024,
  4. and could in certain setups cause problems with:
  5. 1) software that runs at boot time (e.g., old versions of LILO)
  6. 2) booting and partitioning software from other OSs
  7.    (e.g., DOS FDISK, OS/2 FDISK)

输入n新建分区
Command (m for help): n

  1. Command action
  2.    e   extended
  3.    p   primary partition (1-4)
  4. p
  5.  
  6. /dev/xvdb中第1个分区
  7. Partition number (1-4): 1
  8. First cylinder (1-2871, default 1):
  9. Using default value 1
  10. Last cylinder or +size or +sizeM or +sizeK (1-2871, default 2871):
  11. Using default value 2871

输入W保存退出

  1. Command (m for help): w
  2. The partition table has been altered!
  3. Calling ioctl() to re-read partition table.
  4. Syncing disks.

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

  1. mkfs -t ext3 /dev/xvdb1
  1. [root@MyVPS ~]# mkfs -t ext3 /dev/xvdb1
  2. mke2fs 1.39 (29-May-2006)
  3. Filesystem label=
  4. OS type: Linux
  5. Block size=4096 (log=2)
  6. Fragment size=4096 (log=2)
  7. 2883584 inodes, 5765319 blocks
  8. 288265 blocks (5.00%) reserved for the super user
  9. First data block=0
  10. Maximum filesystem blocks=4294967296
  11. 176 block groups
  12. 32768 blocks per group, 32768 fragments per group
  13. 16384 inodes per group
  14. Superblock backups stored on blocks:
  15.         32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
  16.         4096000
  17. Writing inode tables: done
  18. Creating journal (32768 blocks): done
  19. Writing superblocks and filesystem accounting information: done
  20. This filesystem will be automatically checked every 24 mounts or
  21. 180 days, whichever comes first.  Use tune2fs -c or -i to override.

我们示范将新分区xvdb1挂载到目录/home1
新建目录/home1,然后挂载

  1. mkdir /home1
  2. mount /dev/xvdb1 /home1

完成后我们通过df -hal可以看到,新分区已经挂载到目录/home1上了

  1. [root@MyVPS ~]# df -hal
  2. Filesystem            Size  Used Avail Use% Mounted on
  3. /dev/mapper/VolGroup00-LogVol00
  4.                       5.7G  1.4G  4.1G  25% /
  5. proc                     0     0     0   -  /proc
  6. sysfs                    0     0     0   -  /sys
  7. devpts                   0     0     0   -  /dev/pts
  8. /dev/xvda1             99M   28M   67M  30% /boot
  9. tmpfs                 256M     0  256M   0% /dev/shm
  10. none                     0     0     0   -  /proc/sys/fs/binfmt_misc
  11. sunrpc                   0     0     0   -  /var/lib/nfs/rpc_pipefs
  12. /dev/xvdb1             22G  173M   21G   1% /home1

最后添加开机自动挂载:

  1. echo "/dev/xvdb1 /home1 ext3 defaults 1 2" >> /etc/fstab

这样就完成了!

通过XenSystem面板重装后的处理

重新建立目录/home1,然后重新挂载,xvdb1的文件内容不受影响

  1. mkdir /home1
  2. mount /dev/xvdb1 /home1

最后,重新添加自动挂载即可:

  1. echo "/dev/xvdb1 /home1 ext3 defaults 1 2" >> /etc/fstab

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

< >