linux 分區(qū)操作試驗(yàn)
=============
一:試驗(yàn)環(huán)境
1.vmware虛擬機(jī)
2.linux9.0
3.設(shè)置兩塊硬盤(pán)
=============
二:試驗(yàn)步驟
1.在linux9.0中安裝第二塊硬盤(pán);
2.使用fdisk工具對(duì)第二塊硬盤(pán)分區(qū);
3.格式化分區(qū);
4.掛載分區(qū)到系統(tǒng)目錄;
5.對(duì)掛載點(diǎn)進(jìn)行存取;
6.卸載掛載點(diǎn);
7.設(shè)置系統(tǒng)啟動(dòng)自動(dòng)掛載分區(qū);
=============
三:分區(qū)工具
1.fdisk使用
因?yàn)槲沂褂玫氖莾蓧Kscsi硬盤(pán),故第二塊硬盤(pán)被識(shí)別為sdb
查看sdb的分區(qū)情況,因?yàn)槭切掠脖P(pán),所以沒(méi)有任何分區(qū)信息;
[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.對(duì)sdb硬盤(pán)進(jìn)行分區(qū)操作
[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 //刪除分區(qū);
l list known partition types
m print this menu //打印操作菜單;
n add a new partition //建立新分區(qū);
o create a new empty DOS partition table
p print the partition table //打印分區(qū)表;
q quit without saving changes //不保存分區(qū)表,推出;
s create a new empty Sun disklabel
t change a partition's system id //該表分區(qū)的id表示;
u change display/entry units
v verify the partition table
w write table to disk and exit //保存分區(qū)表,推出;
x extra functionality (experts only)
3.建立主分區(qū)
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..創(chuàng)建擴(kuò)展分區(qū),最好將硬盤(pán)的所有剩余空間都作為擴(kuò)展分區(qū)
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.創(chuàng)建邏輯分區(qū)
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.改變分區(qū)的系統(tǒng)代碼
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.創(chuàng)建邏輯分區(qū)sdb6,并將其轉(zhuǎn)換為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.保存分區(qū)表信息;重啟計(jì)算機(jī);
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
==============
四:格式化分區(qū)
1.格式化linux類型文件系統(tǒng);
[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文件系統(tǒng)
[root@www root]# mkfs -t vfat /dev/sdb5
mkfs.vfat 2.8 (28 Feb 2001)
3.格式化swap文件系統(tǒng);
[root@www root]# mkswap /dev/sdb6
Setting up swapspace version 1, size = 509927 kB
================
五:掛載使用分區(qū)
[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
==========================
六:讓系統(tǒng)啟動(dòng)時(shí)自動(dòng)掛載分區(qū)
[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