summaryrefslogtreecommitdiff
path: root/fdisk
AgeCommit message (Collapse)AuthorFilesLines
2010-03-19fdisk: fix -b <sectorsize>Karel Zak2-7/+15
The old fdisk (<2.17) does not differentiate between logical and physical sector size, it uses the <sectorsize> for everything. Now, we have logical and physical sectors size, but the -b option changes the logical size only. The second bug is that "fdisk -b <sz>" does not read topology information (it means that all I/O limits and physical sector size are 512 (default). The backwardly compatible bug fix is to override both sizes, logical and physical if "-b" is used. In future we can add a special option for physical size only. Signed-off-by: Karel Zak <kzak@redhat.com>
2010-03-16fdisk: correctly truncate and align translated partition namesPádraig Brady2-4/+15
* fdisk/Makefile.am: Depend on the mbsalign module. * fdisk/fdisk.c: Align using mbsalign rather than printf. [kzak@redhat.com: - use size_t for width to fix gcc warning] Reported-by: Makoto Kato <m_kato@ga2.so-net.ne.jp> Signed-off-by: Pádraig Brady <P@draigBrady.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-26fdisk: fix 'p' output for sun labelKarel Zak1-9/+9
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-19fdisk: swap VTOC values for warning messagesKarel Zak1-3/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-18sfdisk: make sure writes make it to disk in write_partitions()Bryn M. Reeves1-0/+5
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=565946 Signed-off-by: Bryn M. Reeves <bmr@errorists.org> Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-15fdisk: don't use 1MiB grain on small devicesKarel Zak1-3/+6
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-15fdisk: use 1MiB offset and grain always when possibleKarel Zak1-5/+14
It would be nice to minimize dependence between the disk layout and disk topology. We have to follow disk topology for alignment_offset and huge (> 1MiB) I/O sizes only. For all others disks we can use 1MiB grain and 1MiB offset. Reported-by: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-15fdisk: add -c option (switch off DOS mode)Karel Zak2-3/+15
* add -c to allows to switch off DOS mode from command line * recommend sectors (command 'u' or option -u) Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-15fdisk: fix ALIGN_UPKarel Zak1-0/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-15fdisk: fallback for topology valuesKarel Zak1-1/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-15fdisk: cleanup help, add -h optionKarel Zak3-34/+28
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-12fdisk: use more elegant way to count and check alignmentKarel Zak1-33/+34
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-12cfdisk: set '[New]' as default item on menu for non allocated space instead ↵Francesco Cosoleto1-1/+1
of '[Help]'. Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2010-02-11cfdisk: set '[Quit]' as default menu item on first run instead of '[Bootable]'.Francesco Cosoleto1-1/+3
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2010-02-09fdisk: cleanup warningsKarel Zak1-37/+23
* don't print: The number of cylinders for this disk is set to 12161. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) we really don't care about MS-DOS or extremely old LILO. * inform users that DOS-compatible mode is bad and deprecated thing (It's difficult to use 2048 sectors grain or 4KiB sectors or alignment_offset in DOS mode where all is based on cylinders...) * don't check for cylinders boundary in non-DOS mode * inform about sector and I/O sizes Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-09fdisk: fix default first sectorKarel Zak1-5/+4
The previous release 2.17 introduces aligned defaults for the first and last sectors on the partition. Unfortunately, there is endless loop when the code looks for first unused aligned sector. Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-09fdisk: cleanup alignment, default to 1MiB offsetKarel Zak1-21/+66
* add heuristic to detect that the device does not provide topology information. We can use topology if: - alignment_offset is not 0 - or optimal_io_size is not 0 - or minimal_io_size is not power of 2 * default to 1MiB offset for the start of the first partition if topology is unknown. This (2048 512-byte sectors) is Windows Vista default. * use optimal_io_size, minimal_io_size or 1MiB as a grain for partitions alignment Note that this all is used when DOS-compatible mode is disabled. Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-09fdisk: fix check_alignment()Karel Zak1-5/+5
The old version of check_alignment() does not work with extended partitions. Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-09fdisk: don't check alignment_offset against geometryKarel Zak1-12/+3
The alignment_offset is compensation for DOS compatible partitioning. It usually matches with disk geometry (e.g. 63 sectors), but the offset is also exported from phy.disks to RAIDs there the geometry don't match with the offset. So.. don't print unnecessary warning. Signed-off-by: Karel Zak <kzak@redhat.com>
2010-02-03Merge remote branch 'origin/master'LaMont Jones3-221/+66
Conflicts: tests/ts/blkid/images-fs/adaptec-raid.img.bz2 tests/ts/blkid/images-fs/ddf-raid.img.bz2 tests/ts/blkid/images-fs/gfs2.img.bz2 tests/ts/blkid/images-fs/hpt37x-raid.img.bz2 tests/ts/blkid/images-fs/isw-raid.img.bz2 tests/ts/blkid/images-fs/jbd.img.bz2 tests/ts/blkid/images-fs/jmicron-raid.img.bz2 tests/ts/blkid/images-fs/lvm2.img.bz2 tests/ts/blkid/images-fs/nvidia-raid.img.bz2 tests/ts/blkid/images-fs/ocfs2.img.bz2 tests/ts/blkid/images-fs/promise-raid.img.bz2 tests/ts/blkid/images-fs/reiser4.img.bz2 tests/ts/blkid/images-fs/romfs.img.bz2 tests/ts/blkid/images-fs/silicon-raid.img.bz2 tests/ts/blkid/images-fs/swap0.img.bz2 tests/ts/blkid/images-fs/swap1.img.bz2 tests/ts/blkid/images-fs/via-raid.img.bz2 tests/ts/blkid/images-fs/vmfs_volume.img.bz2 tests/ts/blkid/images-fs/zfs.img.bz2
2010-01-28fdisk: use "optimal I/O size" in warningsKarel Zak1-4/+4
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-01-28fdisk: use optimal_io_sizeKarel Zak1-11/+13
* rename the minimum_io_size variable to io_size * use blkid_topology_get_optimal_io_size() for io_size initialization * use blkid_topology_get_minimum_io_size() as a fallback solution for io_size initialization Signed-off-by: Karel Zak <kzak@redhat.com>
2010-01-22cfdisk: use libblkidMatthias König2-206/+49
Let cfdisk use the internal libblkid if available to get the filesystem type and label. [kzak@redhat.com: - remove old FS probing code from cfdisk - remove "Linux" prefix for filesystem names - enlarge fstype field in partition_info - restrict probing area by partition size] Signed-off-by: Matthias König <mk@phasorlab.de> Signed-off-by: Karel Zak <kzak@redhat.com>
2010-01-18Merge remote branch 'origin/master'LaMont Jones1-5/+0
2010-01-18Merge commit 'v2.17'LaMont Jones3-13/+10
2010-01-13fdisk: don't include scsi.hKarel Zak1-5/+0
The fdisksunlabel.c header file is unnecessary for fdisk/fdisksunlabel.h. Reported-by: Thomas Stalder <thomas@netsolux.ch> Signed-off-by: Karel Zak <kzak@redhat.com>
2010-01-06fdisk: sleep-after-sync and fsync usageKarel Zak3-9/+5
It seems that sleep() after sync() is unnecessary legacy. It's very probably unnecessary since kernel 1.3.20. For example the libparted does not to use sleep() at all. It seems that more important is fsync() usage in fdisks. For more details see http://marc.theaimsgroup.com/?l=linux-kernel&m=105545785306867&w=3 http://marc.theaimsgroup.com/?l=linux-kernel&m=105545848607353&w=3 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=276369 Currently we use fsync() in fdisk only. This patch also add fsync() to sfdisk and cfdisk. Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=276369 Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=502639 Signed-off-by: Karel Zak <kzak@redhat.com>
2010-01-04sfdisk: confused about disk sizeKarel Zak1-4/+5
The size of disk in the sfdisk command is based on number of cylinders (this is probably legacy from CHS epoch). That's wrong because partitions are addressed in sectors (LBA), so cylinders don't provide necessary resolution (granularity). On Sat, Jan 02, 2010 at 01:01:16PM +0100, Giulio wrote: > $ cat /sys/block/sda/size > 184549376 > > $ sfdisk -d /dev/sda > part.dump > $ cat part.dump > # partition table of /dev/sda > unit: sectors > > /dev/sda1 : start= 2048, size= 2097152, Id=83 > /dev/sda2 : start= 2099200, size= 12582912, Id=83 > /dev/sda3 : start= 14682112, size= 84934656, Id=83 > /dev/sda4 : start= 99616768, size= 84932608, Id=83 > > > $ sfdisk -L /dev/sda < part.dump > Checking that no-one is using this disk right now ... > OK > > Disk /dev/sda: 11487 cylinders, 255 heads, 63 sectors/track > Old situation: > Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 > > Device Boot Start End #cyls #blocks Id System > /dev/sda1 0+ 130- 131- 1048576 83 Linux > /dev/sda2 130+ 913- 784- 6291456 83 Linux > /dev/sda3 913+ 6200- 5287- 42467328 83 Linux > /dev/sda4 6200+ 11487- 5287- 42466304 83 Linux > Warning: given size (84932608) exceeds max allowable size (84921887) disk size: based on number of cylinders: 11487 * 8225280 = 94483791360 bytes based on number of sectors: 184549376 * 512 = 94489280512 bytes end of 4th partition (LBA in bytes): (99616768 + 84932608) * 512 = 94489280512 Reported-by: Giulio <giulioo@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2009-12-21Merge remote branch 'origin/master'LaMont Jones1-4/+4
2009-12-10po: fix msgid bugsKarel Zak1-4/+4
Reported-by: Petr Pisar <petr.pisar@atlas.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
2009-11-27Merge remote branch 'origin/master'LaMont Jones2-42/+272
2009-11-20build-sys: fix blkid CFLAGS in fdisk/Makefile.amKarel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-11-19Merge remote branch 'upstream/master'LaMont Jones1-2/+2
2009-11-18fdisk: offer aligned first sectorKarel Zak1-10/+35
Typical "new partition" dialog looks like: Partition number (1-4): 1 First sector (4-818687, default 4): ^^^^^^^^^ The range (e.g. 4-818687) depends on fdisk mode (DOS/non-DOS), but the default value should be always aligned. For example RAID5 device in the DOS mode: Disk /dev/md0: 419 MB, 419168256 bytes 2 heads, 4 sectors/track, 102336 cylinders, total 818688 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 65536 bytes Disk identifier: 0x081479c3 .... Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First sector (4-818687, default 128): <---- !!! Using default value 128 Last sector, +sectors or +size{K,M,G} (128-818687, default 818687): +10M Command (m for help): p .... Device Boot Start End Blocks Id System /dev/md0p1 128 20607 10240 83 Linux For non-DOS mode the range will be: First sector (128-818687, default 128): Signed-off-by: Karel Zak <kzak@redhat.com>
2009-11-18fdisk: align end of partition when defined by +size{K,M,G}Karel Zak1-13/+35
It's better to have disks without gaps between partitions, so it's better to align ends of partitions. Note, we don't care about end of partitions when the last sector has been explicitly requested by user. Signed-off-by: Karel Zak <kzak@redhat.com>
2009-11-18fdisk: check for partition boundaryKarel Zak1-1/+14
Disk /dev/md0: 419 MB, 419168256 bytes 2 heads, 4 sectors/track, 102336 cylinders, total 818688 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 65536 bytes Disk identifier: 0x081479c3 Device Boot Start End Blocks Id System /dev/md0p1 200 818687 409244 83 Linux Partition 1 does not start on physical block boundary. Signed-off-by: Karel Zak <kzak@redhat.com>
2009-11-18fdisk: print info and recommendations about alignmentKarel Zak1-4/+36
* inform user that phy.sector > log.sector * warn user when alignment_offset is not provided does, DOS-compatible mode is enabled and the default geo.sectors are not aligned * suggest to change display units to sectors (oh yes, fdisk default are cylinders...) Signed-off-by: Karel Zak <kzak@redhat.com>
2009-11-18fdisk: use minimal_io_size for the first partitionKarel Zak1-12/+34
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-11-18fdisk: add basic routines for LBA alignmentKarel Zak1-0/+73
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-11-18fdisk: read topology info from libblkidKarel Zak2-3/+46
and print ('p' command) info about logical and physical sectors and alignment_offset. minimum_io_size we don't use physical sector size directly, because on RAIDs is better to use minimum_io_size (aka stripe chunk size). For disk drives is minimum_io_size the same value as physical sector size. alignment_offset For compatibility with legacy operating systems some vendors provide disks where logical and physical sectors are aligned at sector 63 (= geometry.sectors). In other words the physical 4KB sectors start at LBA -1. Then the physical boundary is at: alignment_offset + N * phy_sector_size Signed-off-by: Karel Zak <kzak@redhat.com>
2009-11-05build-sys: remove LT_STATIC_LDFLAGSKarel Zak1-2/+2
It was really stupid idea to use *_LDFLAGS for some global variable. Signed-off-by: Karel Zak <kzak@redhat.com>
2009-11-05build-sys: cleanup static buildingKarel Zak1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-19Merge remote branch 'origin/master'LaMont Jones9-50/+49
Conflicts: mount/lomount.c
2009-10-17fdisk: fix strict-aliasing bugsKarel Zak6-6/+31
gcc 4.4 produces tons of "dereferencing type-punned pointer will break strict-aliasing rules" warnings for fdisk code where is char buffer[BUFSIZ]; ((struct disklabel *) MBRBuffer)->foo There are two ways how fix the problem: 1/ union { char buffer[BUFSIZ], struct disklabel label } MBRBuffer; 2/ use allocated buffer, this way seems less invasive. This patch implements 2/. Old version: $ make -C fdisk | grep -c warning 236 New version: $ make -C fdisk | grep -c warning 0 About aliasing: - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40665 - http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html - C99 Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-16fdisk: sgi label - remove duplicate swab16swab[16,32]() definitionsKarel Zak2-17/+6
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-16fdisk: use c.hKarel Zak3-4/+4
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-16sfdisk: use c.h, remove obsolete #ifdefsKarel Zak1-23/+8
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-10Merge remote branch 'origin/master'LaMont Jones2-2/+0
2009-10-09Remove now unused <sys/ioctl.h> includesGuillem Jover2-2/+0
Those became unused with the switch to the blkdev functions. Signed-off-by: Guillem Jover <guillem@hadrons.org>
2009-09-16Merge commit 'origin/master'LaMont Jones2-7/+10