Re: sfdisk and 1MiB post-MBR gap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 09, 2010 at 09:00:35PM -0400, Eric Thibodeau wrote:
> As per ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/v2.18/v2.18-ReleaseNotes :
> 
> fdisk(8):
>   - supports new command line option "-c" to switch off DOS mode
>   - uses 1MiB offset for the first partition
>     (all these changes are already in the release 2.17.2)
> 
> I presume the 1MiB offset is to accomodate for grub2. 

 No, the offset (and alignment to MiBs) is there for compatibility and
 portability (raids, 4K sector disks, win7, ...).

> My attempts in partitioning a drive with a 1MiB post-MBR gap failed

 sfdisk has tendency to use CHS to calculate partition size, it means
 that 1MiB does not have to be on cylinder boundary. You have to use
 sectors as basic units.

 The another problem is that it checks against cylinder boundary, so
 you need to use --force ...

> with the following command line call:
> 
> sfdisk -uM -L /dev/sda <<-EOF

 try to use -uS, it seems that sfdisk rounds to cylinders if magabyte
 is specified (this should be fixed).

> 1,256,fd
> ,512,fd
> ,,fd
> ;
> EOF

 for example:

   sfdisk --force -uS /dev/sdb <<EOF
   2048 102400 0x83
   104448 1206272 0x83
   EOF

 result:

   sfdisk -uS -l /dev/sdb

   Device Boot       Start       End   #sectors  Id  System
   /dev/sdb1          2048    104447     102400  83  Linux
   /dev/sdb2        104448   1310719    1206272  83  Linux


 My suggestion is to use fdisk rather than sfdisk, if you really need
 create partitions from script than is probably the best way to to
 create the partitions by fdisk and then dump the layout by 
 
    sfdisk -uS -d <dev> > part.txt

 and then call from scripts

    sfdisk <dev> < part.txt

 or use the latest versions of GNU Parted.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux