linux下使用fdisk分区的方法
2013-06-01 12:41
423 查看
fdisk -l 查看硬盘分区的信息
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 33 265041 83 Linux
/dev/sda2 34 1945 15358140 83 Linux
/dev/sda3 1946 3220 10241437+ 83 Linux
/dev/sda4 3221 3916 5590620 5 Extended
/dev/sda5 3221 3481 2096451 82 Linux swap / Solaris
/dev/sda6 3482 3916 3494106 8e Linux LVM
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
大家可以看到有一个/dev/sdb盘还没有分区
使用 fdisk /dev/sdb 进入分区界面
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):
按下m会输出帮助文件:(具体的命令不再展示)
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)
下面我们就开是对/dev/sdb的分区,我们建立一个主分区,大小为2G
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 ----创建一个新的分区
Command action
e extended
p primary partition (1-4)
p --创建一个主分区
Partition number (1-4): 1
First cylinder (1-652, default 1): 1 --分区开始柱面,默认为 1(因为这里是新硬盘,没有分区,所以是1,如果是有分区的,那么默认就是空闲的第一个柱面),
Last cylinder or +size or +sizeM or +sizeK (1-652, default 652): +2048M
--分区的大小
Command (m for help): w --保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
下面我们使用fdisk -l /dev/sdb 就可以看见我们刚才的分区了
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 250 2008093+ 83 Linux
下面我们还需要对我们新建的分区格式化才能挂载使用
用 mkfs.后加想格式化的系统,我们格式化成ext3
mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
251392 inodes, 502023 blocks
25101 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=515899392
16 block groups
32768 blocks per group, 32768 fragments per group
15712 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 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
现在我们的分区就可以mount使用了
mount /dev/sdb1 /home/project/
df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sdb1 1.9G 35M 1.8G 2% /home/project
如果我们想下次启动后系统能自动mount这个分区,我们可以修改/etc/fstab文件增加如下信息
/dev/sdb1 /home/project ext3 defaults 0 0
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 33 265041 83 Linux
/dev/sda2 34 1945 15358140 83 Linux
/dev/sda3 1946 3220 10241437+ 83 Linux
/dev/sda4 3221 3916 5590620 5 Extended
/dev/sda5 3221 3481 2096451 82 Linux swap / Solaris
/dev/sda6 3482 3916 3494106 8e Linux LVM
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
大家可以看到有一个/dev/sdb盘还没有分区
使用 fdisk /dev/sdb 进入分区界面
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):
按下m会输出帮助文件:(具体的命令不再展示)
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)
下面我们就开是对/dev/sdb的分区,我们建立一个主分区,大小为2G
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 ----创建一个新的分区
Command action
e extended
p primary partition (1-4)
p --创建一个主分区
Partition number (1-4): 1
First cylinder (1-652, default 1): 1 --分区开始柱面,默认为 1(因为这里是新硬盘,没有分区,所以是1,如果是有分区的,那么默认就是空闲的第一个柱面),
Last cylinder or +size or +sizeM or +sizeK (1-652, default 652): +2048M
--分区的大小
Command (m for help): w --保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
下面我们使用fdisk -l /dev/sdb 就可以看见我们刚才的分区了
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 250 2008093+ 83 Linux
下面我们还需要对我们新建的分区格式化才能挂载使用
用 mkfs.后加想格式化的系统,我们格式化成ext3
mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
251392 inodes, 502023 blocks
25101 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=515899392
16 block groups
32768 blocks per group, 32768 fragments per group
15712 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 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
现在我们的分区就可以mount使用了
mount /dev/sdb1 /home/project/
df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sdb1 1.9G 35M 1.8G 2% /home/project
如果我们想下次启动后系统能自动mount这个分区,我们可以修改/etc/fstab文件增加如下信息
/dev/sdb1 /home/project ext3 defaults 0 0
相关文章推荐
- 实例解说Linux中fdisk分区使用方法
- Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- 实例解说Linux中fdisk分区使用方法
- Linux中fdisk分区使用方法