NAME

stdbuf - Run COMMAND, with modified buffering operations for its standard streams.

SYNOPSIS

stdbuf OPTION... COMMAND

DESCRIPTION

Run COMMAND, with modified buffering operations for its standard streams.

Mandatory arguments to long options are mandatory for short options too.

-i--input=MODE
Adjust standard input stream buffering
-o--output=MODE
Adjust standard output stream buffering
-e--error=MODE
Adjust standard error stream buffering
--help
display this help and exit
--version
output version information and exit

If MODE is `L' then corresponding stream will be line buffered. This option is invalid with standard input.

If MODE is `0' then corresponding stream will be unbuffered.

Otherwise MODE is a number which may be followed by one of the following: KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. In this case the corresponding stream will be fully buffered with the buffer size set to MODE bytes.

NOTE: If COMMAND adjusts the buffering of its standard streams (`tee' does for e.g.) then that will override corresponding settings changed by `stdbuf'. Also some filters (like `dd' and `cat' etc.) don't use streams for I/O, and are thus unaffected by `stdbuf' settings.

EXAMPLES

tail -f access.log | stdbuf -oL cut -d ' ' -f1 | uniq 
This will immedidately display unique entries from access.log

BUGS

On GLIBC platforms, specifying a buffer size, i.e. using fully buffered mode will result in undefined operation.

AUTHOR

Written by Pádraig Brady.

REPORTING BUGS

Report stdbuf bugs to bug-coreutils@gnu.org 
GNU coreutils home page: <http://www.gnu.org/software/coreutils/
General help using GNU software: <http://www.gnu.org/gethelp/>

COPYRIGHT

Copyright © 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. 
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

SEE ALSO

The full documentation for stdbuf is maintained as a Texinfo manual. If the info and stdbuf programs are properly installed at your site, the command

info coreutils 'stdbuf invocation'

should give you access to the complete manual.

sfdisk(8) - Linux man page

Name

sfdisk - Partition table manipulator for Linux

Synopsis

sfdisk [optionsdevice
sfdisk -s [partition]

Description

sfdisk has four (main) uses: list the size of a partition, list the partitions on a device, check the partitions on a device, and - very dangerous - repartition a device.

sfdisk doesn't understand GUID Partition Table (GPT) and it is not designed for large partitions. In particular case use more advanced GNU parted(8).

Note that sfdisk does not align partitions to block device I/O limits. This functionality is provided by fdisk(8).

List Sizes

sfdisk -s partition gives the size of partition in blocks. This may be useful in connection with programs like mkswap(8) or so. Here partition is usually something like /dev/hda1 or/dev/sdb12, but may also be an entire disk, like /dev/xda.

% sfdisk -s /dev/hda9
81599
%

If the partition argument is omitted, sfdisk will list the sizes of all disks, and the total:

% sfdisk -s
/dev/hda: 208896
/dev/hdb: 1025136
/dev/hdc: 1031063
/dev/sda: 8877895
/dev/sdb: 1758927
total: 12901917 blocks
%

List Partitions

The second type of invocation: sfdisk -l [optionsdevice will list the partitions on this device. If the device argument is omitted, the partitions on all hard disks are listed.

% sfdisk -l /dev/hdc
Disk /dev/hdc: 16 heads, 63 sectors, 2045 cylinders
Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from
0
Device Boot Start End #cyls #blocks Id System
/dev/hdc1 0+ 406 407- 205096+ 83 Linux native
/dev/hdc2 407 813 407 205128 83 Linux native
/dev/hdc3 814 2044 1231 620424 83 Linux native
/dev/hdc4 0 - 0 0 0 Empty
%

The trailing - and + signs indicate that rounding has taken place, and that the actual value is slightly less (more). To see the exact values, ask for a listing with sectors as unit.

Check partitions

The third type of invocation: sfdisk -V device will apply various consistency checks to the partition tables on device. It prints 'OK' or complains. The -V option can be used together with -l. In a shell script one might use sfdisk -V -q device which only returns a status.

Create partitions

The fourth type of invocation: sfdisk device will cause sfdisk to read the specification for the desired partitioning of device from its standard input, and then to change the partition tables on that disk. Thus, it is possible to use sfdisk from a shell script. When sfdisk determines that its standard input is a terminal, it will be conversational; otherwise it will abort on any error.

BE EXTREMELY CAREFUL - ONE TYPING MISTAKE AND ALL YOUR DATA IS LOST

As a precaution, one can save the sectors changed by sfdisk:

% sfdisk /dev/hdd -O hdd-partition-sectors.save
...
%

Then, if you discover that you did something stupid before anything else has been written to disk, it may be possible to recover the old situation with

% sfdisk /dev/hdd -I hdd-partition-sectors.save
%

(This is not the same as saving the old partition table: a readable version of the old partition table can be saved using the -d option. However, if you create logical partitions, the sectors describing them are located somewhere on disk, possibly on sectors that were not part of the partition table before. Thus, the information the -O option saves is not a binary version of the output of -d.)

There are many options.

Options

-v or --version
Print version number of sfdisk and exit immediately.
-? or --help
Print a usage message and exit immediately.
-T or --list-types
Print the recognized types (system Id's).
-s or --show-size
List the size of a partition.
-g or --show-geometry
List the kernel's idea of the geometry of the indicated disk(s).
-G or --show-pt-geometry
List the geometry of the indicated disks guessed by looking at the partition table.
-l or --list
List the partitions of a device.
-d
Dump the partitions of a device in a format useful as input to sfdisk. For example,

% sfdisk -d /dev/hda > hda.out
% sfdisk /dev/hda < hda.out

will correct the bad last extended partition that the OS/2 fdisk creates.

-V or --verify
Test whether partitions seem correct. (See above.)
-i or --increment
Number cylinders etc. starting from 1 instead of 0.
-N number
Change only the single partition indicated. For example:

% sfdisk /dev/hdb -N5
,,,*
%

will make the fifth partition on /dev/hdb bootable ('active') and change nothing else. (Probably this fifth partition is called /dev/hdb5, but you are free to call it something else, like '/my_equipment/disks/2/5' or so).

-A number
Make the indicated partition(s) active, and all others inactive.
-c or --id number [Id]
If no Id argument given: print the partition Id of the indicated partition. If an Id argument is present: change the type (Id) of the indicated partition to the given value. This option has the two very long forms --print-id and --change-id. For example:

% sfdisk --print-id /dev/hdb 5
6
% sfdisk --change-id /dev/hdb 5 83
OK

first reports that /dev/hdb5 has Id 6, and then changes that into 83.

-uS or -uB or -uC or -uM
Accept or report in units of sectors (blocks, cylinders, megabytes, respectively). The default is cylinders, at least when the geometry is known.
-x or --show-extended
Also list non-primary extended partitions on output, and expect descriptors for them on input.
-C cylinders
Specify the number of cylinders, possibly overriding what the kernel thinks.
-H heads
Specify the number of heads, possibly overriding what the kernel thinks.
-S sectors
Specify the number of sectors, possibly overriding what the kernel thinks.
-f or --force
Do what I say, even if it is stupid.
-q or --quiet
Suppress warning messages.
-L or --Linux
Do not complain about things irrelevant for Linux.
-D or --DOS
For DOS-compatibility: waste a little space. (More precisely: if a partition cannot contain sector 0, e.g. because that is the MBR of the device, or contains the partition table of an extended partition, then sfdisk would make it start the next sector. However, when this option is given it skips to the start of the next track, wasting for example 33 sectors (in case of 34 sectors/track), just like certain versions of DOS do.) Certain Disk Managers and boot loaders (such as OSBS, but not LILO or the OS/2 Boot Manager) also live in this empty space, so maybe you want this option if you use one.
-E or --DOS-extended
Take the starting sector numbers of "inner" extended partitions to be relative to the starting cylinder boundary of the outer one, (like some versions of DOS do) rather than to the starting sector (like Linux does). (The fact that there is a difference here means that one should always let extended partitions start at cylinder boundaries if DOS and Linux should interpret the partition table in the same way. Of course one can only know where cylinder boundaries are when one knows what geometry DOS will use for this disk.)
--IBM or --leave-last
Certain IBM diagnostic programs assume that they can use the last cylinder on a disk for disk-testing purposes. If you think you might ever run such programs, use this option to tell sfdisk that it should not allocate the last cylinder. Sometimes the last cylinder contains a bad sector table.
-n
Go through all the motions, but do not actually write to disk.
-R
Only execute the BLKRRPART ioctl (to make the kernel re-read the partition table). This can be useful for checking in advance that the final BLKRRPART will be successful, and also when you changed the partition table 'by hand' (e.g., using dd from a backup). If the kernel complains ('device busy for revalidation (usage = 2)') then something still uses the device, and you still have to unmount some file system, or say swapoff to some swap partition.
--no-reread
When starting a repartitioning of a disk, sfdisk checks that this disk is not mounted, or in use as a swap device, and refuses to continue if it is. This option suppresses the test. (On the other hand, the -f option would force sfdisk to continue even when this test fails.)
-O file
Just before writing the new partition, output the sectors that are going to be overwritten to file (where hopefully file resides on another disk, or on a floppy).
-I file
After destroying your filesystems with an unfortunate sfdisk command, you would have been able to restore the old situation if only you had preserved it using the -O flag.

Theory

Block 0 of a disk (the Master Boot Record) contains among other things four partition descriptors. The partitions described here are called primary partitions.

A partition descriptor has 6 fields:

struct partition {
unsigned char bootable; /* 0 or 0x80 */
hsc begin_hsc;
unsigned char id;
hsc end_hsc;
unsigned int starting_sector;
unsigned int nr_of_sectors;
}

The two hsc fields indicate head, sector and cylinder of the begin and the end of the partition. Since each hsc field only takes 3 bytes, only 24 bits are available, which does not suffice for big disks (say > 8GB). In fact, due to the wasteful representation (that uses a byte for the number of heads, which is typically 16), problems already start with 0.5GB. However Linux does not use these fields, and problems can arise only at boot time, before Linux has been started. For more details, see the lilo documentation.

Each partition has a type, its 'Id', and if this type is 5 or f ('extended partition') the starting sector of the partition again contains 4 partition descriptors. MSDOS only uses the first two of these: the first one an actual data partition, and the second one again an extended partition (or empty). In this way one gets a chain of extended partitions. Other operating systems have slightly different conventions. Linux also accepts type 85 as equivalent to 5 and f - this can be useful if one wants to have extended partitions under Linux past the 1024 cylinder boundary, without DOS FDISK hanging. (If there is no good reason, you should just use 5, which is understood by other systems.)

Partitions that are not primary or extended are called logical. Often, one cannot boot from logical partitions (because the process of finding them is more involved than just looking at the MBR). Note that of an extended partition only the Id and the start are used. There are various conventions about what to write in the other fields. One should not try to use extended partitions for data storage or swap.

Input Format

 

sfdisk reads lines of the form

<start> <size> <id> <bootable> <c,h,s> <c,h,s>

where each line fills one partition descriptor.

Fields are separated by whitespace, or comma or semicolon possibly followed by whitespace; initial and trailing whitespace is ignored. Numbers can be octal, decimal or hexadecimal, decimal is default. When a field is absent or empty, a default value is used.

The <c,h,s> parts can (and probably should) be omitted - sfdisk computes them from <start> and <size> and the disk geometry as given by the kernel or specified using the -H, -S, -C flags.

Bootable is specified as [*|-], with as default not-bootable. (The value of this field is irrelevant for Linux - when Linux runs it has been booted already - but might play a role for certain boot loaders and for other operating systems. For example, when there are several primary DOS partitions, DOS assigns C: to the first among these that is bootable.)

Id is given in hex, without the 0x prefix, or is [E|S|L|X], where L (LINUX_NATIVE (83)) is the default, S is LINUX_SWAP (82), E is EXTENDED_PARTITION (5), and X is LINUX_EXTENDED (85).

The default value of start is the first nonassigned sector/cylinder/...

The default value of size is as much as possible (until next partition or end-of-disk).

However, for the four partitions inside an extended partition, the defaults are: Linux partition, Extended partition, Empty, Empty.

But when the -N option (change a single partition only) is given, the default for each field is its previous value.

Example

The command

sfdisk /dev/hdc << EOF
0,407
,407
;
;
EOF

will partition /dev/hdc just as indicated above.

The command

sfdisk /dev/hdb << EOF
,3,L
,60,L
,19,S
,,E
,130,L
,130,L
,130,L
,,L
EOF

will partition /dev/hdb into two Linux partitions of 3 and 60 cylinders, a swap space of 19 cylinders, and an extended partition covering the rest. Inside the extended partition there are four Linux logical partitions, three of 130 cylinders and one covering the rest.

With the -x option, the number of input lines must be a multiple of 4: you have to list the two empty partitions that you never want using two blank lines. Without the -x option, you give one line for the partitions inside a extended partition, instead of four, and terminate with end-of-file (^D). (And sfdisk will assume that your input line represents the first of four, that the second one is extended, and the 3rd and 4th are empty.)

DOS 6.x WARNING

The DOS 6.x FORMAT command looks for some information in the first sector of the data area of the partition, and treats this information as more reliable than the information in the partition table. DOS FORMAT expects DOS FDISK to clear the first 512 bytes of the data area of a partition whenever a size change occurs. DOS FORMAT will look at this extra information even if the /U flag is given -- we consider this a bug in DOS FORMAT and DOS FDISK.

The bottom line is that if you use sfdisk to change the size of a DOS partition table entry, then you must also use dd to zero the first 512 bytes of that partition before using DOS FORMAT to format the partition. For example, if you were using sfdisk to make a DOS partition table entry for /dev/hda1, then (after exiting sfdisk and rebooting Linux so that the partition table information is valid) you would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero the first 512 bytes of the partition. BE EXTREMELY CAREFUL if you use the dd command, since a small typo can make all of the data on your disk useless.

For best results, you should always use an OS-specific partition table program. For example, you should make DOS partitions with the DOS FDISK program and Linux partitions with the Linux sfdisk program.

Drdos Warnings

Stephen Tweedie reported (930515): 'Most reports of superblock corruption turn out to be due to bad partitioning, with one filesystem overrunning the start of the next and corrupting its superblock. I have even had this problem with the supposedly-reliable DRDOS. This was quite possibly due to DRDOS-6.0's FDISK command. Unless I created a blank track or cylinder between the DRDOS partition and the immediately following one, DRDOS would happily stamp all over the start of the next partition. Mind you, as long as I keep a little free disk space after any DRDOS partition, I don't have any other problems with the two coexisting on the one drive.'

A. V. Le Blanc writes in README.efdisk: 'Dr. DOS 5.0 and 6.0 has been reported to have problems cooperating with Linux, and with this version of efdisk in particular. This efdisk sets the system type to hexadecimal 81. Dr. DOS seems to confuse this with hexadecimal 1, a DOS code. If you use Dr. DOS, use the efdisk command 't' to change the system code of any Linux partitions to some number less than hexadecimal 80; I suggest 41 and 42 for the moment.'

A. V. Le Blanc writes in his README.fdisk: 'DR-DOS 5.0 and 6.0 are reported to have difficulties with partition ID codes of 80 or more. The Linux 'fdisk' used to set the system type of new partitions to hexadecimal 81. DR-DOS seems to confuse this with hexadecimal 1, a DOS code. The values 82 for swap and 83 for file systems should not cause problems with DR-DOS. If they do, you may use the 'fdisk' command 't' to change the system code of any Linux partitions to some number less than hexadecimal 80; I suggest 42 and 43 for the moment.'

In fact, it seems that only 4 bits are significant for the DRDOS FDISK, so that for example 11 and 21 are listed as DOS 2.0. However, DRDOS itself seems to use the full byte. I have not been able to reproduce any corruption with DRDOS or its fdisk.

Bugs

There are too many options.

There is no support for non-DOS partition types.

See Also

cfdisk(8)fdisk(8)mkfs(8)parted(8)partprobe(8)kpartx(8)

Availability

The sfdisk command is part of the util-linux-ng package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.

Referenced By

guestfish(1), guestfs(3), ntfsresize(8)

some cmds,tools and utils man的更多相关文章

  1. android studio 各种问题

    1.dexDebug ExecException finished with non-zero exit value 2 全bug日志如下: (Error:Execution failed for t ...

  2. Webx框架自带的petstore

    Webx框架:http://openwebx.org/ petstore:webx3/webx-sample/petstore/tags/3.0/petstore 编译之后:mvn jetty:run ...

  3. webx--petstore

    配置对应环境,运行petstore 通过官网给的命令行方法,来运行petstore petstore是java ee的经典学习案例,下载链接 如何运行呢? 参见官网给的指导:webx官网 git cl ...

  4. Webx MVC分析(转)

    Webx框架:http://openwebx.org/ petstore:webx3/webx-sample/petstore/tags/3.0/petstore 编译之后:mvn jetty:run ...

  5. Java探针

    使用java代理来实现java字节码注入 使用JavaSsist可以对字节码进行修改 使用ASM可以修改字节码 使用Java代理和ASM字节码技术开发java探针工具可以修改字节码 备注:javass ...

  6. java30

    1.类的组合关系 当一个类中的字段是一个类时,就称类依赖于字段这个类,也称这两个类为组合关系 2.快捷键:ctrl+shift+c,多行的// ctrl+shift+/,多行的/-----/ 3.类的 ...

  7. Java探针-Java Agent技术-阿里面试题

    Java探针参考:Java探针技术在应用安全领域的新突破 最近面试阿里,面试官先是问我类加载的流程,然后问了个问题,能否在加载类的时候,对字节码进行修改 我懵逼了,答曰不知道,面试官说可以的,使用Ja ...

  8. JavaScript学习总结(六)——前端模块化开发

    早期的javascript版本没有块级作用域.没有类.没有包.也没有模块,这样会带来一些问题,如复用.依赖.冲突.代码组织混乱等,随着前端的膨胀,模块化显得非常迫切. 前端模块化规范如下: 一.前端模 ...

  9. AndroidO Treble架构下Hal进程启动及HIDL服务注册过程【转】

    本文转载自:https://blog.csdn.net/yangwen123/article/details/79854267 通过前面对Treble架构的介绍,我们知道,Android Framew ...

随机推荐

  1. 【bzoj4247】挂饰 背包dp

    题目描述 JOI君有N个装在手机上的挂饰,编号为1...N. JOI君可以将其中的一些装在手机上. JOI君的挂饰有一些与众不同——其中的一些挂饰附有可以挂其他挂件的挂钩.每个挂件要么直接挂在手机上, ...

  2. 【bzoj3166】[Heoi2013]Alo 可持久化Trie树+STL-set

    题目描述 Welcome to ALO ( Arithmetic and Logistic Online).这是一个VR MMORPG ,如名字所见,到处充满了数学的谜题.现在你拥有n颗宝石,每颗宝石 ...

  3. 浅谈android反调试之 签名校验

    反调试原理 很多时候,我们都需要进行修改修改应用程序的指令,然后重打包运行,重新打包就需要充签名. 利用签名的变化我们用于反调试.反调试实现代码如下: 为了更加隐藏,比较函数可能在SO层进行实现,如下 ...

  4. 一款基于bootstrap的文件上传插件,现在很多手机webapp都在用

    官网:http://plugins.krajee.com/file-input

  5. 转载 关于malloc

    1.函数原型及说明: void *malloc(long NumBytes):该函数分配了NumBytes个字节,并返回了指向这块内存的指针.如果分配失败,则返回一个空指针(NULL). 关于分配失败 ...

  6. hdu 3605 /状态合并最大流

    题意:N个人去m个星球,给出n个人可以去哪些星球的01矩阵.求是否能满足所有人都去.(n到10万,m<=10) 一看,起先一瞬间就建图,准备秒了,人向星球连边,直接最大流判断是否为n,提交超时. ...

  7. BZOJ2243 [SDOI2011]染色(树链剖分+线段树合并)

    题目链接 BZOJ2243 树链剖分 $+$ 线段树 线段树每个节点维护$lc$, $rc$, $s$ $lc$代表该区间的最左端的颜色,$rc$代表该区间的最右端的颜色 $s$代表该区间的所有连续颜 ...

  8. 洛谷——P1767 家族_NOI导刊2010普及(10)

    P1767 家族_NOI导刊2010普及(10) 题目描述 在一个与世隔绝的岛屿上,有一个有趣的现象:同一个家族的人家总是相邻的(这里的相邻是指东南西北四个方向),不同的家族之间总会有河流或是山丘隔绝 ...

  9. 会话跟踪技术Cookieless

    会话跟踪技术Cookieless   在Web应用中,通常使用Cookie记录用户的状态,如用户名.访问时间等信息.当进行HTTP请求的时候,会自动发送Cookie信息给服务器.服务器接收到,就可以判 ...

  10. 链表的排序 时间复杂度O(nlogn)

    思路:用归并排序.对一个链表采用递归进行二等分,直到每个部分有序,然后对其进行合并.其实就是两步,先分解,然后合并有序链表. 代码: //对链表采用递归排序 class Solution { publ ...