部分摘自:《鸟哥的linux私房菜-基础学习篇》
如果在系统中新增了磁盘,我们需要做如下一些事情
1.对磁盘分区,以建立可用的分区
2.格式化分区,以建立系统可用的文件系统
3.建立载入点,并将各文件系统载入
(注意:如再细分,还要做的是在载入文件系统前对文件系统进行检验)
好,下面我们来分步介绍:
一、查看当前系统是否有新加载的且可使用的硬盘
#fdisk -l
Disk /dev/sda: 4194 MB, 4194312192 bytes
255 heads, 63 sectors/track, 509 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x7e401134
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5 40131 83 Linux
/dev/sda2 6 371 2939895 83 Linux
/dev/sda3 372 509 1108485 5 Extended
/dev/sda5 372 403 257008+ 82 Linux swap / Solaris
Disk /dev/sdb: 8388 MB, 8388624384 bytes
255 heads, 63 sectors/track, 1019 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
我们看到有个新增的/dev/sdb硬盘,这时我们就先来分区
二、对新硬盘分区
分区工具fdisk的使用
#fdisk /dev/sdb
Command (m for help): m
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):
假设我们分好的区如下(适合做装linux/win双系统测试的分区结构),ntfs\fat32\ext2\ext3\swap都有
#fdisk -l /dev/sdb
Disk /dev/sdb: 8388 MB, 8388624384 bytes
255 heads, 63 sectors/track, 1019 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x2e914821
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 5 40131 83 Linux
/dev/sdb2 6 371 2939895 7 HPFS/NTFS
/dev/sdb3 372 1019 5205060 5 Extended
/dev/sdb5 372 403 257008+ 82 Linux swap / Solaris
/dev/sdb6 404 769 2939863+ 83 Linux
/dev/sdb7 770 1019 2008093+ c W95 FAT32 (LBA)
三、格式化分区
我们先查看当前系统支持的文件系统格式
#ls /lib/modules/`uname -r`/kernel/fs/
9p befs configfs ecryptfs ext4 gfs2 isofs jfs ncpfs ocfs2 reiserfs udf vfat
affs cifs cramfs ext2 fat hfs jbd mbcache.ko nls quota_v1.ko smbfs ufs xfs
afs coda dlm ext3 fuse hfsplus jbd2 msdos ntfs quota_v2.ko squashfs unionfs
可以看到我们当前系统对 ntfs\fat32\ext2\ext3\swap都支持,如你的系统查看后发现不支持ntfs,那么执行 pacman -S ntfs-3g 来安装ntfs模块
现在来格式化所有分区
//格式化分区
#mkfs.ext2 /dev/sdb1
#mkfs.ntfs /dev/sdb2
#mkswap /dev/sdb5
#mkfs.ext3 /dev/sdb6
#mkfs.vfat /dev/sdb7
四、挂载各分区
//建立挂载点
#mkdir /mnt/sdb1
#mkdir /mnt/sdb2
#mkdir /mnt/sdb6
#mkdir /mnt/sdb7
//挂载,卸载用umount命令就可以了
#mount -t ext2 /dev/sdb1/ /mnt/sdb1/
#mount -t ntfs /dev/sdb2/ /mnt/sdb2/
#mount -t ext3 /dev/sdb6/ /mnt/sdb6/
#mount -t vfat -o iocharset=utf8 /dev/sdb7/ /mnt/sdb7/
设置自动载入
我们可以直接修改 /etc/fstab 文件
附:虚拟内存的增加
//建立虚拟内存设备
#swapon /dev/sdb5
//关闭虚拟内存设备
#swapoff /dev/sdb5
//建立虚拟内存文件
//使用dd命令再/tmp下新增一64M的文件
#dd if=/dev/zero of=/tmp/swap bs=4 count=16382
//if 要转换的输入文件格式
//of 输出文件
//bs 指的是一个分区占用多少KB
//count 指要使用多少个bs
//所以最后的容量为 bs*count = 4*16382 ~64M
#mkswap /tmp/swap
#swapon /tmp/swap
//我们可用用free查看来比较
#swapoff /tmp/swap
Last modified by vkill on2008/04/28 17:30
如果在系统中新增了磁盘,我们需要做如下一些事情
1.对磁盘分区,以建立可用的分区
2.格式化分区,以建立系统可用的文件系统
3.建立载入点,并将各文件系统载入
(注意:如再细分,还要做的是在载入文件系统前对文件系统进行检验)
好,下面我们来分步介绍:
一、查看当前系统是否有新加载的且可使用的硬盘
Quotation
#fdisk -l
Disk /dev/sda: 4194 MB, 4194312192 bytes
255 heads, 63 sectors/track, 509 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x7e401134
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5 40131 83 Linux
/dev/sda2 6 371 2939895 83 Linux
/dev/sda3 372 509 1108485 5 Extended
/dev/sda5 372 403 257008+ 82 Linux swap / Solaris
Disk /dev/sdb: 8388 MB, 8388624384 bytes
255 heads, 63 sectors/track, 1019 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
我们看到有个新增的/dev/sdb硬盘,这时我们就先来分区
二、对新硬盘分区
#fdisk /dev/sdb
Quotation
分区工具fdisk的使用
#fdisk /dev/sdb
Command (m for help): m
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):
假设我们分好的区如下(适合做装linux/win双系统测试的分区结构),ntfs\fat32\ext2\ext3\swap都有
Quotation
#fdisk -l /dev/sdb
Disk /dev/sdb: 8388 MB, 8388624384 bytes
255 heads, 63 sectors/track, 1019 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x2e914821
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 5 40131 83 Linux
/dev/sdb2 6 371 2939895 7 HPFS/NTFS
/dev/sdb3 372 1019 5205060 5 Extended
/dev/sdb5 372 403 257008+ 82 Linux swap / Solaris
/dev/sdb6 404 769 2939863+ 83 Linux
/dev/sdb7 770 1019 2008093+ c W95 FAT32 (LBA)
三、格式化分区
我们先查看当前系统支持的文件系统格式
Quotation
#ls /lib/modules/`uname -r`/kernel/fs/
9p befs configfs ecryptfs ext4 gfs2 isofs jfs ncpfs ocfs2 reiserfs udf vfat
affs cifs cramfs ext2 fat hfs jbd mbcache.ko nls quota_v1.ko smbfs ufs xfs
afs coda dlm ext3 fuse hfsplus jbd2 msdos ntfs quota_v2.ko squashfs unionfs
可以看到我们当前系统对 ntfs\fat32\ext2\ext3\swap都支持,如你的系统查看后发现不支持ntfs,那么执行 pacman -S ntfs-3g 来安装ntfs模块
现在来格式化所有分区
//格式化分区
#mkfs.ext2 /dev/sdb1
#mkfs.ntfs /dev/sdb2
#mkswap /dev/sdb5
#mkfs.ext3 /dev/sdb6
#mkfs.vfat /dev/sdb7
四、挂载各分区
//建立挂载点
#mkdir /mnt/sdb1
#mkdir /mnt/sdb2
#mkdir /mnt/sdb6
#mkdir /mnt/sdb7
//挂载,卸载用umount命令就可以了
#mount -t ext2 /dev/sdb1/ /mnt/sdb1/
#mount -t ntfs /dev/sdb2/ /mnt/sdb2/
#mount -t ext3 /dev/sdb6/ /mnt/sdb6/
#mount -t vfat -o iocharset=utf8 /dev/sdb7/ /mnt/sdb7/
设置自动载入
我们可以直接修改 /etc/fstab 文件
附:虚拟内存的增加
Quotation
//建立虚拟内存设备
#swapon /dev/sdb5
//关闭虚拟内存设备
#swapoff /dev/sdb5
//建立虚拟内存文件
//使用dd命令再/tmp下新增一64M的文件
#dd if=/dev/zero of=/tmp/swap bs=4 count=16382
//if 要转换的输入文件格式
//of 输出文件
//bs 指的是一个分区占用多少KB
//count 指要使用多少个bs
//所以最后的容量为 bs*count = 4*16382 ~64M
#mkswap /tmp/swap
#swapon /tmp/swap
//我们可用用free查看来比较
#swapoff /tmp/swap
Last modified by vkill on2008/04/28 17:30
网友评论(0):


