初学者对linux挂硬盘
2013-03-30 18:06
211 查看
1、使用root用户执行:
[root@localhost ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 38 305203+ 83 Linux
/dev/sda2 39 1048 8112825 83 Linux
/dev/sda3 1049 1305 2064352+ 82 Linux swap / Solaris
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 5 Extended
/dev/sdb5 1 1305 10482349+ 82 Linux swap / Solaris
Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
其中Disk /dev/sdc: 1073 MB, 1073741824 bytes 是我们挂的硬盘。
2、
[root@localhost ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
输入n进行新建扩展分区
3、
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):
Using default value 130
输入e再输入1,使用默认全部分配给一个分区
4、输入n和l建立逻辑分区
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (1-130, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):
Using default value 130
5、输入p查看分区类型
Command (m for help): p
Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 130 1044193+ 5 Extended
/dev/sdc5 1 130 1044162 83 Linux
6、输入t转换分区类型
转换为82类型
Command (m for help): t
Partition number (1-5): 5
Hex code (type L to list codes): 82
Changed system type of partition 5 to 82 (Linux swap / Solaris)
Command (m for help): p
Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 130 1044193+ 5 Extended
/dev/sdc5 1 130 1044162 82
Linux swap / Solaris
7、保存退出
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
8、格式化
[root@localhost ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 38 305203+ 83 Linux
/dev/sda2 39 1048 8112825 83 Linux
/dev/sda3 1049 1305 2064352+ 82 Linux swap / Solaris
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 5 Extended
/dev/sdb5 1 1305 10482349+ 82 Linux swap / Solaris
Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 130 1044193+ 5 Extended
/dev/sdc5 1 130 1044162 82 Linux swap / Solaris
[root@localhost ~]# mkfs -t ext3 -c /dev/sdc5
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
130560 inodes, 261040 blocks
13052 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
16320 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Checking for bad blocks (read-only test): done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
9、挂载到文件夹上
[root@localhost ~]# mkdir /test
[root@localhost ~]# mount /dev/sdc5 /test
恭喜你完成将1G的硬盘全部挂载到/test上!!!
[root@localhost ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 38 305203+ 83 Linux
/dev/sda2 39 1048 8112825 83 Linux
/dev/sda3 1049 1305 2064352+ 82 Linux swap / Solaris
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 5 Extended
/dev/sdb5 1 1305 10482349+ 82 Linux swap / Solaris
Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
其中Disk /dev/sdc: 1073 MB, 1073741824 bytes 是我们挂的硬盘。
2、
[root@localhost ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
输入n进行新建扩展分区
3、
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):
Using default value 130
输入e再输入1,使用默认全部分配给一个分区
4、输入n和l建立逻辑分区
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (1-130, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):
Using default value 130
5、输入p查看分区类型
Command (m for help): p
Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 130 1044193+ 5 Extended
/dev/sdc5 1 130 1044162 83 Linux
6、输入t转换分区类型
转换为82类型
Command (m for help): t
Partition number (1-5): 5
Hex code (type L to list codes): 82
Changed system type of partition 5 to 82 (Linux swap / Solaris)
Command (m for help): p
Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 130 1044193+ 5 Extended
/dev/sdc5 1 130 1044162 82
Linux swap / Solaris
7、保存退出
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
8、格式化
[root@localhost ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 38 305203+ 83 Linux
/dev/sda2 39 1048 8112825 83 Linux
/dev/sda3 1049 1305 2064352+ 82 Linux swap / Solaris
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 5 Extended
/dev/sdb5 1 1305 10482349+ 82 Linux swap / Solaris
Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 130 1044193+ 5 Extended
/dev/sdc5 1 130 1044162 82 Linux swap / Solaris
[root@localhost ~]# mkfs -t ext3 -c /dev/sdc5
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
130560 inodes, 261040 blocks
13052 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
16320 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Checking for bad blocks (read-only test): done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
9、挂载到文件夹上
[root@localhost ~]# mkdir /test
[root@localhost ~]# mount /dev/sdc5 /test
恭喜你完成将1G的硬盘全部挂载到/test上!!!
相关文章推荐
- 献给初学者:谈谈如何学习Linux操作系统
- linux下的硬盘检测工具 Smartmontools
- 初学者学习Linux之DNS服务搭建
- linux 如何查看硬盘大小,内存大小等系统信息及硬件信息
- linux下 gcc编译初学者使用教程
- <linux><grub 0.97>三重引导,基本无解,除非重做硬盘
- 深入理解硬盘的Linux分区
- 在VMware上为linux添加新硬盘
- Linux系统限制普通用户内存使用(ulimit)和硬盘配额空间(quota)
- linux挂硬盘方法
- 【Vegas原创】VMWare下,Linux挂载、卸载新硬盘的方法
- Linux LVM硬盘管理及LVM扩容
- 新增硬盘扩充linux ftp server空间
- linux初学者常用命令
- 扩展虚拟机硬盘 - linux
- Linux下添加新硬盘,分区及挂载
- 移动硬盘在windows上用了之后在linux上不能访问
- 【高性能】Linux挂载GPT硬盘
- 如何在 Linux 系统下检测硬盘上的坏道和坏块
- 初学Linux[17]--加入Linux阵营初期:初学者常问的八大问题解疑