create new tag
, view all tags
parted is a *nix utility for partioning disks.

As I learned more about it, I realized it might do what I needed to do as far as cloning a Vector Linux install from one hard drive to another as, in addition to partitioning, it can copy partitions.

I've recently tried that and ran into a lot of problems, possibly due to bad hardware or my mistakes. This page is pretty much a mess at this point (at least starting from #Useful_Examples -- I do plan to fix it up, once I figure out the problems).

See AboutThesePages.



Here's a list of supported features (by filesystem) from http://www.gnu.org/software/parted/parted.html:

Hmm, this is interesting -- wonder if I really want this here or just refer to it (or maybe just show the table) -- the original page is copyright by the FSF with their permission to copy verbatim with their notice intact -- question is, is what I've copied here more than fair use?

(Copied on 27 Feb 2003 at which time I saw versions 1.4.x, 1.6.2, and 1.6.4 available for download from wherever I downloaded them from.)

Supported disk labels: raw access (useful for RAID and LVM), MS-DOS partition tables, Intel GPT partition tables, MIPS partition tables, PC98 partition tables, Sun and BSD disk labels and Macintosh partition maps.

Supported operations

File system detect create resize copy check
ext2        *      *      *1     *2   *3
ext3        *             *1     *2   *3
fat16       *      *      *4     *5   *
fat32       *      *      *      *    *
linux-swap  *      *      *      *    *
HFS         *
JFS         *
NTFS        *
ReiserFS    *      *6     *1, 6  *6   *6
UFS         *
XFS         *

Notes (for the table above):

  1. For ext2, ext3 and reiserfs: the start of the partition must stay fixed.
  2. For ext2, ext3: the partition you copy to must be bigger or exactly the same size as the partition you copy from.
  3. For ext2 and ext3: the checking is limited to ensuring the resize and copy commands will be ok.
  4. For fat: the size of the new partition after resizing or copying is restricted by the cluster size. Parted can shrink the cluster size, so you can always shrink your partition. However, if you can't use FAT32 for some reason, you may not be able to grow your partition.
  5. Parted supports both FAT16 and FAT32. Parted can convert file systems between FAT16 and FAT32, if necessary.
  6. Reiserfs support is enabled if you install libreiserfs, available at http://reiserfs.osdn.org.ua. (It is likely to be availabe soon from http://www.namesys.com)


Some notes from http://www.gnu.org/manual/parted-1.6.1/html_mono/parted.html#SEC10:

<very pseudo Backus Naur form>

# parted <device> [<command>] [<command>]


  • Be careful with device_minor_numbers -- they may change as you add and delete partitions (not sure if this occurs in a single session of parted, in the next session, or after a reboot -- will have to check)


# parted /dev/sda resize 1 52 104 mkfs 2 fat16

Resize command:

resize <device_minor_number> <new_start(in MB)> <new_end(in MB)>


  • Some file types do not allow specifying a new_start position -- may need to do a workaround of cloning a drive to some other location, then cloning it back to the desired location (assuming there is sufficient space on this or another hard drive) -- you can clone partition (images) within parted


resize 1 52 104

Parted Commands

Here is a reminder of the available commands and their syntax, but there are a lot of ifs, ands, and buts -- don't try to use these without having read the respective section of http://www.gnu.org/manual/parted-1.6.1/html_mono/parted.html#SEC10 carefully.

Note to me: Looks like this was a waste of time -- most of it is on the manpage and seems pretty clear to me (now -- did I have to go through this exercise to get it to be clear to me? Must others?

  • check <minor>
  • cp [<from-device>] <from-minor> <to-minor>
  • help [<command>]
  • mklabel <label-type>
  • mkfs <minor> <fs-type>
  • mkpart <part-type> [<fs-type>] <start> <end>
  • mkpartfs <part-type> <fs-type> <start> <end>
  • move <minor> <start> [<end>]
  • name <minor> <name>
  • print
  • quit
  • rescue <start> <end>
  • resize <minor> <start> <end>
  • rm <minor>
  • select <device>
  • set <minor> <flag> <state>

The next useful step could be to list all the possibilities for things like label-type, part-type, fs-type, flag, and state, but even if I do, not all fs-types are valid in all commands (for example).

Useful Examples

(for my purposes)

This is not ready for prime time see #Recent_Experience.

Are there some preliminaries when starting with a blank (or previously used) disk? Must I create a label? Still not sure -- the one disk I worked on had an msdos label, but it originally had windows installed.

Must I set some flags?

If I want to run this as a script under parted, do I put all these commands in a file and then issue a command like parted <device> <filename>?


parted /dev/hda mkpartfs primary linux-swap 0 256

parted /dev/hda mkpartfs primary ext3 256 1200

parted /dev/hda cp /dev/hdb 2 2

parted /dev/hda resize 2 256 <hda-size>

Aside 1: Here's how to copy the MBR from one disk to another (I don't know if there's a way to do it "within" parted):

dd if=/dev/hda of=/dev/hdb count=1 bs=512

Aside 2: Here's how to setup and activate a swap partition (not within parted -- I can certainly make a swap partition within parted, not sure I can activate it):

To set up a swap partition:

# mkswap -f /dev/hda5

To activate the swap area:

# swapon /dev/hda5

Recent Experience

Last night (20 Feb 2003) I attempted to use parted interactively to clone a hard drive with Vector Linux installed.

The hard drive to be cloned might be bad -- I had some trouble with it before, so that might be the cause of some of my problems.

I started parted without specifying a device and it found the one I wanted to work on (/dev/hdc and told me the drive parameters). (In a script, make sure you specify the device.

It already had an OS installed so I removed those partitions using (parted) rm 3 (then 2, then 1). When I was done, it still had an msdos label, which I left (because I didn't know how to remove it, and I assumed it was required).

I created a swap partition using mkpartfs primary linux-swap 0 256

I attempted to create the intended root partition using mkpartfs primary ext3 256 1200 which didn't work because parted can't make an ext3 filesystem.

Considered two options, tried this:

  • made a partition using mkpart primary 256 1200

  • copied the existing ext3 partition to this using cp /dev/hda 2 2 (This took a little over 4 minutes, as predicted by parted, and seemed to work smoothly, making me thing the hard drive is OK -- still not sure.)

Ran p just to see what was going on -- partition 2 was marked as ext3.

Other option would be to exit parted, run something like mkfs.ext3 on the partition made above.

Exited parted, tried to properly set up lilo doing (something like) this:

mount -t ext3 /dev/hdc2 /mnt/temp
chroot /mnt/temp /sbin/lilo
umount /mnt/temp

UPDATE: Eventually got the above to work at least once when the target disk (MBR) was hda and the source disk (MBR) was hdc. (IIRC, earlier failures occurred when the target disk was not hda and that intuitively makes some sense (because all the things like fstab use the hda notation) but I can't explain fully.)

I tried a number of things around this point in time. Probably the next thing I did was power down and move cables to make the cloned hard drive hda and tried to boot. No luck -- I think at this point I got the first of the L 99 99 99 ... indication on bootup. Oops, no got some different indication at this point.

Booted with a parted boot and root floppy pair, started looking around. Mounted /dev/hda2 again, went to look at /etc/lilo.conf. Noticed that one of the parameters pointed to /hda rather than /hda2 (or did it say hdc?? need to double check.) Anyway, saved and closed up, and rebooted (I'm almost certain I forgot to rerun lilo. This time on bootup I got the L 99 99 99 ... (Along in here I ran a google search and found some pages (not many -- maybe 9000 but many in the first 100 were false hits on things like 99.99 or whatever) that dealt with the l 99 99 ... one page hinted that (re)running lilo might solve the problem. I thought I saw some things that referred to the superblock, but never found pages that specifically discussed that or what to do to fix it. -- Maybe the old notes from Civileme (if I found them -- might be on Wikilearn, I'll try a search on superblock in Wikilearn.)

Shutdown, rebooted from parted floppy again, checked /etc/lilo.conf again, ran /sbin/lilo, and rebooted. Again the L 99 99 99 ...

Another point I almost forgot -- as I was working with the "problem drive" (not the "known good hard drive"), I occasionally got messages about problems, sometimes from parted, other times as I ran /sbin/lilo. The gist was that the CHA geometry didn't agree with something else (the LBA geometry??). In running LILO I was given the option to ignore or fix (IIRC). The first time I tried ignore and (eventually) rebooted. Later I tried the other option and (eventually) rebooted. Neither one seemed to help.

Somewhere along in this sequence of events I checked /etc/fstab and found it completely empty. (Or maybe it only had an entry for the "proc" devices although I think when I found that I checked further and decided that was the fstab on the boot / root floppies -- the one on the hard drive was completely blank.)

Decided to install the other hard drive (with what I thought was a good install), boot from that with the intention of copying /etc/fstab.

It would not boot -- got an L 01 01 01 ... indication. Booted the parted floppies and looked around at /etc/fstab (OK, a ton of comments but some apparently correct entries included), /etc/lilo.conf (looked OK).

Now I wasn't certain whether the original install was not good or whether maybe parted had done something to it (even though I ran parted "on" the other hard drive not this one). Note: I had done one reboot to run the ./cfkscript2, so I know it worked reasonably well at that point -- sound had tested OK, and I was almost certain I had rebooted and logged in (and saw X).

Anyway, I tried several new installs on the known good hard drive, ran into some sort of problem each time. (I was using possibly bad CD-Rom drives from CFK to test them -- at first I used a 24X which seemed to work OK. Then I switched to one that was definitely dead (tray would not open) -- opened it up, could not find an obvious problem. Finally switched to the CD-Rom installed in the system, which, AFAIK, is good (I used it before for successful Vector and Mandrake 9.0 installs (on the "known good hard drive".

So, I'm concerned about the "known good hard drive" at this point. Will try Vector again with a different CD (disk) (and or Mandrake 9.0). Then try another known good CD-Rom.

I can't imagine that parted "broke" the "known good hard drive", but I don't know for sure.

<I'll be out of town for a few days, so won't resume this effort until sometime next week.>


See ResourceRecommendations. Feel free to add additional resources to these lists, but please follow the guidelines on ResourceRecommendations including ResourceRecommendations#Guidelines_for_Rating_Resources.


  • (rhk) [[][]] --

Recommended for Specific Needs

  • (rhk) [[][]] --

Recommended by Others

No Recommendation

  • (rhk) [[][]] --

Not Recommended

  • (rhk) [[][]] --


  • () RandyKramer - 18 Jul 2002
  • <If you edit this page: add your name here; move this to the next line; and include your comment marker (initials), if you have created one, in parenthesis before your WikiName.>

Page Ratings

Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2003-03-03 - RandyKramer
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiLearn? WebBottomBar">Send feedback
See TWiki's New Look