找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 服务器 Linux/BSD 查看内容

新硬备 安装

2009-12-20 13:51| 发布者: admin| 查看: 152| 评论: 0|原作者: 玄霄

题外话: ext2fs 转换为ext3fs tune2fs -j /dev/had4 (假设hda4是ext2fs文件系统)
直接格式化为ext3fs mke2fs -j /dev/hda4划(ext3fs文件系统包括5个组成部分:一组索引结点(inode)组织单元 一组分散的超级块(superblock) 一份文件系统中磁盘块的映射表 一份磁盘块使用情况的汇总 一组数据块)
ReiserFS是另一种linux上新出现的文件系统,SUSE把它作为自己默认的文件系统(fedora and SUSE)
XFS在SGI的系统上使用,JFS在IBM的系统上使用 ,这两种系统没有ext2fs 或者ReiserFS使用广泛.
(向硬盘随机执行写操作有可能在几秒之内毁掉一个文件系统,所以应该严格地设置硬盘文件的访问权限,现在的系统倾向于比以前的系统使用更少的分区,但在大多数系统里必须致少有下面两种分区
1 根分区 2 交换分区 )
硬盘安装过程概述:
1 将硬盘连接到计算机上
2 如果必要的话(通常不需要),格式化硬盘
3 为硬盘添加卷标以及对硬盘进行分区
4 建立逻辑卷
5 在硬盘分区中创建文件系统
6 设置自动安装机制
7 在交换分区上设置交换机制
安装文件系统 mount /dev/sda1 /mnt (将/dev/sda1所表示的分区里的文件系统安装到目录/mnt,这是用于临时安装文件的路径 用df命令可以核实文件系统的大小,下面是一个例子: df /home 注意:df报告的单位是1K大小的块,或着用-h选项 以好读的数值来显示G)

设置自动安装,如下所示:

/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
/dev/VolGroup00/lvhome /home ext3 defaults 1 2
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
/dev/VolGroup00/lvusr /usr ext3 defaults 1 2
/dev/VolGroup00/lvvar /var ext3 defaults 1 2
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
每行有6个空白隔开的字段,每行描述一个文件系统.传统上对各个字段是为了阅读方便
第一个字段给出了设备名或者是e2label关联到设备上的标签(以LABEL=的形式),fstab文件可以包括从远程系统上安装的文件系统,这种情况下,第一个字段是NFS路径,记法:server:/export指出的是名为server的机器上的/export目录,实际不点用存储窨的文件系统(比如前面提到过的/proc和/dev/shm)在这个字段都用none来占位.
第二个字段指定安装点 第三个字段指定安装的文件系统类型 第四个字段列出了安装选项,关键字defaults代表rw,suid,dev,exec,auto,nouser,async这些选项的组合.
第五个字段指出"转储频率"的值,从理论上来说,可以由备份设备来使用,通常不用.
第六个字段指定fsck应该检查文件系统的次序,在这个字段中有相同什的文件系统会尽可能并发检查,在日志文件系统出现之前,fsck是一个很花时间的进程,所以这个字段那时候非常重要,现在它没有那么重要的,不要将位于同一硬盘上的两个非日志文件系统设为同样的值,,否则将会导致磁盘头来回寻道,大大降低性能,只有位于不同硬盘上的文件系统才应该并行检查.
mount umount swapon fsck 命令都要读取fstab文件,
回归正题:
#fdisk -l
[root@testggv ~]# fdisk -l
Disk /dev/hdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 * 1 13 104391 83 Linux
/dev/hdb2 14 9729 78043770 8e Linux LVM
Disk /dev/hdc: 13.0 GB, 13022324736 bytes
16 heads, 63 sectors/track, 25232 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
[root@testggv ~]#
[root@testggv ~]# fdisk /dev/hdc
The number of cylinders for this disk is set to 25232.
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)
Command (m for help):
红字部分是我们经常用到的:
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):
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e 注意,建立扩展分区,先将所有的分区都划分成扩展分区,然后在扩展分区上再建立logical disk
Partition number (1-4): 1
First cylinder (1-25232, default 1):
Using default value 1
Last cylinder or size or sizeM or sizeK (1-25232, default 25232): Using default value 25232
Command (m for help):
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (1-25232, default 1):
Using default value 1
Last cylinder or size or sizeM or sizeK (1-25232, default 25232): 2G
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (3877-25232, default 3877):
Using default value 3877
Last cylinder or size or sizeM or sizeK (3877-25232, default 25232):
Using default value 25232
Command (m for help): 这样我将/dev/hdc 分成了两个逻辑盘
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@testggv ~]#
[root@testggv ~]# fdisk -l /dev/hdc
Disk /dev/hdc: 13.0 GB, 13022324736 bytes
16 heads, 63 sectors/track, 25232 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdc1 1 25232 12716896 5 Extended
/dev/hdc5 1 3876 1953441 83 Linux
/dev/hdc6 3877 25232 10763392 83 Linux
[root@testggv ~]#
如果要将一个分区做为swap,注意改变id 以下做下试验
Command (m for help): t
Partition number (1-6): 5
Hex code (type L to list codes): 82
Changed system type of partition 5 to 82 (Linux swap / Solaris)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@testggv ~]# fdisk -l /dev/hdc
Disk /dev/hdc: 13.0 GB, 13022324736 bytes
16 heads, 63 sectors/track, 25232 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdc1 1 25232 12716896 5 Extended
/dev/hdc5 1 3876 1953441 82 Linux swap / Solaris
/dev/hdc6 3877 25232 10763392 83 Linux
[root@testggv ~]#

分区已经建好,现在要在分区上创建ext3fs文件系统

注意,以下这样格式分/dev/hdc5就错,因为,/dev/hdc5是 linux swap
[root@testggv ~]# mke2fs -j /dev/hdc5
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
244320 inodes, 488360 blocks
24418 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=503316480
15 block groups
32768 blocks per group, 32768 fragments per group
16288 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@testggv ~]#
正确的做法是:
[root@testggv ~]# mkswap /dev/hdc5
Setting up swapspace version 1, size = 2000318 kB
[root@testggv ~]#swapon /dev/hdc5
[root@testggv ~]# swapon -s
Filename Type Size Used Priority
/dev/mapper/VolGroup00-LogVol01 partition 786424 0 -1
/dev/hdc5 partition 1953432 0 -2
[root@testggv ~]#
加入到/etc/fstab文件里:
/dev/hdc5 swap swap defaults 0 0







最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 01:39 , Processed in 0.298387 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部