Chinaunix首页 | 论坛 | 博客
  • 博客访问: 155319
  • 博文数量: 17
  • 博客积分: 357
  • 博客等级: 一等列兵
  • 技术积分: 706
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-12 16:49
文章分类

全部博文(17)

文章存档

2013年(3)

2012年(14)

我的朋友

分类: LINUX

2012-05-05 22:30:07

在虚拟机中为虚拟机linux添加一个2G容量的SCSI硬盘,启动系统
一,查看系统磁盘

点击(此处)折叠或打开

  1. root@ubuntu-server:/dev# ls -l /dev |grep -e 'sd[a-z]'
  2. brw-rw---- 1 root disk 8, 0 2012-05-06 06:13 sda
  3. brw-rw---- 1 root disk 8, 1 2012-05-05 22:14 sda1
  4. brw-rw---- 1 root disk 8, 2 2012-05-06 06:13 sda2
  5. brw-rw---- 1 root disk 8, 5 2012-05-06 06:13 sda5
  6. brw-rw---- 1 root disk 8, 16 2012-05-06 06:13 sdb
可以看到系统有两块磁盘sda,sdb
二,使用fdisk磁盘分区工具对sdb新盘分区

点击(此处)折叠或打开

  1. root@ubuntu-server:/dev# fdisk /dev/sdb
  2. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
  3. Building a new DOS disklabel. Changes will remain in memory only,
  4. until you decide to write them. After that, of course, the previous
  5. content won't be recoverable.
  6. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
  7. Command (m for help):
根据提示键入m,会有帮助菜单

点击(此处)折叠或打开

  1. Command (m for help): m
  2. Command action
  3. a toggle a bootable flag
  4. b edit bsd disklabel
  5. c toggle the dos compatibility flag
  6. d delete a partition
  7. l list known partition types
  8. m print this menu
  9. n add a new partition
  10. o create a new empty DOS partition table
  11. p print the partition table
  12. q quit without saving changes
  13. s create a new empty Sun disklabel
  14. t change a partition's system id
  15. u change display/entry units
  16. v verify the partition table
  17. w write table to disk and exit
  18. x extra functionality (experts only)
键入n,新建分区

点击(此处)折叠或打开

  1. Command (m for help): n
  2. Command action
  3. e extended
  4. p primary partition (1-4)
提示是创建主分区还是扩展分区
注意:如果已经有扩展分区,系统会问,是要新增主分区还是逻辑分区,如果还没有扩展分区,系统会问,是要新增主分区还是扩展分区。如果已经用完4个主分区+扩展分区,那么就只有逻辑分区可以选择。
 
键入p,创建主分区

点击(此处)折叠或打开

  1. p
  2. Partition number (1-4): 1(分区编号,可随意)
  3. First cylinder (1-261, default 1): (分区开始柱面)
  4. Using default value 1
  5. Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): 150(分区结束柱面)
键入p可查看当前分区状态,键入w,使分区生效(或键入q,取消退出)

点击(此处)折叠或打开

  1. Command (m for help): p
  2. Disk /dev/sdb: 2147 MB, 2147483648 bytes
  3. 255 heads, 63 sectors/track, 261 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Device Boot Start End Blocks Id System
  6. /dev/sdb1 1 150 1204843+ 83 Linux
  7. Command (m for help): w
  8. The partition table has been altered!
  9. Calling ioctl() to re-read partition table.
  10. Syncing disks.

用同样的方式可以把余下的磁盘空间分成主分区或扩展分区

二,使用mke2fs格式化分区
         磁盘分区后必须格式化才能挂载到系统中使用
首先查看sdb盘分区

点击(此处)折叠或打开

  1. root@ubuntu-server:/dev# ls -l /dev |grep -e 'sdb'
  2. brw-rw---- 1 root disk 8, 16 2012-05-05 22:59 sdb
  3. brw-rw---- 1 root disk 8, 17 2012-05-05 22:59 sdb1
  4. brw-rw---- 1 root disk 8, 18 2012-05-05 22:59 sdb2
格式化sdb1

点击(此处)折叠或打开

  1. root@ubuntu-server:/dev# mke2fs -j /dev/sdb1(-j参数,会把分区文件系统主动升级为ext3)
  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. 150720 inodes, 301210 blocks
  8. 15060 blocks (5.00%) reserved for the super user
  9. ......

格式化sdb2

三,挂载分区

点击(此处)折叠或打开

  1. root@ubuntu-server:~# mkdir /mnt/sdb1
  2. root@ubuntu-server:~# mkdir /mnt/sdb2
  3. root@ubuntu-server:~# mount -t ext3 /dev/sdb1 /mnt/sdb1
  4. root@ubuntu-server:~# mount -t ext3 /dev/sdb2 /mnt/sdb2
查看分区

点击(此处)折叠或打开

  1. root@ubuntu-server:~# df
  2. Filesystem 1K-blocks Used Available Use% Mounted on
  3. /dev/sda1 7882560 577604 6904540 8% /
  4. varrun 257944 52 257892 1% /var/run
  5. varlock 257944 0 257944 0% /var/lock
  6. procbususb 10240 96 10144 1% /proc/bus/usb
  7. udev 10240 96 10144 1% /dev
  8. devshm 257944 0 257944 0% /dev/shm
  9. /dev/sdb1 1185872 34584 1091048 4% /mnt/sdb1
  10. /dev/sdb2 877572 17296 815696 3% /mnt/sdb2








 
阅读(1714) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~