linux的VPS如何分区
1.fdisk -l
01.[root@MyVPS ~]# fdisk -l02.Disk /dev/xvda: 8589 MB, 8589934592 bytes03.255 heads, 63 sectors/track, 1044 cylinders04.Units = cylinders of 16065 * 512 = 8225280 bytes05.Device Boot Start End Blocks Id System06./dev/xvda1 * 1 13 104391 83 Linux07./dev/xvda2 14 1044 8281507+ 8e Linux LVM08. 09.Disk /dev/xvdb: 23.6 GB, 23622320128 bytes10.255 heads, 63 sectors/track, 2871 cylinders11.Units = cylinders of 16065 * 512 = 8225280 bytes12.Device Boot Start End Blocks Id System
对/dev/xvdb(此名称因系统而异)进行分区:
1.fdisk /dev/xvdb
01.[root@MyVPS ~]# fdisk /dev/xvdb02.The number of cylinders for this disk is set to 2871.03.There is nothing wrong with that, but this is larger than 1024,04.and could in certain setups cause problems with:05.1) software that runs at boot time (e.g., old versions of LILO)06.2) booting and partitioning software from other OSs07.(e.g., DOS FDISK, OS/2 FDISK)08. 09.输入n新建分区10.Command (m for help): n11.Command action12.e extended13.p primary partition (1-4)14.p15. 16./dev/xvdb中第1个分区17.Partition number (1-4): 118.First cylinder (1-2871, default 1):19.Using default value 120.Last cylinder or +size or +sizeM or +sizeK (1-2871, default 2871):21.Using default value 287122. 23.输入W保存退出24.Command (m for help): w25.The partition table has been altered!26.Calling ioctl() to re-read partition table.27.Syncing disks.
将新分区xvdb1(此名称因系统而异)格式化为ext3格式
1.mkfs -t ext3 /dev/xvdb1
01.[root@MyVPS ~]# mkfs -t ext3 /dev/xvdb102.mke2fs 1.39 (29-May-2006)03.Filesystem label=04.OS type: Linux05.Block size=4096 (log=2)06.Fragment size=4096 (log=2)07.2883584 inodes, 5765319 blocks08.288265 blocks (5.00%) reserved for the super user09.First data block=010.Maximum filesystem blocks=429496729611.176 block groups12.32768 blocks per group, 32768 fragments per group13.16384 inodes per group14.Superblock backups stored on blocks:15.32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,16.409600017.Writing inode tables: done18.Creating journal (32768 blocks): done19.Writing superblocks and filesystem accounting information: done20.This filesystem will be automatically checked every 24 mounts or21.180 days, whichever comes first. Use tune2fs -c or -i to override.
我们示范将新分区xvdb1挂载到目录/home
因为home已经存在,所以我们挂载mount /dev/xvdb1 /home
如果你需要挂载在别的目录.可以新建一个目录挂载.如:home1,使用如下命令:
1.mkdir /home12.mount /dev/xvdb1 /home1
完成后我们通过df -hal可以看到,新分区已经挂载到目录/home上了
01.[root@MyVPS ~]# df -hal02.Filesystem Size Used Avail Use% Mounted on03./dev/mapper/VolGroup00-LogVol0004.5.7G 1.4G 4.1G 25% /05.proc 0 0 0 - /proc06.sysfs 0 0 0 - /sys07.devpts 0 0 0 - /dev/pts08./dev/xvda1 99M 28M 67M 30% /boot09.tmpfs 256M 0 256M 0% /dev/shm10.none 0 0 0 - /proc/sys/fs/binfmt_misc11.sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs12./dev/xvdb1 22G 173M 21G 1% /home
最后添加开机自动挂载:
1.echo "/dev/xvdb1 /home ext3 defaults 1 2" >> /etc/fstab
这样就完成了!
通过后台控制系统重做系统之后,只需要重新挂载一次即可
1.mount /dev/xvdb1 /home
最后,重新添加自动挂载即可:
1.echo "/dev/xvdb1 /home ext3 defaults 1 2" >> /etc/fstab
浙公网安备 33010602011771号