linux 磁盘分区,格式化操练手记

操练开始......


[root@Fedora root]# fdisk -l
//先查看哈已知的分区信息
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1        13    104391   83  Linux
/dev/sda2            14       979   7759395   83  Linux
/dev/sda3           980      1044    522112+  82  Linux swap

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1       123    987966    5  Extended
/dev/sdb5             1       123    987934+  83  Linux
//其实设备/dev/sdb有4GB,不懂操作,照猫画虎结果做成了这么一点点:(
[root@Fedora root]# fdisk /dev/sdb
//重新来——只不过是从头再来……
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): d
//我要把它们统统杀掉——delete
Partition number (1-5): 5
//要从logical倒着来delete,和在DOC下面操作windows系统的FAT一样
//悄无声息的就完成了,一点提示都没有的......
Command (m for help): w
//必须w一下让以上操作作用了...
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@Fedora root]# fdisk -l
//查看一哈,呵呵,/dev/sdb5真的不消失了...

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1        13    104391   83  Linux
/dev/sda2            14       979   7759395   83  Linux
/dev/sda3           980      1044    522112+  82  Linux swap

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1       123    987966    5  Extended


[root@Fedora root]# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1        13    104391   83  Linux
/dev/sda2            14       979   7759395   83  Linux
/dev/sda3           980      1044    522112+  82  Linux swap

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1       522   4192933+   5  Extended

//继续我的delete,直到杀完为止:)
//直接就剩下了extended了,用delete是除不掉的,它只能delete partition

[root@Fedora root]# mkfs.ext3 /dev/sdb1
mke2fs 1.34 (25-Jul-2003)
/dev/sdb1: Invalid argument passed to ext2 library while setting up superblock
[root@Fedora root]# mke2fs /dev/sdb1
mke2fs 1.34 (25-Jul-2003)
/dev/sdb1: Invalid argument passed to ext2 library while setting up superblock
//奶奶的咧...还格不了了它...
//哦,是没有卸载sdb5

[root@Fedora root]# umount /mnt/sdb5
[root@Fedora root]# umount /mnt/sdb1
umount: /mnt/sdb1: not mounted
//把挂载的盘全卸载掉,不然不让格式化?

[root@Fedora root]# mkfs.ext3 /dev/sdb
//把整个磁盘entire device全格了......

mke2fs 1.34 (25-Jul-2003)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
524288 inodes, 1048576 blocks
52428 blocks (5.00%) reserved for the super user
First data block=0
32 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@Fedora root]# fdisk -l
//查看哈子,确实没有了,显示只有孤零零的disk

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1        13    104391   83  Linux
/dev/sda2            14       979   7759395   83  Linux
/dev/sda3           980      1044    522112+  82  Linux swap

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

[root@Fedora root]# fdisk /dev/sdb
//刚才操练的是delete,现在来add a new partition......

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 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): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-522, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-522, default 522):
Using default value 522
//选1-522 cylinder,全盘操作。
//但是必须,还得添加logical partition,extended 基础上就是logical

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@Fedora root]# fdisk -l
//看哈子,4GB都成了Extended了:)

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1        13    104391   83  Linux
/dev/sda2            14       979   7759395   83  Linux
/dev/sda3           980      1044    522112+  82  Linux swap

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1       522   4192933+   5  Extended
[root@Fedora root]# mount /dev/sdb1 /mnt/sdb1
mount: error while guessing filesystem type
mount: you must specify the filesystem type
[root@Fedora root]# fdisk /dev/sdb

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): v
8385928 unallocated sectors

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (1-522, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-522, default 522):
Using default value 522
//全部给logical partition

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@Fedora root]# fdisk -l
//显示如我所愿:)

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1        13    104391   83  Linux
/dev/sda2            14       979   7759395   83  Linux
/dev/sda3           980      1044    522112+  82  Linux swap

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1       522   4192933+   5  Extended
/dev/sdb5             1       522   4192902   83  Linux
[root@Fedora root]# mount /dev/sdb5 /mnt/sdb5
mount: you must specify the filesystem type
//原来是没有format,需要指定一个filesystem:(
//那么就大胆的mkfs.ext3吧

[root@Fedora root]# mkfs.ext3 /dev/sdb5

mke2fs 1.34 (25-Jul-2003)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
524288 inodes, 1048225 blocks
52411 blocks (5.00%) reserved for the super user
First data block=0
32 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

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@Fedora root]# fdisk -l
//再次查看我的杰作

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1        13    104391   83  Linux
/dev/sda2            14       979   7759395   83  Linux
/dev/sda3           980      1044    522112+  82  Linux swap

Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1       522   4192933+   5  Extended
/dev/sdb5             1       522   4192902   83  Linux
[root@Fedora root]# mount /dev/sdb5 /mnt/sdb5
[root@Fedora root]# ll /mnt/sdb5
total 16
drwx------    2 root     root        16384 Jan 10 21:56 lost+found
[root@Fedora root]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2              7637400   5561672   1687760  77% /
/dev/sda1               101086      6459     89408   7% /boot
none                     79180         0     79180   0% /dev/shm
/dev/sdb5              4127044     32828   3884572   1% /mnt/sdb5
[root@Fedora root]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2             7.3G  5.4G  1.7G  77% /
/dev/sda1              99M  6.4M   88M   7% /boot
none                   78M     0   78M   0% /dev/shm
/dev/sdb5             4.0G   33M  3.8G   1% /mnt/sdb5
[root@Fedora root]# df -H
Filesystem             Size   Used  Avail Use% Mounted on
/dev/sda2              7.9G   5.7G   1.8G  77% /
/dev/sda1              104M   6.7M    92M   7% /boot
none                    82M      0    82M   0% /dev/shm
/dev/sdb5              4.3G    34M   4.0G   1% /mnt/sdb5
[root@Fedora root]#

你可能感兴趣的:(linux,dos,command,table,delete,磁盘)