免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 853 | 回复: 0
打印 上一主题 下一主题

Linux下分区工具 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-03-23 11:19 |只看该作者 |倒序浏览

                [root@localhost gxlinux]# [color="#3366ff"]df -Th
[color="#ff0000"]#[color="#ff0000"]查看已经挂载上的文件分区大小以及格式([color="#ff0000"]当然你的系统必须有空闲的空间不用了)
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda1 ext3 2.9G 2.2G 505M 82% /
/dev/sda2 ext3 965M 22M 894M 3% /home
tmpfs tmpfs 345M 12K 345M 1% /dev/shm
[root@localhost gxlinux]# [color="#3366ff"]/sbin/fdisk /dev/sda
[color="#ff0000"]#fdisk[color="#ff0000"]命令来进行磁盘分区
[color="#ff0000"]#[color="#ff0000"]如果你有第二块硬盘,[color="#ff0000"]那么后面的设备符号是/dev/sdb,[color="#ff0000"]第三块以此类推
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)
Command (m for help): [color="#3366ff"]m [color="#ff0000"]#[color="#ff0000"]查看fdisk[color="#ff0000"]命令的帮助
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition [color="#ff0000"]#[color="#ff0000"]删除某个分区
l list known partition types
m print this menu
n add a new partition [color="#ff0000"]#[color="#ff0000"]增加新的分区
o create a new empty DOS partition table
p print the partition table [color="#ff0000"]#[color="#ff0000"]打印/[color="#ff0000"]查看分区表
q quit without saving changes [color="#ff0000"]#[color="#ff0000"]不保存退出
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 [color="#ff0000"]#[color="#ff0000"]保存退出
x extra functionality (experts only)
Command (m for help): [color="#3366ff"]p [color="#ff0000"]#[color="#ff0000"]打印/[color="#ff0000"]查看已有的分区表
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000e25d9
Device Boot Start End Blocks Id System
/dev/sda1 * 1 382 3068383+ 83 Linux
/dev/sda2 383 509 1020127+ 83 Linux
/dev/sda3 510 636 1020127+ 82 Linux swap / Solaris
Command (m for help): [color="#3366ff"]n [color="#ff0000"]#[color="#ff0000"]开始增加新的分区
Command action
e extended [color="#ff0000"]#[color="#ff0000"]扩展分区
p primary partition (1-4) [color="#ff0000"]#[color="#ff0000"]主分区,[color="#ff0000"]一块硬盘中可以有4[color="#ff0000"]个主分区
[color="#ff0000"]#[color="#ff0000"]例如:XP[color="#ff0000"]下C[color="#ff0000"]盘为主分区,DEF[color="#ff0000"]为逻辑分区(DEF[color="#ff0000"]合起来就是扩展分区)
[color="#3366ff"]e [color="#ff0000"]#[color="#ff0000"]增加扩展分区
Selected partition 4 [color="#ff0000"]#[color="#ff0000"]分区4[color="#ff0000"]作为扩展分区,[color="#ff0000"]分区4[color="#ff0000"]开始是未分配空闲空间
First cylinder (637-1044, default 637): [color="#3366ff"]
Using default value 637 [color="#ff0000"]#[color="#ff0000"]分区的开头,1044[color="#ff0000"]是块结尾
Last cylinder or +size or +sizeM or +sizeK (637-1044, default 1044): [color="#3366ff"]
[color="#ff0000"]#也可在这里直接输入想要建立分区的大小,比如+5000MB,表示建立5000MB大小的分区
Using default value 1044 [color="#ff0000"]#[color="#ff0000"]分区的结尾
Command (m for help): [color="#3366ff"]n [color="#ff0000"]#[color="#ff0000"]建立完扩展分区,[color="#ff0000"]然后建立逻辑分区
First cylinder (637-1044, default 637): [color="#3366ff"]
Using default value 637
Last cylinder or +size or +sizeM or +sizeK (637-1044, default 1044): [color="#3366ff"]
Using default value 1044
Command (m for help): [color="#3366ff"]p [color="#ff0000"]#[color="#ff0000"]建立完了逻辑分区,[color="#ff0000"]打印/[color="#ff0000"]查看
[color="#ff0000"]#[color="#ff0000"]可以看到增加了一个分区,[color="#ff0000"]逻辑分区是建立在扩展分区上的
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000e25d9
Device Boot Start End Blocks Id System
/dev/sda1 * 1 382 3068383+ 83 Linux
/dev/sda2 383 509 1020127+ 83 Linux
/dev/sda3 510 636 1020127+ 82 Linux swap / Solaris
/dev/sda4 637 1044 3277260 5 Extended
/dev/sda5 637 1044 3277228+ 83 Linux
Command (m for help): [color="#3366ff"]w [color="#ff0000"]#[color="#ff0000"]把新的分区表写入并保存,[color="#ff0000"]记住一定要保存
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost gxlinux]# [color="#3366ff"]df -Th
[color="#ff0000"]#[color="#ff0000"]因为这个时候还没有挂载,[color="#ff0000"]所以在df[color="#ff0000"]命令下并不能看到新的分区
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda1 ext3 2.9G 2.2G 505M 82% /
/dev/sda2 ext3 965M 22M 894M 3% /home
tmpfs tmpfs 345M 12K 345M 1% /dev/shm
[root@localhost gxlinux]# [color="#3366ff"]/sbin/mkfs.ext3 /dev/sda5
[color="#ff0000"]#[color="#ff0000"]在挂载之前应该先格式化,[color="#ff0000"]比如ext2,ext3[color="#ff0000"]格式
[color="#ff0000"]#[color="#ff0000"]还可以使用/sbin/mkfs –t ext3 /dev/sda5
[color="#ff0000"]#其实我们已经看到在fdisk命令中已经自动将其格式化为ext3格式了
mke2fs 1.40.2 (12-Jul-2007)
warning: 107 blocks unused.
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
410400 inodes, 819200 blocks
40965 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=838860800
25 block groups
32768 blocks per group, 32768 fragments per group
16416 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost gxlinux]# [color="#3366ff"]/sbin/e2label /dev/sda5 backup [color="#ff0000"]#[color="#ff0000"]给新分区添加一个标签
[root@localhost gxlinux]# [color="#3366ff"]mkdir /mnt/bak
[root@localhost gxlinux]# [color="#3366ff"]mount /dev/sda5 /mnt/bak [color="#ff0000"]#[color="#ff0000"]将新分区挂载到指定目录上
[root@localhost gxlinux]# [color="#3366ff"]df -Th [color="#ff0000"]#[color="#ff0000"]这时候就可以看到挂载上了
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda1 ext3 2.9G 2.2G 505M 82% /
/dev/sda2 ext3 965M 22M 894M 3% /home
tmpfs tmpfs 345M 12K 345M 1% /dev/shm
/dev/sda5 ext3 3.1G 69M 2.9G 3% /mnt/bak
[root@localhost gxlinux]# [color="#3366ff"]vim /etc/fstab [color="#ff0000"]#[color="#ff0000"]添加一行到/etc/fstab[color="#ff0000"]中开机自动挂载
[color="#ff0000"]#其实不用设置,系统也可以开机自动挂载的,因为它的格式跟linux系统格式是一样的
[root@localhost gxlinux]# [color="#3366ff"]cat /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/home /home ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda3 swap swap defaults 0 0
[color="#ff0000"]LABEL=backup /mnt/bak ext3 defaults 1 2
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/93926/showart_1873907.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP