Summary: Re-partitioning a disk

From: Lack Mr G M (
Date: Fri Jul 16 1993 - 14:03:22 CDT

    Well, I've managed to combine my /usr (sd0g) and /home (sd0h)
partitions and the system is alive and well. It was quite simple in the
end (well, it should have been :-) - see below). This is what I did
(and didn't) do.

    To start with I had said nothing about what resources I had
available, which is probably just as well as it allowed everyone to
assume what they wanted.

    While combining /home and /usr their contents will be unavailable,
so I have to find a way of having the relevant commands around. The
winning suggestion for this was:

> 2) Find some way to get a /usr directory mounted. The easiest way
> is to export /usr from another machine and mount it as /usr.

  first suggested by: (Ian MacPhedran)

    In fact, I basically ended up using his entire suggestion, so I
might as well include it all here.

> When you combine the partitions, you will lose the data on both partitions.
> I.e. you will not have a /usr (nor a /home) partition.
> I recommend:
> 1) Backup all data on this disk (even sd0a, just in case)
> 2) Find some way to get a /usr directory mounted. The easiest way
> is to export /usr from another machine and mount it as /usr.
> (You will have to add the exporting host to your /etc/hosts file,
> and make an entry in your /etc/fstab to mount the new /usr.)
> Boot to single-user mode.
> You could also boot from a CD-ROM drive to single user mode.
> As long as you're only using the data on the CDROM, you can
> mess with your disk as much as you need.
> 3) Use the format command, select "partition", and "print" the
> current partition table. Use "g" to resize the g partition to
> the end of disk (add the sizes of the current g & h partitions).
> Use "h" to set the size of the h partition to zero. "Label" the
> disk and exit.
> 4) Use the command "newfs" to create a new filesystem on sd0g.
> 5) Mount /dev/sd0g, and restore your /usr files to it from backup,
> 6) Replace the /usr entry in your /etc/fstab (if you previously
> modified it) and reboot.
> While you're doing this, you could extend the size of your swap
> partition as well. You might want to do this if you find yourself
> "out of memory" occasionally.
> WARNING: you are correct in assuming that a lot of things can go wrong
> when using format. Double check everything.

     Since I has a /usr (and /home) available on another system this
became fairly easy. However, I would add the following comments:

1) Whichever backup system you use, remember that you really want to get
back all of the original file protections and time-stamps (if possible).
I was using tar, so the restore required a "p" option.

   Also, do *not* save things with absolute pathnames (/usr/...). When
you get to restoring them /usr is *not* the one you want to end up with
(it is nfs-mounted from another system!). You need to save with
relative names, mount the new partition as /newusr and put everything
into that.

2) Make sure that your dumps do *not* contain any "core" files (which
take up more space on restores) or "swap" files (quicker just to mkfile
them again afterwards).

3) When you do the restores you will be running in single-user mode with
a "sun" console. This scrolls slowly and, as I used the "v" option to
tar for part of the restores, appeared to slow things down.

4) I can't see any point in extending my swap partition, as it only
needs to be large enough to boot with (which it is). For additional
paging space I can just use mkfile for a swap filesystem (which I do).

5) I also wanted the data from /home, so restored that to (into what
would be /usr/home). I then "undid" all of the links that had been form
the /usr to /home file-systems and mv'ed the files to the correct place
instead (this cross fs linking was part of the reason I wanted to
combine them).

     That's about it. Now for what went wrong. Simply that I left the
"nfs" bit out of the /usr and /home entries in /etc/fstab, so when I did
the initial re-boot into single user mode I got error messages about bad
lines in fstab, file-systems not mounted in read-write mode.

     At this point Panic (not a unix panic - a human one) set in. I
tried "df" to see what was mounted. "df" not found. Nothing seemed to
work. No "mount" (or perhaps it was there but "mount /dev/sd3g /usr"
failed, which isn't surprising as it should be sd0g - can anyone explain
why sd3 is device 0, sd0 is device 3 while sd1 is device 1???).
Apparently nothing. So I "borrowed" a CD drive and booted off that.
This at least booted, but I couldn't find a "mount" anywhere (perhaps
someone could confirm that??) so there was nothing useful that I could
do from there.

    A bit of reason then re-entered my brain and I booted of disk to
single user mode again and tried "ls". Amazing - there was the "/"
partition. Don't ask me how I missed this before...

    But the disk is still read-only so:

1) mount -o remount / (cribbed from the /etc/rc.single script)
2) mount /dev/sd0g /usr
3) PATH=.....

and I was back with a useable editor (uemacs) and fixed fstab.

Thanks to the following for their replies:

 Heas <>
 Andrew Watson <>
 Jim Davis <>
 Charles <> (Ian MacPhedran)
 djiracek@jupiter.uucp (Dan Jiracek) (Kevin Heagney) (Ed Arnold)
 "Robert D. Worsham" <> (Dave Plummer)
 Postmaster <> (Michael Harris) (John D Schneider)
 Tim Perala <> (John Justin Hough) (Richard J. Niziak)
 Susan Thielen <>
 zshouben@PCS.CNU.EDU (Shouben Zhou) (Mike Andrews) (Perry Hutchison) (Kevin Sheehan {Consulting Poster Child})
 "Y.TSUJI" <> (Derek Terveer)
 twilight! (Brooks Cutter) (Bernhard Weinelt) (Glenn Satchell - Uniq Professional Services) (Mark S. Anderson) (Mike Pechner) (Birger A. Wathne)
 megatek!geoff@uunet.UU.NET (Geoffrey R. Walton)
 jhunter@PCS.CNU.EDU (Thar is grumpy)

----------- Gordon Lack ----------------- ------------
The contents of this message *may* reflect my personal opinion. They are
*not* intended to reflect those of my employer, or anyone else.

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:08:01 CDT