Virtualbox中Linux添加一个新磁盘->创建分区->格式化->

引言:我们常常在使用系统的时候突然发现,哎呦~~~我们的磁盘空间不够用啦!我遇到常见的就是数据库数据暴增,预留的空间没有啦,只好新添加磁盘,在VB虚拟机上就可以实现,往往苦于没有图文并茂的好资料,下面我来为大家简单快捷的实操示范一下,做一名“实操族”偶耶!一 virtualbox 设置添加磁盘关闭你的虚拟机,挂载新磁盘不可以在开机状态做Virtualbox 菜单栏- 设置- 存储- SATA控制器 – 右击,选择“添加虚拟硬盘”注:千万不要选择“IDE控制器”这是一种非常古老的并口磁盘,现在已经都淘汰了,请选SATA控制器现在流行的串口磁盘添加。我们点击红框框中的“添加虚拟磁盘”按钮它会问你,添加虚拟磁盘是要创建一个新文件来保存数据,还是选择一个现有文件保存,我们选择“创建新的虚拟磁盘”这时又让你选择“虚拟磁盘文件类型”,请注意90%都是选择VDI(虚拟磁盘映像)类型的,如果你的系统没有什么特殊需求,请选择第一个。点击“下一步”选择“动态分配”磁盘空间,只在需要的时候扩展物理磁盘空间,点击“下一步”虚拟磁盘映像文件的路径:E:\Vritaulbox\leonarding2.vdi虚拟磁盘映像文件的大小:20GB点击“创建”现在已经创建好了一个新的虚拟磁盘“leonarding2.vdi”,我们启动系统,virtualbox添加工作已经完成,剩下的就是在Linux系统中给新添加的磁盘- 分区。二 Linux系统进行新磁盘分区[root@leonarding1~]# fdisk –l 检查现有系统磁盘空间Disk/dev/sda: 21.4 GB, 21474836480 bytes 这是我们原来的那块旧磁盘255 heads, 63sectors/track, 2610 cylindersUnits = cylindersof 16065 * 512 = 8225280 bytes Device Boot Start End BlocksIdSystem 旧磁盘就分了2个分区/dev/sda1 * 1 13 104391 83Linux/dev/sda2 14 2610 20860402+8eLinux LVMDisk/dev/sdb: 21.4 GB, 21474836480 bytes 这是我们新添加的磁盘/dev/sdb,还没有分区255 heads, 63sectors/track, 2610 cylindersUnits = cylindersof 16065 * 512 = 8225280 bytesDisk /dev/sdbdoesn’t contain a valid partition table不包含有效分区表信息,我们需要给新磁盘创建分区表Disk /dev/dm-0:18.2 GB, 18253611008 bytes 下面这些都不用管255 heads, 63sectors/track, 2219 cylindersUnits = cylindersof 16065 * 512 = 8225280 bytesDisk /dev/dm-0doesn’t contain a valid partition tableDisk /dev/dm-1:3087 MB, 3087007744 bytes255 heads, 63sectors/track, 375 cylindersUnits = cylindersof 16065 * 512 = 8225280 bytesDisk /dev/dm-1doesn’t contain a valid partition table[root@leonarding1~]# fdisk /dev/sdb sdb磁盘分区,有很多选项,我们选择m帮助信息Device containsneither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOSdisklabel. Changes will remain in memory only,until you decideto write them. After that, of course, the previouscontent won’t be recoverable.The number ofcylinders for this disk is set to 2610.There is nothingwrong with that, but this is larger than 1024,and could incertain setups cause problems with:1) software thatruns at boot time (e.g., old versions of LILO)2) booting andpartitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)Warning: invalidflag 0x0000 of partition table 4 will be corrected by w(rite)Command (m forhelp): m 选择m即可看到帮助信息Command action atoggle a bootable flag bedit bsd disklabel ctoggle the dos compatibility flag ddelete a partition llist known partition types mprint this menu n add a new partition 创建一个新分区 ocreate a new empty DOS partition table pprint the partition table qquit without saving changes screate a new empty Sun disklabel tchange a partition’s system id uchange display/entry units vverify the partition table wwrite table to disk and exit xextra functionality (experts only)Command (m forhelp): n 创建一个新分区Command action eextended pprimary partition (1-4)p 选择p添加主分区Partition number(1-4): 1 选择主分区编号为1, 这样创建后的主分区为sdb1First cylinder(1-2610, default 1): 选择格式化分区从第几个柱面开始Using defaultvalue 1 直接“回车”默认从第1个柱面开始Last cylinder or+size or +sizeM or +sizeK (1-2610, default 2610): 选择格式化分区从第几个柱面结束Using defaultvalue 2610 直接“回车”默认从最后1个柱面结束我们把所有20GB空间都格式化为一个分区了,如果有朋友想划分多个分区,如下方法Last cylinder or+size or +sizeM or +sizeK (1-2610, default 2610): 以MB为单位输入自己想要的大小即可这样我们就创建完一个分区,如果要创建更多分区可以照上面的步骤继续创建。Command (m forhelp): w 键入w,保存设置并退出,完成新磁盘分区表创建The partitiontable has been altered!Calling ioctl() tore-read partition table.Syncing disks.[root@leonarding1~]# fdisk –l 我们在看一下系统磁盘空间分配情况Disk /dev/sda:21.4 GB, 21474836480 bytes255 heads, 63sectors/track, 2610 cylindersUnits = cylindersof 16065 * 512 = 8225280 bytes Device Boot Start End BlocksIdSystem/dev/sda1 * 1 13 10439183Linux/dev/sda2 14 2610 20860402+8eLinux LVMDisk/dev/sdb: 21.4 GB, 21474836480 bytes 这时我们可以看到新磁盘已经加入分区表了255heads, 63 sectors/track, 2610 cylindersUnits =cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End BlocksIdSystem/dev/sdb1 1 2610 20964793+83Linux下面我们给新磁盘的/dev/sdb1分区进行格式化操作[root@leonarding1~]# mkfs -t ext4 /dev/sdb1 用ext4格式对/dev/sdb1分区进行格式化mke4fs 1.41.12(17-May-2010)Filesystem label=OS type: Linux 操作系统类型LinuxBlock size=4096(log=2) 操作系统块大小4kFragment size=4096(log=2)Stride=0 blocks,Stripe width=0 blocks1310720 inodes,5241198 blocks262059 blocks(5.00%) reserved for the super userFirst data block=0Maximum filesystemblocks=4294967296160 block groups32768 blocks pergroup, 32768 fragments per group8192 inodes pergroupSuperblock backupsstored on blocks: 32768, 98304, 163840, 229376, 294912,819200, 884736, 1605632, 2654208, 4096000Writing inodetables: done Creating journal(32768 blocks): doneWritingsuperblocks and filesystem accounting information: doneThis filesystemwill be automatically checked every 35 mounts or180 days,whichever comes first.Use tune4fs -c or-i to override.到此我们的新分区格式化完毕,下面我们就要挂载上分区就可以使用啦![root@leonarding1~]# df –h 这是我们还没有挂载新分区之前的挂载点分布Filesystem SizeUsed Avail Use% Mounted on/dev/mapper/VolGroup00-LogVol00 17G 15G 1.6G90% //dev/sda1 99M 23M71M25% /boottmpfs 731M320M 411M44% /dev/shm/dev/sr0 55M 55M 0 100% /media/VBOXADDITIONS_4.2.6_82870[root@leonarding1/]# mkdir /u02 在根目录上创建一个新的挂载目录/u02[root@leonarding1/]# mount /dev/sdb1 /u02 将新磁盘分区挂载到/u02目录下[root@leonarding1/]# df –h 这是我们挂载新分区之后的挂载点分布Filesystem SizeUsed Avail Use% Mounted on/dev/mapper/VolGroup00-LogVol00 17G 15G 1.6G90% //dev/sda1 99M 23M71M25% /boottmpfs 731M320M 411M44% /dev/shm/dev/sr0 55M 55M 0 100% /media/VBOXADDITIONS_4.2.6_82870/dev/sdb1 20G172M19G 1% /u02现在我们可以正常使用新添加的磁盘空间了[root@leonarding1/]# cd /u02[root@leonarding1u02]# mkdir app 创建一个app目录试试[root@leonarding1u02]# lltotal 20drwxr-xr-x 2 rootroot4096 Apr 14 09:12 app ok成功创建木有问题drwx—— 2 rootroot 16384 Apr 14 08:59 lost+found到此Virtualbox中Linux添加一个新磁盘- 创建分区- 格式化- 挂载分区系列操作完毕开机自动挂载新磁盘分区/dev/sdb1[root@leonarding1 /]# vim /etc/fstab 修改文件,在文件最后新增一行/dev/VolGroup00/LogVol00 / ext3 defaults 1 1LABEL=/boot /boot ext3 defaults 1 2tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devptsgid=5,mode=6200 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0/dev/VolGroup00/LogVol01 swap swap defaults 0 0/dev/sdb1 /u02 ext4 defaults 0 0这样在重启系统后就会自动挂载到/u02目录上Virtualbox 添加磁盘 创建分区格式化挂载分区Leonarding2013.4.14天津 spring分享技术~成就梦想Blog:www.leonarding.com 知已知彼,百战百胜。

Virtualbox中Linux添加一个新磁盘->创建分区->格式化->

相关文章:

你感兴趣的文章:

标签云: