Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2395882
  • 博文数量: 328
  • 博客积分: 4302
  • 博客等级: 上校
  • 技术积分: 5486
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-01 11:14
个人简介

悲剧,绝对的悲剧,悲剧中的悲剧。

文章分类

全部博文(328)

文章存档

2017年(6)

2016年(18)

2015年(28)

2014年(73)

2013年(62)

2012年(58)

2011年(55)

2010年(28)

分类: LINUX

2011-01-13 15:47:09


linux 用/sbin/fdisk 建分区,删分区
/sbin/fdisk  devicename
[root@mm sbin]# /sbin/fdisk /dev/hdc

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)
 

 
   p ------看分区表
Command (m for help): p

Disk /dev/hdc: 4311 MB, 4311982080 bytes
255 heads, 63 sectors/track, 524 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1   *           1         523     4200966    7  HPFS/NTFS

    d-------删分区
Command (m for help): d
Selected partition 1

Command (m for help): p

Disk /dev/hdc: 4311 MB, 4311982080 bytes
255 heads, 63 sectors/track, 524 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System


    n-----------建立分区
Command (m for help): n
Command action
   e   extended                             
   p   primary partition (1-4)
Partition number (1-4): 1
也是4个主分区,1个扩展分区,可见是在x86上

First cylinder (1-524, default 1):     cylinder是分区的单位     
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-524, default 524):
Using default value 524
Command (m for help): p

Disk /dev/hdc: 4311 MB, 4311982080 bytes
255 heads, 63 sectors/track, 524 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1               1         524     4208998+  83  Linux


   l--------列 分区类型 
Command (m for help): l

 0  Empty           1e  Hidden W95 FAT1 75  PC/IX          be  Solaris boot  
 1  FAT12           24  NEC DOS         80  Old Minix       bf  Solaris       
 2  XENIX root      39  Plan 9          81  Minix / old Lin c1  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic 82  Linux swap      c4  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286    83  Linux           c6  DRDOS/sec (FAT-
 5  Extended        41  PPC PReP Boot   84  OS/2 hidden C:  c7  Syrinx        
 6  FAT16           42  SFS             85  Linux extended  da  Non-FS data   
 7  HPFS/NTFS       4d  QNX4.x          86  NTFS volume set db  CP/M / CTOS / .
 8  AIX             4e  QNX4.x 2nd part 87  NTFS volume set de  Dell Utility  
 9  AIX bootable    4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt        
 a  OS/2 Boot Manag 50  OnTrack DM      93  Amoeba          e1  DOS access    
 b  W95 FAT32       51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O       
 c  W95 FAT32 (LBA) 52  CP/M            9f  BSD/OS          e4  SpeedStor     
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs       
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  EFI GPT       
10  OPUS            55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
11  Hidden FAT12    56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
12  Compaq diagnost 5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor     
14  Hidden FAT16 <3 61  SpeedStor       a9  NetBSD          f4  SpeedStor     
16  Hidden FAT16    63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary 
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fd  Linux raid auto
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fe  LANstep       
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid ff  BBT

    t-------改分区类型
Command (m for help): p

Disk /dev/hdc: 4311 MB, 4311982080 bytes
255 heads, 63 sectors/track, 524 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1               1         524     4208998+  83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 82
Changed system type of partition 1 to 82 (Linux swap)

Command (m for help): p

Disk /dev/hdc: 4311 MB, 4311982080 bytes
255 heads, 63 sectors/track, 524 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1               1         524     4208998+  82  Linux swap
只能在这里改分区类型,n(new)建分区时,竟然不能设分区,即用n指令建立的分区都是缺省ext 2类型


    fdisk进行分区操作后,退出前别忘了w存盘
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks


    为什么fdisk 建立分区后,无法mount上新分区?-------必须先建FS
[root@mm /]# mkdir diskpartitontest
[root@mm /]# mount /dev/hdc1 /diskpartitontest
mount: fs type ntfs not supported by kernel
[root@mm /]# mount -t ext3 /dev/hdc1 /diskpartitontest
mount: wrong fs type, bad option, bad superblock on /dev/hdc1,
       or too many mounted file systems
[root@mm /]# mount -t ext2 /dev/hdc1 /diskpartitontest
mount: wrong fs type, bad option, bad superblock on /dev/hdc1,
       or too many mounted file systems
因为其上还没建立文件系统

mkfs后,可以mount分区
[root@mm diskpartitontest]# /sbin/mkfs /dev/hdc1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux

Block size=4096 (log=2)


Fragment size=4096 (log=2)
526944 inodes, 1052249 blocks

52612 blocks (5.00%) reserved for the super user

First data block=0
Maximum filesystem blocks=1077936128

33 block groups

32768 blocks per group, 32768 fragments per group

15968 inodes per group

Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: 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.

[root@mm diskpartitontest]# mount /dev/hdc1 /diskpartitontest

[root@mm diskpartitontest]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      8.6G  5.8G  2.4G  71% /
/dev/hda1              99M  9.0M   85M  10% /boot
none                  125M     0  125M   0% /dev/shm
/dev/hdc1             4.0G  8.1M  3.8G   1% /diskpartitontest


   mkfs
[root@mm diskpartitontest]# man mkfs
NAME
       mkfs - build a Linux file system
      
       -t fstype
              Specifies the type of file system to be built.  If not specified, the default file system type (currently ext2)  is used.
                    mkfs缺省是ext2

       -v     Produce verbose output.
[root@mm diskpartitontest]# whereis mkfs
mkfs: /sbin/mkfs.msdos /sbin/mkfs.ext2 /sbin/mkfs.ext3 /sbin/mkfs /sbin/mkfs.vfat /sbin/mkfs.cramfs /usr/share/man/man8/mkfs.8.gz


    新的LV(LVM里的逻辑卷) 建立FS后,可以手工mount上,但/etc/fstab 总mount不上,重起时报告file system type 错误
错误出在,/etc/fstab中的FS是ext3,而用mkfs做FS,而不是用mkfs.ext3做
[root@mm guan]# ls -l /sbin/mk*
-rwxr-xr-x  1 root root  5905 Aug  4  2004 /sbin/mkbootdisk
-rwxr-xr-x  3 root root 28484 Oct 13  2004 /sbin/mkdosfs
-rwxr-xr-x  3 root root 34832 Apr 24  2006 /sbin/mke2fs
-rwxr-xr-x  1 root root  6912 May 25  2006 /sbin/mkfs
-rwxr-xr-x  1 root root 15300 May 25  2006 /sbin/mkfs.cramfs
-rwxr-xr-x  3 root root 34832 Apr 24  2006 /sbin/mkfs.ext2
-rwxr-xr-x  3 root root 34832 Apr 24  2006 /sbin/mkfs.ext3
-rwxr-xr-x  3 root root 28484 Oct 13  2004 /sbin/mkfs.msdos
-rwxr-xr-x  3 root root 28484 Oct 13  2004 /sbin/mkfs.vfat
-rwxr-xr-x  1 root root 20313 Apr 11  2006 /sbin/mkinitrd
-rwxr-xr-x  1 root root 13036 May 25  2006 /sbin/mkswap
-rwxr-x---  1 root root 15444 Oct  5  2004 /sbin/mkzonedb
[root@mm guan]# cat /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details
/dev/VolGroup00/LogVol00 /            ext3    defaults        1 1
LABEL=/boot             /boot         ext3    defaults        1 2
/dev/VolGroup00/testlv /testlv        ext3    defaults        1 1


    linux做分区和sun做分区
 sun 
  linux
  format建立修改slice(solaris slice是固定的1-7,不需要建立,只需要修改)
  newfs
  mount   
  修改/etc/fstab
fdisk 建partiton
  mkfs(mke2fs,mkfs.ext2,mkfs.ext3)
mount
修改/etc/vfstab

 

   修改目录大小------只针对有整个分区mount的目录
备份---umountod ---mount new---- 恢复
#cp –r /export/data /var/tmp/data
 先备分目录数据
# umount /dev/hda8
 卸载目录/分区
 重新建立一个新分区
或者把原分区用软件扩大
 
# mount  /dev/hda9 /mnt/data
or
# mount  /dev/hda8 /mnt/data 
 把新分区重新mount到/export/data上

或把修改(扩容)后的原分区mount回/export/data上
#cp –r /var/tmp/data /export/data
 把备分数据拷回原目录
vi /etc/vfstab
修改/etc/vfstab


转载自:http://blog.sina.com.cn/s/blog_6151984a0100fp4v.html
 


阅读(2896) | 评论(2) | 转发(0) |
0

上一篇:/etc/fstab 文件

下一篇:磁盘概念

给主人留下些什么吧!~~

chinaunix网友2011-03-08 14:37:23

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com

chinaunix网友2011-03-08 14:37:23

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com