Sponsored Content
Top Forums Shell Programming and Scripting Enhanced partition copy script (new & improved!) Post 302447896 by Corona688 on Tuesday 24th of August 2010 03:44:07 PM
Old 08-24-2010
One thing I've noticed that dd seems unable to do is properly save/restore "extended" partition information. It's not recorded in the boot sector, and dd-ing the "extended" device (not the partitions in it) doesn't seem to preserve it either. Where is it stored?
 

9 More Discussions You Might Find Interesting

1. Gentoo

How to copy single partition?

I presently backup my multi-OS multi-paritition boot drive (fedora core 4/ext3, WinXPServer/NTFS, WinXPHome/FAT32) with the command: telinit 1; cp /dev/sda /dev/sdb And this works. Is there a command to only copy a single partition instead of an entire device? And what about the grub... (12 Replies)
Discussion started by: siegfried
12 Replies

2. UNIX for Dummies Questions & Answers

slice & partition???

:confused: Hello, What is the difference between slice and partition on Solaris world? Regards (4 Replies)
Discussion started by: XNOR
4 Replies

3. Shell Programming and Scripting

How do I search first&second string & copy all content between them to other file?

Hi All, How do I search first string & second string and copy all content between them from one file to another file? Please help me.. Thanks In Advance. Regards, Pankaj (12 Replies)
Discussion started by: pankajp
12 Replies

4. UNIX for Advanced & Expert Users

copy a whole partition excluding specified.

Scenario: I would want to copy my / to /mnt, and to avoid recursion exclude /mnt. cp -avx / /mnt If i use the above i believe it would run recursively, and end up in mess. So how to do it ?! Basically this / is sda1, and /mnt is sda2 and sda1 is where only OS is available & currently... (2 Replies)
Discussion started by: thegeek
2 Replies

5. Shell Programming and Scripting

Perl Script to find & copy words from Web.

I need to write a perl script to search for a specific set of numbers that occur after a series of words but before another. Specifically, I need to locate the phrase today at the summit, then immediately prior to the words tonnes/day copy the number that will be between 100 and 9,999, for example,... (1 Reply)
Discussion started by: libertyforall
1 Replies

6. Filesystems, Disks and Memory

Using dd to copy a partition.

Here's a conundrum. I use a ThinkPad (T30) which has a slot on the side for the hard drive. It is very easy to swap this with another hard drive which I keep as a backup. Now when I copy the Linux partition from my (in use) hard drive to the backup one (in my UltraBay slot) it takes only 30... (0 Replies)
Discussion started by: newyorkpaulie
0 Replies

7. Shell Programming and Scripting

Compare & Copy Directories : Bash Script Help

Beginner/Intermediate shell; comfortable in the command line. I have been looking for a solution to a backup problem. I need to compare Directory 1 to Directory 2 and copy all modified or new files/directories from Directory 1 to Directory 3. I need the directory and file structure to be... (4 Replies)
Discussion started by: Rod
4 Replies

8. Shell Programming and Scripting

Script to overwrite & before that keep copy a file on many servers

I have ssh password less auth enable & script does the job well as well #/bin/bash for i in `cat ip` do scp /etc/resolv.conf root@$ip done But I need to take backup of the file i will overwrite .. is there any simple way ? Kindly respond (5 Replies)
Discussion started by: heman96
5 Replies

9. Red Hat

Shrink LVM partition & create new Linux Primary partition

Hello All, I have a Red Hat Linux 5.9 Server installed with one hard disk & 2 Partitions created on it as follows, /boot - Linux Partition & another is LVM - One VG & under that 5-6 Logical volumes(var,opt,home etc). Here my requirement is to take out 1GB of space from LVM ( Any logical... (5 Replies)
Discussion started by: gr8_usk
5 Replies
FIXPARTS(8)							  FixParts Manual						       FIXPARTS(8)

NAME
fixparts - MBR partition table repair utility SYNOPSIS
fixparts device DESCRIPTION
FixParts (aka fixparts) is a text-mode menu-driven program for repairing certain types of problems with Master Boot Record (MBR) partition tables. The program has three design goals, although a few additional features are supported, as well: * It can remove stray GUID Partition Table (GPT) data, which can be left behind on a disk that was once used as a GPT disk but then incompletely converted to the more common (as of 2011) MBR form. * It can repair mis-sized extended partitions -- either partitions that extend beyond the physical end of the disk or that overlap with nearby primary partitions. FixParts is designed in such a way that this type of repair occurs automatically, so if it's the only problem with your disk, you can launch the program and then immediately save the partition table, making no manual changes, and the program will fix the problem. * You can change primary partitions into logical partitions or vice-versa, within constraints imposed by the MBR data structures. Additional features include the ability to change partition type codes or boot/active flags, to delete partitions, and to recompute CHS values. With the possible exception of recomputing CHS values, these secondary features are better performed with fdisk, because fixpart's design means that it's likely to alter partition numbering even when such changes are not requested. The fixpart program employs a user interface similar to that of Linux's fdisk, but fixpart is much more specialized. Most importantly, you can't create new partitions with fixpart, although you can change primary/logical assignment. In the MBR scheme, partitions come in three varieties: primary These partitions are defined in the first sector of the hard disk and are limited in number to four. Some OSes, such as Windows and FreeBSD, must boot from a primary partition. extended Extended partitions are specialized primary partitions. They serve as holding areas for logical partitions. logical A disk can contain an arbitrary number of logical partitions (fixpart, however, imposes a limit of 124 logical partitions). All the logical partitions reside inside a single extended partition, and are defined using a linked-list data structure. This fact means that every logical partition be preceded by at least one sector of unallocated space to hold its defining data structure (an Extended Boot Record, or EBR). These distinctions mean that primary and logical partitions cannot be arbitrarily interspersed. A disk can contain one to three primary partitions, a block of one or more logical partitions, and one to three more primary partitions (for a total of three primary partitions, not counting the extended partition). Primary partitions may not be sandwiched between logical partitions, since this would mean placing a primary partition within an extended partition (which is just a specific type of primary partition). Unlike most disk utilities, fixpart's user interface ignores extended partitions. Internally, the program discards the information on the original extended partition and, when you tell it to save its changes, it generates a new extended partition to contain the then-defined logical partitions. This is done because most of the repairs and manipulations the tool performs require generating a fresh extended parti- tion, so keeping the original in the user interface would only be a complication. Another unusual feature of fixpart's user interface is that partition numbers do not necessarily correlate with primary/logical status. In most utilities, partitions 1-4 correspond to primary partitions, whereas partitions 5 and up are logical partitions. In fixpart, any parti- tion number may be assigned primary or logical status, so long as the rules for layout described earlier are obeyed. When the partition ta- ble is saved, partitions will be assigned appropriately and then tools such as the Linux kernel and fdisk will give them conventional num- bers. When it first starts, fixpart performs a scan for GPT data. If the disk looks like a conventional GPT disk, fixpart refuses to run. If the disk appears to be a conventional MBR disk but GPT signatures are present in the GPT primary or secondary header areas, fixpart offers to delete this extraneous data. If you tell it to do so, the program immediately wipes the GPT header or headers. (If only one header was found, only that one header will be erased, to minimize the risk of damaging a boot loader or other data that might have overwritten just one of the GPT headers.) With the exception of optionally erasing leftover GPT data when it first starts, fixpart keeps all changes in memory until the user writes changes with the w command. Thus, you can adjust your partitions in the user interface and abort those changes by typing q to quit without saving changes. OPTIONS
The fixparts utility supports no command-line options, except for specification of the target device. Most interactions with fixparts occur with its interactive text-mode menu. Specific functions are: a Toggle the active/boot flag. This flag is required by some boot loaders and OSes. c Recompute the cylinder/head/sector (CHS) values for all partitions. CHS addressing mode is largely obsolete, but some OSes and util- ities complain if they don't like the CHS values. Note that fixparts' CHS values are likely to be incorrect on disks smaller than about 8 GiB except on Linux. l Change a partition's status to logical. This option will only work if the current partition layout supports such a change. Note that if changing a partition's status in this way is not currently possible, making some other change may make it possible. For instance, omitting a partition that precedes the target partition may enable converting a partition to logical form if there had been no free sectors between the two partitions. o Omit a partition. Once omitted, the partition will still appear in the fixpart partition list, but it will be flagged as omitted. You can subsequently convert it to primary or logical form with the r or l commands, respectively. When you save your changes with w, though, the partition will be lost. p Display basic partition summary data. This includes partition's number, the boot/active flag's status, starting and ending sector numbers, primary/logical/omitted status, whether or not the partition may be converted to logical form, and the partition's MBR types code. q Quit from the program without saving your changes. Use this option if you just wanted to view information or if you make a mistake and want to back out of all your changes. r Change a partition's status to primary. This option will only work if the current partition layout supports such a change. Note that every partition can theoretically become a primary partition, although in some configurations, making this change will require omit- ting some partitions. If fixparts refuses to allow changing a partition to primary, you may need to convert other partitions to logical form or omit them entirely. s Sort partition entries. This option orders partitions in the display to match their on-disk positions, which can make understanding the disk layout easier in some cases. This option has no effect on the ultimate ordering of logical partitions, which are sorted before being saved. The order of primary partitions in the final saved partition table may be affected by this option. In both cases, as already noted, the partition numbers displayed by fixparts may not be the same as those used by the kernel or displayed by other partitioning tools. t Change a partition's type code. You enter the type code using a one-byte hexadecimal number. w Write data. Use this command to save your changes and exit from the program. ? Print the menu. Type this command (or any other unrecognized command) to see a summary of available options. BUGS
As of May 2012 (version 0.8.5), fixparts should be considered beta software. Known bugs and limitations include: * The program compiles correctly only on Linux, FreeBSD, Mac OS X, and Windows. Linux versions for x86-64 (64-bit), x86 (32-bit), and PowerPC (32-bit) have been tested, with the x86-64 version having seen the most testing. Under FreeBSD, 32-bit (x86) and 64-bit (x86-64) versions have been tested. Only 32-bit versions for Mac OS X and Windows have been tested. * The FreeBSD version of the program can't write changes to the partition table to a disk when existing partitions on that disk are mounted. (The same problem exists with many other FreeBSD utilities, such as gpt, fdisk, and dd.) This limitation can be overcome by typing sysctl kern.geom.debugflags=16 at a shell prompt. * The program can load only up to 128 partitions (4 primary partitions and 124 logical partitions). This limit can be raised by chang- ing the #define MAX_MBR_PARTS line in the basicmbr.h source code file and recompiling. * The program can read partitions only if the disk has correct LBA partition descriptors. These descriptors should be present on any disk over 8 GiB in size or on smaller disks partitioned with any but very ancient software. * The program makes no effort to preserve partition numbers. This can have consequences for boot loaders and for mounting filesystems via /etc/fstab. It may be necessary to edit configuration files or even to re-install your boot loader. * The program may change the order of partitions in the partition table. AUTHORS
Primary author: Roderick W. Smith (rodsmith@rodsbooks.com) Contributors: * Yves Blusseau (1otnwmz02@sneakemail.com) * David Hubbard (david.c.hubbard@gmail.com) * Justin Maggard (justin.maggard@netgear.com) * Dwight Schauer (dschauer@ti.com) * Florian Zumbiehl (florz@florz.de) SEE ALSO
cfdisk (8), cgdisk (8), fdisk (8), mkfs (8), parted (8), sfdisk (8) gdisk (8) sgdisk (8) http://en.wikipedia.org/wiki/Master_boot_record http://www.rodsbooks.com/fixparts/ AVAILABILITY
The fixparts command is part of the GPT fdisk package and is available from Rod Smith. Roderick W. Smith 0.8.5 FIXPARTS(8)
All times are GMT -4. The time now is 09:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy