免费注册 查看新帖 |

Chinaunix

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

Examples of the use of sfdisk 3.0(转载) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-07-04 11:16 |只看该作者 |倒序浏览
Examples of the use of sfdisk 3.0 (to partition a disk)
Input lines have fields ,,... - see sfdisk.8.
Usually no  is given, and input lines start with a comma.
Before doing anything with a disk, make sure it is not in use;
unmount all its file systems, and say swapoff to its swap partitions.
(The final BLKRRPART ioctl will fail if anything else still uses
the disk, and you will have to reboot. It is easier to first make
sure that nothing uses the disk, e.g., by testing:
        % umount /dev/sdb1
        % sfdisk -R /dev/sdb
        BLKRRPART: Device or resource busy
      * Device busy for revalidation (usage=2)
        % swapoff /dev/sdb3
        % sfdisk -R /dev/sdb
      * sdb: sdb1  sdb3
        %
Note that the starred messages are kernel messages, that may be
logged somewhere, or written to some other console.
In sfdisk 3.01 sfdisk automatically does this check, unless told not to.)
1. One big partition:
        sfdisk /dev/hda =32M
/dev/hda3        51+   203    153-   156468    5  Extended
/dev/hda4         0      -      0         0    0  Empty
/dev/hda5        51+    71-    21-    20603+   4  DOS 16-bit FAT
-----------------------------------------------------------------------
All these rounded numbers look better in cylinder units:
        % sfdisk -l /dev/hda
-----------------------------------------------------------------------
   Device Boot Start     End   #cyls   #blocks   Id  System
/dev/hda1          0+      5       6-     1223+   a  OS/2 Boot Manager
/dev/hda2          6     256     251     51204    6  DOS 16-bit FAT >=32M
/dev/hda3        257    1023     767    156468    5  Extended
/dev/hda4          0       -       0         0    0  Empty
/dev/hda5        257+    357     101-    20603+   4  DOS 16-bit FAT =32M
/dev/hda3        257    1023     767    156468    5  Extended
/dev/hda4          0       -       0         0    0  Empty
/dev/hda5        257+    357     101-    20603+   4  DOS 16-bit FAT =32M
         7  OS/2 HPFS or QNX or Advanced UNIX
         8  AIX data
         9  AIX boot or Coherent
         a  OS/2 Boot Manager
        ...
4. Preserving the sectors changed by sfdisk.
        % sfdisk -O save-hdd-partition-sectors /dev/hda
        ...
   will write the sectors overwritten by sfdisk to file.
   If you notice that you trashed some partition, you may
   be able to restore things by
        % sfdisk -I save-hdd-partition-sectors /dev/hda
        %
5. Preserving some old partitions.
        % sfdisk -N2 /dev/hda
        ...
   will only change the partition /dev/hda2, and leave the rest
   unchanged. The most obvious application is to change an Id:
        % sfdisk -N7 /dev/hda
        ,,63
        %
-----------------------------------------------------------------------
Old situation:
   Device Boot Start     End   #cyls   #blocks   Id  System
/dev/hda1          0+      5       6-     1223+   a  OS/2 Boot Manager
...
/dev/hda6        358+    438      81-    16523+  82  Linux swap
/dev/hda7        439+   1023     585-   119339+  83  Linux native
New situation:
   Device Boot Start     End   #cyls   #blocks   Id  System
/dev/hda1          0+      5       6-     1223+   a  OS/2 Boot Manager
...
/dev/hda6        358+    438      81-    16523+  82  Linux swap
/dev/hda7        439+   1023     585-   119339+  63  GNU HURD
-----------------------------------------------------------------------
   Note that changing a logical partition into an empty partition
   will decrease the number of all subsequent logical partitions.   
6. Deleting a partition.
At first I thought of having an option -X# for deleting partitions,
but there are several ways in which a partition can be deleted, and
it is probably better to handle this just as a general change.
        % sfdisk -d /dev/hda > ohda
will write the current tables on the file `ohda'.
-----------------------------------------------------------------------
% cat ohda
# partition table of /dev/hda
unit: sectors
/dev/hda1 : start=        1, size=   40799, Id= 5
/dev/hda2 : start=    40800, size=   40800, Id=83
/dev/hda3 : start=    81600, size=  336192, Id=83
/dev/hda4 : start=        0, size=       0, Id= 0
/dev/hda5 : start=        2, size=   40798, Id=83
-----------------------------------------------------------------------
In order to delete the partition on /dev/hda3, edit this file
and feed the result to sfdisk again.
-----------------------------------------------------------------------
% emacs ohda
% cat ohda
# partition table of /dev/hda
unit: sectors
/dev/hda1 : start=        1, size=   40799, Id= 5
/dev/hda2 : start=    40800, size=   40800, Id=83
/dev/hda3 : start=        0, size=       0, Id= 0
/dev/hda4 : start=        0, size=       0, Id= 0
/dev/hda5 : start=        2, size=   40798, Id=83
% sfdisk /dev/hda

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

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP