Re: formatting hardrive

From: Jerry McAllister (jerrymc_at_clunix.cl.msu.edu)
Date: 10/04/03

  • Next message: Jerry McAllister: "Re: formatting hardrive"
    To: ajacoutot@lphp.org (Antoine Jacoutot)
    Date: Sat, 4 Oct 2003 17:56:07 -0400 (EDT)
    
    

    >
    > Hi !
    >
    > Ok, I'm at a point where I'm ready to cry :(
    > Is there ANY easy way to partition/slice a hardrive for FreeBSD ?????
    > I spent all morning playing with bsdlabel, sysinstall... I just want to
    > partition a second hardrive so I could dump/restore the content of my first
    > drive.
    > So, I tried sysinstall post-install tools to create the slices and all, but
    > all I get are errors like "can't write to ad2", or "can't mount /dev/ad2s1a
    > on /mnt" ....
    > Basically what I want is:
    > ad2s1a --> /mnt
    > ad2s1b --> SWAP
    > ad2s1d --> /mnt/tmp
    > ad2s1e --> /mnt/var
    > ad2s1f --> /mnt/usr
    >
    > So, all I have to do after is dump / --> /mnt, /tmp --> /mnt/tmp ... and so
    > on.
    > I sware I tried all morning without any kind of success :(
    >
    > I would really appreciate some help.

    Well, although /stand/sysinstall would do it OK, it might be just
    as easy to use fdisk and disklabel directly. I don't know anything
    about 'bsdlabel'.

    So, presuming your extra disk is really /dev/ad2 (are there ad0 and ad1?)
    do the following.

       fdisk -BI ad2 (makes one big slice on the disk)

       disklabel -w -r da0s1 auto (writes an initial label for slice 1)

       disklabel -r -e da0s1 (now edit the label to make the partitions)
           this will bring up the label for slice1 in an editor - vi unless
           you specify another one. Edit the partition table as needed.
           Make it something like this only with the sizes you need.
           You didn't mention sizes so this example is for a nominal 18GB drive
           with 512 MB for a: /mnt,
                1GB for b: swap,
                512 MB for e: /mnt/tmp,
                1 GB for f: /mnt/var
                and all the rest for g: /mnt/usr
           NOTES: - The size is specified in number of 512 byte blocks
                  - Recent versions of disklabel (at least since 4.6.2 FreeBSD)
                    allow you to put a * for offset and it calculates it for you
                  - and a * for size in the last partition specified tells it to
                    use all rest of the slice for that partition.
           By convention, partition b: is used for swap, c: is a comment used to
           specify the whole slice and d: is not used for regular file systems.
          
           - Don't change the header stuff, just the partition size stuff.
        
    8 partitions:
    # size offset fstype [fsize bsize bps/cpg]
      a: 1048576 0 4.2BSD 1024 8192 22 #
      b: 2097152 * swap 1024 8192 22 #
      c: 35551782 0 unused 0 0 #
      e: 1048576 * 4.2BSD 1024 8192 22 #
      f: 2097152 * swap 1024 8192 22 #
      g: * * 4.2BSD 2048 16384 89 #

    When you :wq out of the edit session, it will write the label.

    Now, you have to newfs each of the partitions except for swap.
    Probably just take the defaults for newfs.
       
       newfs /dev/ad2s1a
       newfs /dev/ad2s1e
       newfs /dev/ad2s1f
       newfs /dev/ad2s1g

    Now mount partition a on /mnt so you can make the mount points for
    the rest of the partitions. (By the way, I would suggest making
    up a different mount point than /mnt because there are some other
    things like to mess with that so you might make up something like /dmp
    by doing mkdir /dmp, then replace /mnt with /dmp in all these commands)

       mount /dev/ad2s1a /mnt (or mount /dev/ad2s1a /dmp)
       cd /mnt (or cd /dmp)
       mkdir tmp
       mkdir var
       mkdir usr

    Now edit fstab to add the following entries

       # Disk ad2
       /dev/ad2s1a /mnt ufs rw 2 2
       /dev/ad2s1b none swap rw 0 0
       /dev/ad2s1e /mnt/tmp ufs rw 2 2
       /dev/ad2s1f /mnt/var ufs rw 2 2
       /dev/ad2s1g /mnt/usr ufs rw 2 2

    Alternatatively, if you use /dmp for a mount point it would look like:

       # Disk ad2
       /dev/ad2s1a /dmp ufs rw 2 2
       /dev/ad2s1b none swap rw 0 0
       /dev/ad2s1e /dmp/tmp ufs rw 2 2
       /dev/ad2s1f /dmp/var ufs rw 2 2
       /dev/ad2s1g /dmp/usr ufs rw 2 2

    Now, just mount everything.
    In the future it will all be mounted at boot time.

       mount -a

    And you are done.

    By the way. Don't try to dump to the mounted directory.
     eg DO NOT dump -0f /dmp/var /var
    Instead, you must name a file in the directory.
                  dump -0f /dmp/var/var.backup /var

    Given this, I don't see why you really want to make all those
    partions in the slice.

     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    Just make the slice with fdisk as I described and then use disklabel
    to create just one large partition to hold the dump files.
    So, the disklabel partition table would look something like:

    8 partitions:
    # size offset fstype [fsize bsize bps/cpg]
      b: 2097152 0 swap 1024 8192 22 #
      c: 35551782 0 unused 0 0 #
      e: * * 4.2BSD 2048 16384 89 #

    Then you would only need to create the /dmp mount point:
       mkdir /dmp

    Add to /etc/fstab the following:

       # Disk ad2
       /dev/ad2s1b none swap rw 0 0
       /dev/ad2s1e /dmp ufs rw 2 2

    Mount it with:

       mount -a

    and do dumps to files /dmp/root.backup (eg: dump -0f /dmp/root.backup /)
                          /dmp/tmp.backup (eg: dump -0f /dmp/tmp.backup /tmp)
                          /dmp/var.backup (eg: dump -0f /dmp/var.backup /var)
                          /dmp/usr.backup (eg: dump -0f /usr/var.backup /usr)
    That way you don't have to outguess how big each separate partition for
    each dump needs to be.

    Also, it is very unusual to back up /tmp since it is supposed to be
    only temporary, sort of scratch space. But, that is up to you.

    ////jerry

    >
    > Thanks in advance.
    >
    > --
    > Antoine Jacoutot
    > ajacoutot@lphp.org
    > http://www.lphp.org
    > PGP/GnuPG key: http://www.lphp.org/ressources/ajacoutot.asc
    >
    _______________________________________________
    freebsd-questions@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"


  • Next message: Jerry McAllister: "Re: formatting hardrive"

    Relevant Pages

    • Re: asrock, problem with nic after windows-boot - Mount Issues [Resolved]
      ... Like an idiot, I mounted hda1, when I needed to mount the whole hda ... mkdir /p1 ... I think I'm wrong about KDE being the umount culprit though; ... This hda4 is a copy (and a Primary partition, as most know) of a win98 ...
      (comp.os.linux.networking)
    • Re: Problem with random disks mount sequence
      ... I'll get random mount sequences. ... At the beginning the USB ... nautilus remember that 'storage3' was 1st partition, ... SCSI drives are listed by order of discovery. ...
      (Fedora)
    • Re: Relabel partition didnt work
      ... > You're confusing disk lables with mount points. ... > When installing etch, at some point partman asked for a mount point for ... > that partition and I entered /xyz. ... There's nothing to do to the second hard disk. ...
      (Debian-User)
    • Re: Ubuntu second hard drive was Windows partition
      ... Ubuntu second hard drive was Windows partition ... If ntfs-3g does come default in ubuntu, you can probably mount the ... on these lists for a couple of years now and should know what to say and ...
      (Ubuntu)
    • Re: R/W access of a vfat partition by any user ?
      ... FAT32 partition will be writable by any user instead of just root. ... users Allow every user to mount and unmount the file system. ... The 'umask=022' makes all files and directories have rwxr-xr-x permissions. ... If you want different perms and you don't speak binary, ...
      (alt.os.linux.suse)