日期:2014-05-16  浏览次数:20925 次

Linux系统下挂载、卸载新硬盘的方法

VMware虚拟机中,Linux系统下挂载、卸载新硬盘的方法
装载:

1、启动vm,选择vm->Settings,按向导添加一块SCSI磁盘。进入Linux系统。
2、 fdisk -l 会看到有一块新的设置,如果你先前有一块硬盘(sda1, sda3...),新加的这块应该是(/dev/sdb)。 (如果添加的第二块硬盘是IDE硬盘,应该看到hdb,如果是SCSI硬盘,看到的就是应该sdb)
[root@localhost ~]# fdisk -l
?
Disk /dev/sda: 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/sda1?? *?????????? 1????????? 13????? 104391?? 83? Linux
/dev/sda3????????????? 14??????? 1044???? 8281507+? 83? Linux
?
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
?
Disk /dev/sdb doesn't contain a valid partition table
?
3、分区:
[root@localhost ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
?
The number of cylinders for this disk is set to 1044.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
?
Command (m for help): m???? ##在这里按m ,就会输出帮助;
Command action
?? a?? toggle a bootable flag
?? b?? edit bsd disklabel
?? c?? toggle the dos compatibility flag
?? d?? delete a partition? ##这是删除一个分区的动作;
?? l?? list known partition types?? ##:l是列出分区类型,以供我们设置相应分区的类型;
?? m?? print this menu
?? n?? add a new partition??? ##添加一个分区;
?? o?? create a new empty DOS partition table
?? p?? print the partition table?? ##p列出分区表;
?? q?? quit without saving changes? ##不保存退出;
?? s?? create a new empty Sun disklabel?
?? t?? change a partition's system id?? ##t 改变分区类型;
?? u?? change display/entry units
?? v?? verify the partition table
?? w?? write table to disk and exit?? ##把分区表写入硬盘并退出;
?? x?? extra functionality (experts only)? ##扩展应用,专家功能;
?
Command (m for help): n
Command action
?? e?? extended?? ##扩展分区
?? p?? primary partition (1-4) ##选p建主分区
p
Partition number (1-4): 1
First cylinder (1-17849, default 1):?? ##注:这个就是分区的Start 值;这里最好直接按回车,如果你输入了一个非默认的数字,会造成空间浪费;
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-17849, default 17849):? 8920
Using default value 500
##这个是定义分区大小的,+200M 就是大小为200M ;当然你也可以根据上面提示的单位cylinder的大小来算,然后来指定 End的数值,在fdisk –l命令中可以看到Units = cylinders of 16065 * 512 = 8225280 bytes,这个就是单位cylinder的大小,我这里选的End的数值是8920,正好是总大小的一半,71G左右

##然后再来建一个主分区
Command (m for help): n
Command action
?? e?? extended
?? p?? primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (8921-17849, default 8921):8921
Using default value 8921
Last cylinder or +size or +sizeM or +sizeK (8921-17849, default 17849):17849
Using default value 17849
##最后保存并退出,切记,一定要保存,不然不会生效的。
Command (m for help):