Professional Web Applications Themes

What's an easy way to replace a drive? - FreeBSD

The continuing problems I'm having with my SATA drives seem to center on only one of the two drives, /dev/ad10, and since both drives are identical (Western Digital WD1200JD 120-GB SATA drives), this is a good indicator that the drive itself might be failing. So I've decided to spend $83 and buy a replacement drive to see if that fixes the problem. Now, what's the easiest way to replace the drive? The drive I want to replace contains only /var and /tmp. Are these mounted in single-user mode? I was thinking perhaps I can just replace the drive, set up ...

  1. #1

    Default What's an easy way to replace a drive?

    The continuing problems I'm having with my SATA drives seem to center on
    only one of the two drives, /dev/ad10, and since both drives are
    identical (Western Digital WD1200JD 120-GB SATA drives), this is a good
    indicator that the drive itself might be failing. So I've decided to
    spend $83 and buy a replacement drive to see if that fixes the problem.

    Now, what's the easiest way to replace the drive? The drive I want to
    replace contains only /var and /tmp. Are these mounted in single-user
    mode? I was thinking perhaps I can just replace the drive, set up
    identical slices on the new drive, then restore /var and /tmp from the
    latest backup. Can I restore from tape in single-user mode?

    I don't have any extra connectors to which I can attach this drive
    without removing one of the other drives, so I'm looking for a way to
    fix it up by just removing the old drive and putting in the new one,
    without the need to have both old and new drives online at the same
    time.

    --
    Anthony


    Anthony Guest

  2. #2

    Default Re: What's an easy way to replace a drive?

    On Thu, 24 Mar 2005 05:09:24 +0100, Anthony Atkielski
    <fr> wrote: 


    May not be the best answer, but if the drive's data is still intact
    (i.e. readable) and the replacement will be identical, maybe try DD or
    similar from a bootable "rescue" cd, like freesbie? If not that, then
    you may be able to copy the data between the 2 drives using same said
    bootable CD after creating the partitions.

    It doesn't meet the requirements of not removing drives unnecessarily,
    but it's an option.

    My 1 1/2 cents.

    GS
    Gary Guest

  3. #3

    Default Re: What's an easy way to replace a drive?

    Anthony Atkielski wrote:
     
    You can back up to tape and restore in single user mode. If /var and
    /tmp aren't too big, you could boot into single user mode,
    mount /usr
    mount -r /var (just to be safe)
    mount -r /tmp

    and create tar balls or even use dump to file (use the device in /dev as
    source, of course) with /var and /tmp unmounted.

    Then, reboot into single user mode with the new disk, set up the disk
    the way you want it with fdisk and bsdlabel, and then untar or restore
    from dump.


    Nicholas Guest

  4. #4

    Default Re: What's an easy way to replace a drive?

    On 2005-03-24 05:09, Anthony Atkielski <fr> wrote: 

    You'll have to use some sort of temporary storage for the data of the
    original /var and/or /tmp then. A tape or a local partition with a lot
    of free space will do just fine.

    If your other partitions have enough space to hold a compressed copy of
    the files, i.e. in var.cpio.gz and tmp.cpio.gz under /usr/backup, you
    can use that space as a temporary storage area. It takes a bit of
    planning and care, but it's relatively straightforward:

    1. Boot single user

    2. Mount all the file systems manually. This takes a bit of
    effort, but it's not too hard:

    # adjkerntz -i
    # swapon -a
    # fsck -p
    # mount -u /
    # mount -va

    3. Copy over the files of /var and /tmp under /usr/backup:

    # mkdir /usr/backup
    # cd /var
    # find . | cpio -o | gzip -9c - > /usr/backup/var.cpio.gz
    # cd /tmp
    # find . | cpio -o | gzip -9c - > /usr/backup/tmp.cpio.gz

    4. Make sure your backup copies are fine:

    # cd /usr/backup
    # zcat tmp.cpio.gz | cpio -i -tv
    # zcat var.cpio.gz | cpio -i -tv

    5. Sync your disks, and halt the system.

    6. While the system is turned off, swap disks.

    7. Boot in single user mode again.

    8. Mount everything (as before), except for /tmp and /var.

    You can either mount the file systems one by one, or mount
    the root file system as read-write, comment out the fstab
    entries for /var and /tmp and use `mount -a' as before.

    9. Partition, label and newfs the new disk. One way of doing
    this from the command line.

    10. Mount the partitions of the new disk in their new location.

    11. Restore everything from /usr/backup:

    # cd /tmp
    # zcat /usr/backup/tmp.cpio.gz | cpio -i -dmvu
    # cd /var
    # zcat /usr/backup/var.cpio.gz | cpio -i -dmvu

    12. Sync your disks & reboot.

    13. Optionally, after you verify that everything works as
    expected, delete the compress CPIO archives from
    /usr/backup.

    Giorgos Guest

  5. #5

    Default Re: What's an easy way to replace a drive?

    Nicholas Basila writes:
     
     
     

    Can I boot from the FreeBSD boot CD and avoid mounting anything on any
    of the hard drives at all? (That's not a problem in this case, since the
    root is on a different drive, but if I ever had to replace the drive
    containing the root I'm just wondering how to go about it.)

    --
    Anthony


    Anthony Guest

  6. #6

    Default Re: What's an easy way to replace a drive?

    Gary Smithe writes:
     

    Is it possible to dd the entire contents of one drive into a single file
    on another drive (assuming the latter drive is big enough)? If so, I
    could save time by just copying the drive wholesale to a huge file on
    another drive, replacing it, then copying everything back. Not sure if
    "whole drive" would include content outside the FS, though (?).

    --
    Anthony


    Anthony Guest

  7. #7

    Default RE: What's an easy way to replace a drive?



    -----Original Message-----
    From: org
    [mailto:org]On Behalf Of Anthony
    Atkielski
    Sent: Thursday, March 24, 2005 1:58 PM
    To: org
    Subject: Re: What's an easy way to replace a drive?

    Gary Smithe writes:
     
    intact 
    DD or 
    then 
    said 

    Is it possible to dd the entire contents of one drive into a single
    file
    on another drive (assuming the latter drive is big enough)? If so,
    I
    could save time by just copying the drive wholesale to a huge file
    on
    another drive, replacing it, then copying everything back. Not sure
    if
    "whole drive" would include content outside the FS, though (?).

    --
    Anthony


    _______________________________________________
    org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    To unsubscribe, send any mail to
    "org"

    Guest

  8. #8

    Default Re: What's an easy way to replace a drive?


    >
    > Is it possible to dd the entire contents of one drive into a single file
    > on another drive (assuming the latter drive is big enough)? If so, I
    > could save time by just copying the drive wholesale to a huge file on
    > another drive, replacing it, then copying everything back. Not sure if
    > "whole drive" would include content outside the FS, though (?).[/ref]

    Whatever piece you dd will be copied whole including boot sector
    and slice/partition table if you dd a slice or a partition instead of
    just the files. So, yes you could do it, but...

    The problem with dd-ing a partition or slice is that when you put it
    back, what was on the old drive would then overwrite the new including
    the slice and partition tables and boot sector, etc. It is likely that
    the new/rebuilt disk would be slightly different than the old so you
    really want to slice/partition/newfs it from scratch.

    I would recommend using dump(8) to copy each of the filesystems to a file.
    Then create new slices & partitions, newfs them and restore(8) the contents
    back. It is safer and just as efficient.

    ////jerry
     

    Jerry Guest

  9. #9

    Default Re: What's an easy way to replace a drive?

    Hi,

    In the worse case scenario, you want to move a system drive. (If it's
    not a system drive, you get less steps.)

    This is for the NOVICE, I therefore suggest the sysinstall gui to do
    the lifting:

    (No, I use bsdlabel, fdisk, etc, but this is more simplistic and
    generates ease-of-use methodology.)

    1) connect the drive to the system. (NOTE: if you are trying to do a
    system disk and you aren't familiar with bsdlabel, fdisk, etc., connect
    a single disk to the machine and boot the distro CD.)

    2) use sysinstall to partition the drive correctly. (Tools are fdisk
    and bsdlabel.) Make sure you write an MBR and/or boot blocks to the
    drive. When creating the partitions, typically, make them look similar
    to the original. /, /usr, /var. (NOTE: if you have another drive
    connected to the system, sysinstall will try to create d: as the first
    partition on the new drive when you want it to be a: . That's why I
    suggest keeping only the new drive connected for now. Getting real
    familiar with bsdlabel and fdisk can get you around this as you mature
    as a system administrator.)

    3) Write all the changes out to the drive from the partition editor.
    It will label the drive partitions and then newfs. (It will prompt you
    with: Are you sure you want to do this now? )

    4) At this point, you can shutdown and connect the system drive and
    bring up the system into single user mode on the initial drive. Create
    mount points like: /root2, /var2, /usr2 and mount the NEW drives
    partitions to them. Do a: mount -a to make sure all partitons on the
    system drive are mounted.

    5) Now, use dump and restore to move everything over. This will,
    typically, be much faster than dd on a non-full drive. DD has to read
    everything. This method just moves the info on the disk.

    for example:

    cd /root2; dump 0af - / | restore xf -
    ....
    ....
    change permissions on . ? (or something like it) y <ret>
    cd /var2; dump 0af - /var | restore xf -

    etc.

    If you just want a simple method of backing up partitions to a file:
    (I use the mount points here for simplicity, /home could be replaced
    by /dev/ad0s1f or such.)

    cd <partition on new drive>;
    dump 0af - /home | gzip > home.dump.gz
    dump 0af - /usr | gzip > usr.dump.gz

    without gzip...

    dump 0af home.dump /home

    later to restore,

    cd < new location >
    gunzip < /<path>/home.dump.gz | restore xf -

    without gzip....

    restore xf /<path>/home.dump

    I tried to make this simple.

    P.


    On Thursday 24 March 2005 14:08, com wrote: 
    >
    > intact

    >
    > DD or

    >
    > then

    >
    > said

    >
    > Is it possible to dd the entire contents of one drive into a single
    > file
    > on another drive (assuming the latter drive is big enough)? If so,
    > I
    > could save time by just copying the drive wholesale to a huge file
    > on
    > another drive, replacing it, then copying everything back. Not sure
    > if
    > "whole drive" would include content outside the FS, though (?).
    >
    > --
    > Anthony
    >
    >
    > _______________________________________________
    > org mailing list
    > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    > To unsubscribe, send any mail to
    > "org"
    >
    > _______________________________________________
    > org mailing list
    > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    > To unsubscribe, send any mail to
    > "org"[/ref]
    Paul Guest

  10. #10

    Default Re: What's an easy way to replace a drive?

    On Thursday 24 March 2005 13:57, Anthony Atkielski wrote: 
    >
    > Is it possible to dd the entire contents of one drive into a single
    > file on another drive (assuming the latter drive is big enough)? If
    > so, I could save time by just copying the drive wholesale to a huge
    > file on another drive, replacing it, then copying everything back.
    > Not sure if "whole drive" would include content outside the FS,
    > though (?).[/ref]


    Also, just an fyi....

    Under just about any cirstances, mirror the root drive with either
    hardware (if your motherboard supports it) or (THANK GOD FOR POUL AND
    PAWEL) use geom_mirror. It will save you an incredible amount of
    headaches if you can't do fdisk and bsdlabel confidently. If
    configured correctly, just pull the bad drive, install another, tell it
    to sync up. All done. In a hot swap box, no down time needed.

    P.
    Paul Guest

  11. #11

    Default Re: What's an easy way to replace a drive?

    Anthony Atkielski wrote:
     
    >
    >

    >
    >

    >
    >Can I boot from the FreeBSD boot CD and avoid mounting anything on any
    >of the hard drives at all? (That's not a problem in this case, since the
    >root is on a different drive, but if I ever had to replace the drive
    >containing the root I'm just wondering how to go about it.)
    >
    >
    >[/ref]
    Sure... just use the live disk. As long as you can access the necessary
    /dev entries from the CD, you can copy it.
    Nicholas Guest

  12. #12

    Default Re: What's an easy way to replace a drive?

    I replaced my HD once or twice. I doented the process the last time
    I did it.

    http://www.usmstudent.com/HOWTO/how_i_replaced_my_FreeBSD_HD.txt

    Darren


    Anthony Atkielski wrote: 
    >

    >

    >
    >
    > Can I boot from the FreeBSD boot CD and avoid mounting anything on any
    > of the hard drives at all? (That's not a problem in this case, since the
    > root is on a different drive, but if I ever had to replace the drive
    > containing the root I'm just wondering how to go about it.)
    >[/ref]
    backdoc Guest

  13. #13

    Default Re: What's an easy way to replace a drive?

    On Thu, Mar 24, 2005 at 07:55:13PM +0100, Anthony Atkielski wrote:
     

    Use Disk2 - the live filesystem disk - for that purpose. If you boot
    from it, it puts you into sysinstall just like disk1, but you can
    select 'Fixit mode' from the main menu and get a shell prompt while
    running entirely of the CD.

    Cheers,

    Matthew

    --
    Dr Matthew J Seaman MA, D.Phil. 8 Dane Court Manor
    School Rd
    PGP: http://www.infracaninophile.co.uk/pgpkey Tilmanstone
    Tel: +44 1304 617253 Kent, CT14 0JL UK

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.0 (FreeBSD)

    iQCVAwUBQkVpm5r7OpndfbmCAQLm0QP+Mp4s/E6uHbIE2RbhssARpVNm2KlZ1zoT
    ggWmV5RT7zzMRNlOcK0X4fsS+8HGE+Je47yB6l4cKbEa2LV F+1F2/geWz1yDS
    QXWdTqSah1xMWxnzlSZZpLdJ/K5I/imFsXrFAQUc9e/mkLKbA0Q8RylnpgoasWck
    cP8V81iGYBM=
    =kqWh
    -----END PGP SIGNATURE-----

    Matthew Guest

Similar Threads

  1. Search and replace (super global replace)
    By johnweiffenbach@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 1
    Last Post: April 8th, 08:56 AM
  2. Easy way to replace 0 with empty string?
    By Paul in forum PERL Miscellaneous
    Replies: 5
    Last Post: September 25th, 04:51 PM
  3. Wrong drive letter assigned to boot drive at install
    By Keith in forum Windows XP/2000/ME
    Replies: 3
    Last Post: August 3rd, 01:12 AM
  4. How to prevent restricted user modifying the hard drive(C drive) content.
    By Tell in forum Windows Setup, Administration & Security
    Replies: 2
    Last Post: July 30th, 04:50 PM
  5. Replies: 7
    Last Post: July 13th, 03:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139