Chinaunix首页 | 论坛 | 博客
  • 博客访问: 151555
  • 博文数量: 25
  • 博客积分: 1632
  • 博客等级: 上尉
  • 技术积分: 324
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-02 21:19
文章分类

全部博文(25)

文章存档

2011年(13)

2010年(12)

我的朋友

分类: LINUX

2010-04-03 21:25:41

我一般分2个盘来学习linux,一个盘就是专门来安装linux操作系统的,还个盘就是用来安装开发文件,这样就把盘分开了,因为虚拟的盘有时候会出问题的,系统盘坏了,我的还一个单独的不被用来装操作系统的盘是好的,一般情况下这个盘出问题的情况比较少,所以我就采取了这个方式.
第一步:安装虚拟机
第二步:安装linux操作系统
第三步:安装虚拟工具
第四步:安装第二块虚拟硬盘
:~# fdisk -l
Disk /dev/sda: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000138e3
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         122      979933+  82  Linux swap / Solaris
/dev/sda2             123         487     2931862+  83  Linux
/dev/sda3   *         488         783     2377620   83  Linux
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
这样就可以看到我们刚刚添加的一个IDE的虚拟硬盘:/dev/sdb
我们现在格式化后将它挂载在操作系统上.
:~# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x6fc215b8.
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
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
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   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
Partition number (1-4): 2
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044):
Using default value 1044
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
:~# mkfs -t ext3 /dev/sdb2
mke2fs 1.40.8 (13-Mar-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
524288 inodes, 2096474 blocks
104823 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done                           
Creating journal (32768 blocks):
done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
:~#
:~# fdisk -l
Disk /dev/sda: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000138e3
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         122      979933+  82  Linux swap / Solaris
/dev/sda2             123         487     2931862+  83  Linux
/dev/sda3   *         488         783     2377620   83  Linux
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x6fc215b8
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb2               1        1044     8385898+  83  Linux
这样就可以看到我们刚刚格式化的硬盘.
现在可以挂载了.
:~# mount /dev/sdb2 /workdir/
:~# cd /workdir/
# ls
lost+found
这样就可以看到我们的盘挂载上去了.
为了我们每次都能挂载,我们可以采取很动办法来处理,我一般做成一个bash文件,每次先运行这个文件.
# umount /dev/sdb2
umount: /workdir: device is busy
umount: /workdir: device is busy
我们卸载这个盘,但是出现上面的提示,这个是因为你现在的目录还是在这个虚拟盘里面,所以你先退出你挂载主机上的这个目录,我的目录是/workdir
# cd ..
# umount /dev/sdb2
这样就会卸载成功!
我在根目录下建立了一个bash文件
# gedit setenv
以下是文件内容:
#!/sbin/bash
echo "hello! world!"
echo "start....."
mount /dev/sdb2 /workdir
然后运行
# . setenv
hello! world!\n
start.....
注意.后面要有个空格.
然后打开看下挂载是否成功.
# cd /workdir/
# ls
lost+found
可见成功了!这样我们就可以把这个盘作为开发学习的盘了,就算是换了操作系统,你只要去添加这个盘到你新装的系统上去就可以了!
阅读(1292) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~