Chinaunix首页 | 论坛 | 博客
  • 博客访问: 532911
  • 博文数量: 184
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 2490
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-09 11:34
文章分类

全部博文(184)

文章存档

2011年(1)

2010年(2)

2009年(12)

2008年(169)

我的朋友

分类: LINUX

2008-08-26 16:13:27

linux 分区操作试验
=============
一:试验环境
 
1.vmware虚拟机
2.linux9.0
3.设置两块硬盘
 
=============
二:试验步骤
 
1.在linux9.0中安装第二块硬盘;
2.使用fdisk工具对第二块硬盘分区;
3.格式化分区;
4.挂载分区到系统目录;
5.对挂载点进行存取;
6.卸载挂载点;
7.设置系统启动自动挂载分区;
 
=============
三:分区工具
 
1.fdisk使用
因为我使用的是两块scsi硬盘,故第二块硬盘被识别为sdb
查看sdb的分区情况,因为是新硬盘,所以没有任何分区信息;
[root@www root]# fdisk -l /dev/sdb
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot    Start       End    Blocks   Id  System
 
2.对sdb硬盘进行分区操作
[root@www root]# fdisk /dev/sdb
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  //该表分区的id表示;
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit  //保存分区表,推出;
   x   extra functionality (experts only)
 
3.建立主分区
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-522, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-522, default 522): +500M
Command (m for help): p
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1        62    497983+  83  Linux
 
4..创建扩展分区,最好将硬盘的所有剩余空间都作为扩展分区
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 2
First cylinder (63-522, default 63):
Using default value 63
Last cylinder or +size or +sizeM or +sizeK (63-522, default 522):
Using default value 522
Command (m for help): p
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1        62    497983+  83  Linux
/dev/sdb2            63       522   3694950    5  Extended
 
5.创建逻辑分区
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (63-522, default 63):
Using default value 63
Last cylinder or +size or +sizeM or +sizeK (63-522, default 522): +500M
Command (m for help): p
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1        62    497983+  83  Linux
/dev/sdb2            63       522   3694950    5  Extended
/dev/sdb5            63       124    497983+  83  Linux
Command (m for help):
 
6.改变分区的系统代码
Command (m for help): t
Partition number (1-5): 5
Hex code (type L to list codes): L
 0  Empty           1c  Hidden Win95 FA 70  DiskSecure Mult bb  Boot Wizard hid
 1  FAT12           1e  Hidden Win95 FA 75  PC/IX           be  Solaris boot
 2  XENIX root      24  NEC DOS         80  Old Minix       c1  DRDOS/sec (FAT-
 3  XENIX usr       39  Plan 9          81  Minix / old Lin c4  DRDOS/sec (FAT-
 4  FAT16 <32M      3c  PartitionMagic  82  Linux swap      c6  DRDOS/sec (FAT-
 5  Extended        40  Venix 80286     83  Linux           c7  Syrinx
 6  FAT16           41  PPC PReP Boot   84  OS/2 hidden C:  da  Non-FS data
 7  HPFS/NTFS       42  SFS             85  Linux extended  db  CP/M / CTOS / .
 8  AIX             4d  QNX4.x          86  NTFS volume set de  Dell Utility
 9  AIX bootable    4e  QNX4.x 2nd part 87  NTFS volume set df  BootIt
 a  OS/2 Boot Manag 4f  QNX4.x 3rd part 8e  Linux LVM       e1  DOS access
 b  Win95 FAT32     50  OnTrack DM      93  Amoeba          e3  DOS R/O
 c  Win95 FAT32 (LB 51  OnTrack DM6 Aux 94  Amoeba BBT      e4  SpeedStor
 e  Win95 FAT16 (LB 52  CP/M            9f  BSD/OS          eb  BeOS fs
 f  Win95 Ext'd (LB 53  OnTrack DM6 Aux a0  IBM Thinkpad hi ee  EFI GPT
10  OPUS            54  OnTrackDM6      a5  FreeBSD         ef  EFI (FAT-12/16/
11  Hidden FAT12    55  EZ-Drive        a6  OpenBSD         f0  Linux/PA-RISC b
12  Compaq diagnost 56  Golden Bow      a7  NeXTSTEP        f1  SpeedStor
14  Hidden FAT16 <3 5c  Priam Edisk     a8  Darwin UFS      f4  SpeedStor
16  Hidden FAT16    61  SpeedStor       a9  NetBSD          f2  DOS secondary
17  Hidden HPFS/NTF 63  GNU HURD or Sys ab  Darwin boot     fd  Linux raid auto
18  AST SmartSleep  64  Novell Netware  b7  BSDI fs         fe  LANstep
1b  Hidden Win95 FA 65  Novell Netware  b8  BSDI swap       ff  BBT
Hex code (type L to list codes):b
Changed system type of partition 5 to b (Win95 FAT32)
Command (m for help): p
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1        62    497983+  83  Linux
/dev/sdb2            63       522   3694950    5  Extended
/dev/sdb5            63       124    497983+   b  Win95 FAT32

7.创建逻辑分区sdb6,并将其转换为swap类型;
Command (m for help): p
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1        62    497983+  83  Linux
/dev/sdb2            63       522   3694950    5  Extended
/dev/sdb5            63       124    497983+   b  Win95 FAT32
/dev/sdb6           125       186    497983+  82  Linux swap
8.保存分区表信息;重启计算机;
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
[root@www root]# reboot
 

==============
四:格式化分区
 
1.格式化linux类型文件系统;
[root@www root]# mkfs -t ext3 /dev/sdb1
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
124928 inodes, 497983 blocks
24899 blocks (5.00%) reserved for the super user
First data block=1
61 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
2.格式化 vfat文件系统
[root@www root]# mkfs -t vfat /dev/sdb5
mkfs.vfat 2.8 (28 Feb 2001)
3.格式化swap文件系统;
[root@www root]#  mkswap /dev/sdb6
Setting up swapspace version 1, size = 509927 kB
 
================
五:挂载使用分区
 
[root@www root]# mkdir /mnt/sdb1
[root@www root]# mount /dev/sdb1 /mnt/sdb1
[root@www root]# cd /mnt/sdb1
[root@www sdb1]# touch testfile
[root@www sdb1]# ll
总用量 12
drwx------    2 root     root        12288 10月 16 19:22 lost+found
-rw-r--r--    1 root     root            0 10月 16 19:25 testfile
[root@www sdb1]# cd
[root@www root]# umount /mnt/sdb1
[root@www root]# ls /mnt/sdb1

==========================
六:让系统启动时自动挂载分区
 
[root@www root]# vi /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /proc                   proc    defaults        0 0
none                    /dev/shm                tmpfs   defaults        0 0
/dev/sda3               swap                    swap    defaults        0 0
/dev/cdrom              /mnt/cdrom              udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0
/dev/sdb1               /mnt/sdb1               auto    default         0 0
 
 
 
阅读(582) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~