Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Apr 2010 07:48:03 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Programmer In Training <pit@joseph-a-nagy-jr.us>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: Adding a Disk and Changing Mountpoints
Message-ID:  <20100409074803.10a4edde.freebsd@edvax.de>
In-Reply-To: <4BBE5ACB.3010601@joseph-a-nagy-jr.us>
References:  <4BBE5ACB.3010601@joseph-a-nagy-jr.us>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 08 Apr 2010 17:38:03 -0500, Programmer In Training <pit@joseph-a-nagy-jr.us> wrote:
> Saturday I'll be adding a second 40GB and a tertiary 6GB disk to the
> system (in favor of adding a CD-RW to a system that already has a DVD
> super multi-format drive). I'd like to rearrange my mount points a bit.

Here we go. :-)



> Specifically I would like to move /usr/home to the 40GB drive and
> possibly move /var to the 6GB drive (depending on how the drive
> behaves). I know it should be as easy as moving the relevant directories
> to the new drives once the file systems have been finalized. I'm just
> curious as to any issues I might need to be on the watch for (obviously
> I'll be editing fstab before moving the directories, then issuing the
> mount command as appropriate).

I'd suggest to use dump + restore to move the partitions' contents
partition-wise; this makes sure that file permissions and all
other stuff that may be important is copied 1:1.

Let's assume this is the point you're starting from:

	/dev/ad0s1a	/
	/dev/ad0s1b	swap
	/dev/ad0s1d	/var
	/dev/ad0s1e	/tmp
	/dev/ad0s1f	/usr <--- includes /usr/home

You'll add other disks, let them be

	/dev/ad1
	/dev/ad2

And create one slice and one partitions on each of them. (It's
possible to omit creating the slice, and just creating a
partition on the "pure" disk covering the whole disk, this
is called a dedicated partition, and that's why other systems
may be unable to access it.)

But let's just say you're selecting the "maximum compatibility
mode" and create

	slice /dev/ad1s1, and one partition /dev/ad1s1e
	slice /dev/ad2s1, and one partition /dev/ad2s1e

You then want to make /dev/ad1s1e the new /var, and /dev/ad2s1e
the new /home.

Important: To make sure that noting "unwanted" may happen, do
everything in single user mode: Boot the system into SUM (boot -s),
then do:

	# fsck /var /usr

        # mount /dev/ad1s1e /var
        # cd /var
        # dump -0 -f - /dev/ad0s1d | restore -r -f -
	# cd /
	# umount /var

Now you have transfered the content of old /var on /dev/ad0s1e
to new /var on /dev/ad1s1e. The idea of using dump + restore
implies that you want an exact 1:1 copy partition-wise.

You can't do the same with /usr/home, because it's not on
its own partition, but it's a subtree. For copying it,
you can use cp -R or tar.

Because you won't need the symlink /home@ -> usr/home in
the future, delete it now, and create a "real" mountpoint
for the new /home partition (on its own disk).

	# cd /
	# rm home	<- deletes the symlink
	# mkdir home	<- creates a real directory
	# mount -o ro /dev/ad0s1f /usr
	# mount -o ro /dev/ad2s1e /home
	# cd /usr/home
	# cp -R * /home
	# umount /home

Now as you have transfered everything to the new locations,
adjust /etc/fstab accordingly. Make sure that / is rw.

	# mount -o rw /

Then edit /etc/fstab using your preferred editor, e. g.

	# ee /etc/fstab

	# Device     Mountpoint  FStype  Options  Dump   Pass#
	# ---------  ----------  ------  -------  -----  -----
	/dev/ad0s1b  none        swap    sw       0      0
	/dev/ad0s1a  /           ufs     rw       1      1
	/dev/ad0s1d  /tmp        ufs     rw       2      2
	/dev/ad0s1e  /scratch    ufs     rw       2      2
	/dev/ad0s1f  /usr        ufs     rw       2      2
	/dev/ad1s1e  /var        ufs     rw       2      2
	/dev/ad2s1e  /home       ufs     rw       2      2

	... your other entries here...

	[Esc][Enter][Enter]

Now reboot the system. If - really AFTER if you have stated
that everything is in place as inteded, delete the /usr/home
subtree and the content of /scratch (which was /var).



> I'm doing this move specifically for space issues. My current drive
> (40GB) is nearly full (I only have 2.5GB left on /usr). I wish I
> wouldn't have deleted this mornings reports so I can give a run down on
> specifically how much is left everywhere, but it's getting pretty full.

You can use "df -h" as well as the "du -h <dir>" utility to
find out more about the current occupation of disks or
directory subtrees.



> Once I've moved /var and /usr/home to their own disks, how can I reclaim
> what has already been allocated for them?

If you delete the content from a partition, you'll end up with
an empty partition. You can give it another mount point and use
it, for example, as /scratch partition.



> Or will that happen
> automatically?

No. Nothing of such a big impact will happen automatically.



> Any specific concerns about that? Or would gparted and
> not fdisk be my friend here?

I'd suggest using the "sade" program. In order to re-arrange
partitions, it's the common method to delete existing
partitions and creating new ones. This assumes that you
make backups first, then "resize" the partitions, and
finally load your backup.


Allow me a final about your /etc/fstab. You presented this
entry:

	/dev/acd0    /mnt/cdrom   cd9660    ro,noauto   0   0

According to "man hier", /mnt is not the place to mount
the CD / DVD:

     /mnt/      empty directory commonly used by system administrators as a
                temporary mount point

Instead, in the past, using /cdrom was suggested:

     /cdrom/    default mount point for CD-ROM drives (created by
                sysinstall(8))

But will all the new magic of HAL & stuff, I'm not sure this
is still working (okay, I already know in order to mount things
using HAL, they should not be in /etc/fstab at all). I know
that a "new" approach is to use /media with corresponding
mountpints:

     /media/    contains subdirectories to be used as mount points for remov-
                able media such as CDs, USB drives, and floppy disks

This would be represented as

	/dev/acd0    /media/cdrom   cd9660    ro,noauto   0   0

in your /etc/fstab file. On my home system, I have many of
such entriesm like /media/cdrom, /media/card, /media/stick,
/media/pd, /media/floppy and so on. In the past, mount points
usually resided at / level (such as /cdrom, /floppy), but
that seems not to be the case anymore. Media that will be
exported via NFS usually will be mounted somewhere under
/export - a Solarism... Solaris-ism... just by the way. :-)



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100409074803.10a4edde.freebsd>