Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Cloning a drive??

  • 05-11-2004 1:58pm
    #1
    Registered Users, Registered Users 2 Posts: 1,312 ✭✭✭


    Is it possible to clone a 20Gb hd to a 40Gb HD, and resize the partitions?

    Need this done to a couple systems.
    All linux based.

    preferable an automatic tool as i have no knowledge of linux YET!


Comments

  • Closed Accounts Posts: 16,793 ✭✭✭✭Hagar


    Try Norton Ghost. It doesn't care what OS you are using. Use a boot floppy. It will copy any size to any size as long as the target is big enough to hold the data ( as opposed to free space ).

    Then use Partition Magic to resize the partition.
    Creat subsequent clones from your 1st 40gb to cut down on work.


  • Registered Users, Registered Users 2 Posts: 1,312 ✭✭✭SLIM19198


    tried already, clones partitions but not boot sector/mbr, just loads all gibberish on boot

    not a nice experience ;-)


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 93,562 Mod ✭✭✭✭Capt'n Midnight


    Hagar wrote:
    Try Norton Ghost. It doesn't care what OS you are using. Use a boot floppy. It will copy any size to any size as long as the target is big enough to hold the data ( as opposed to free space ).

    Then use Partition Magic to resize the partition.
    Creat subsequent clones from your 1st 40gb to cut down on work.
    AFAIK you need a ghost license per machine cloned...

    Is the OS to be cloned Linux or are you looking for Linux tools ?
    for identical drives dd will do a sector by sector copy - after the first one
    you can use dd to cupy the first 446 bytes to rebuild the MBR (the bytes after this are the partition table and should be left alone.)
    partimage will generate images - for FAT32/NTFS it will expand the image to a larger partition, should do so for Ext as well
    qtparted - will edit partions and resize Fat32 and can call ntfsresize to resize ntfs partitions (if they are't fragmented and the mft isn't all over the gaff) it should do ext partitoins too. - backup the mbr first before resizing as it can trash the CHS settings leading to fun and games.


    Don't forget that you'll need to make sure the desired partition is active before you put in the other PC.

    If the OS is windows 2K / XP remember it has "features" that act like copyprotection / activation / BSOD's etc and can be stroppy when copied ..


  • Registered Users, Registered Users 2 Posts: 1,312 ✭✭✭SLIM19198


    Th OS to be copied is Linux, I use windows myself but cannot find a tool to clone a linux drive.

    The tools will copy and resize the linux drives, but they remain unbootable, and I do not know how to make them bootable!

    The drives are different, Its an upgrade from a 20Gb to an 80Gb, reinstallation is not possible as no install disks, and its a custom application, just need more storage!


  • Closed Accounts Posts: 153 ✭✭Dustpuppy


    Just mount both drives, copy from one to the other. You just have to install the bootloader then and that's it.


  • Advertisement
  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 93,562 Mod ✭✭✭✭Capt'n Midnight


    Dustpuppy wrote:
    Just mount both drives, copy from one to the other. You just have to install the bootloader then and that's it.
    Nice to know, just like Dos and Windows 95/98 then.


  • Registered Users, Registered Users 2 Posts: 1,312 ✭✭✭SLIM19198


    easier said than done, any guides on how to copy the drives and install the bootloader?


  • Registered Users, Registered Users 2 Posts: 2,755 ✭✭✭niallb


    Hi,
    you say you just need more storage.
    Do you really need to take out the 20G drive at all?
    Could you not just add the 40G, and mount it as /home
    or wherever your application stores its data.
    That way you'd only have to copy that partition's data
    and have no worries about booting.

    If you must take it out, just take it easy.
    There's no big mystery here, and 'cloning' linux drives is much
    simpler than with windows. No need for ghosts or partition magics.

    Making a drive bootable just means having the bios find the bootloader
    and telling the bootloader where to find the start of the OS kernel.
    That means that to install the bootloader on the 40G drive, it needs to be
    set up as the drive that your BIOS will attempt to boot from.
    It is of course possible under linux to get around this, but lets start with walking!
    This will be unfamiliar, but it's not complicated.

    1) Boot your original system and print out or write down this information:
    The contents of the file /etc/fstab
    The output of the command fdisk -l /dev/hda (or whichever disk is installed - see below.)

    2) Rejumper your drives so that the 40G will occupy the same position as
    the 20G currently does - probably primary master.
    Insert both drives, make sure you also have a cdrom you can boot from,
    and power up your system. (Unplug anything else for now if you need an
    extra for the old drive - you won't need DVD, Zip, or whatever during this.)

    Make sure that your BIOS lists both drives and the cdrom.
    Make sure you notify anyone using the system that it will
    be offline for a couple of hours. It really only needs about 10 minutes
    downtime to do this IF you've done it before, but give yourself plenty of time.

    3) Boot from a linux disk in the CD drive.
    Knoppix or Damn Small linux are good choices depending on RAM
    and available download speeds.
    You might stop knoppix at boot time and press F2 to see the options.
    You might want to select text console only, which I think is knoppix 2


    What was the original OS installed anyway? It doesn't matter much,
    as linux is linux, but different distributions choose different boot-loaders,
    making the second last step slightly different.

    4) As linux boots, try and see what letter was assigned to your 20G drive.
    If you miss it, you'll be able to catch it later using dmesg, so don't worry.
    By letter here, I mean hda, hdb, hdc, hdd.

    Seeing as you've just jumpered the drives in step 1, you should be able to tell
    anyway. hda=primary-master, hdb=primary-slave, hdc=secondary-mater, hdd=secondary-slave.
    From here I'll assume hda=40G and hdb=20G, adjust accordingly.

    5) Once you're at a prompt, make sure it's a root prompt.
    If it says knoppix ~$ try typing in sudo su - and you should become root.
    cd /mnt and ls to see what's there.
    Knoppix usually makes directories for all the partitions it finds.
    (I'm assuming here that you've already partitioned the 40G drive
    in the way you'd like it. If not, now is the time to do it.
    To see the existing partitions on your old 20G drive, run (adjusting if necessary)
    fdisk -l /dev/hdb
    This should match your notes from step 1, but with the new drive name.
    Now, look at your listing of /etc/fstab and make sure that
    you've added the sizes of the extra space on the 40G drive to useful locations!
    All your partitions should be pretty much the same size as on the 20G drive except
    for the one taking the application data. If you have the room, leave an extra partition
    for another copy of the root filesystem, so you can boot from it if you damage the
    main system at a later date.
    If you've repartitioned the drive, best to reboot and start again at step 5.

    6) Format the new partitions on the 40G drive using mke2fs.
    (if you have linux paritions hda1, hda2, hda5, run
    mke2fs /dev/hda1 and so on. If you want ext3, use mke2fs -j to create journals.)
    BEWARE, if it's an old system, the kernel may not support ext3 journals.
    Better to stick to ext2 unless the originals were ext3.
    Run mkswap /dev/hda3 on whichever new swap partitions you've created.
    Ideally, it should match the swap entry in /etc/fstab, but that can be edited.

    7) I'd suggest you now make two directories in /mnt.
    mkdir /mnt/20G and
    mkdir /mnt/40G.

    Mount your old root partition (Listed in /etc/fstab printout, adjusted
    to use its current drive 'letter', such as hdb5, on /mnt/20G.
    Mount your new root partition (Exactly as listed in /etc/fstab printout
    since this is our target) on /mnt/40G.
    Mount the other partitions listed in /etc/fstab printout UNDER these mountpoints.
    This means for example if your fstab lists /dev/hda6 as home,
    you should
    mount -t ext2 /dev/hdb6 /mnt/20G/home and
    mount -t ext2 /dev/hda6 /mnt/40G/home
    You will need to create (mkdir) these directories on the 40G drive.

    When you're finished, run mount to make sure everything looks right.
    You should have two trees matching closely your original fstab.

    8) At this point, copy the files over.
    I'd recommend using tar.
    Go to your old system:
    cd /mnt/20G and
    tar c . | tar xvf - -C ../40G
    This is gnu tar syntax, but that's the tar on both disks
    I suggested you might use anyway. If you use something else,
    post the error message, and we'll sort it out.

    When it finishes, run df -h and see do the disk usage
    figures make sense.

    You need to find out whether you were using grub or lilo.
    Distributions vary in which they choose.

    This command will tell you which is installed on a disk's MBR.
    dd if=/dev/hda bs=16 count=1 | strings | grep -a '[LILO|GRUB]'

    9) I'll make an assumption you're using LILO,
    as it's Sunday morning and it takes less time :_).
    Grub installation is a little more involved and may
    need a boot floppy to be made or a temporary bios adjustment.

    Move to your new filesystem:
    You now want to make this your root environment.
    cd /mnt/40G
    chroot /mnt/40GB bin/bash
    Now type lilo and watch the report.
    You should see ...added, but no errors.
    If so, you may well be ready for a reboot.

    exit from the chroot, cd / and
    umount -a to unmount whatever you can.
    CTRL-ALT-DEL and remove the cdrom, and see what happens.

    10) If this doesn't work for you, include your /etc/fstab,
    the outputs of fdisk for your drives and your exact
    distribution name with the reply. Let us know which step
    it failed at, and with what error message.
    Read this all again before you start!
    This isn't complicated, but I know it's unfamiliar and a bit alien for now.


    Good luck with it, hope it works out,

    Niall B.


  • Registered Users, Registered Users 2 Posts: 1,312 ✭✭✭SLIM19198


    Thanks Niall B., I'll give that a shot tomorrow, I couldnt tell you what distro or boot loader is in it, but what you say to do seems easy enough!

    Thanks for all your help.


Advertisement