Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Jan 2009 16:22:31 -0500
From:      Maxim Khitrov <mkhitrov@gmail.com>
To:        Robert Huff <roberthuff@rcn.com>
Cc:        questions@freebsd.org
Subject:   Re: slices to "dangerously dedicated"
Message-ID:  <26ddd1750901201322r2aecd50cj5ddde9fbd4966e14@mail.gmail.com>
In-Reply-To: <18806.10828.412738.659475@jerusalem.litteratus.org>
References:  <18806.10828.412738.659475@jerusalem.litteratus.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jan 20, 2009 at 2:47 PM, Robert Huff <roberthuff@rcn.com> wrote:
>
>        Suppose I have a disk which was - for various reasons - lebeled
> using slices.
>        Is it possible to change it to "dangerously dedicated" without
> backup-wipe-relabel-restore cycle?
>
>
>                                        Robert Huff

It is possible, but is probably a bad idea (it all depends on why you
want to do this). I just ran a quick test in a virtual machine with a
clean drive. The procedure was:

# sysinstall (run the Fdisk tool to create a single s1 slice on /dev/da4)
# bsdlabel -w /dev/da4s1
# newfs -U /dev/da4s1a
# mount /dev/da4s1a /mnt
# echo hello > /mnt/world
# umount /mnt
# fdisk (to find the starting block of s1)
# sysctl kern.geom.debugflags=0x10 (may not be needed)
# dd if=/dev/da4 of=/dev/da4 bs=16k skip=1 (might also want to specify
'count=' to limit the amount of data copied)
# reboot

After the reboot, I could mount /dev/da4a and read the original
contents, s1 was no more. The key to getting it right is proper input
positioning; you cannot do something like `dd if=/dev/da4s1
of=/dev/da4`. In my case, s1 started at block 32, so I set my dd block
size to 16k and skipped the first block, placing me exactly at the
start of s1 (512 * 32 = 16384 or 16k). You really don't want to copy
one sector at a time (bs=512), and in my case, 16k is the highest that
I could go. If you are moving some other slice like s2, you can set bs
to 1 or 2 megs and just do proper calculation for what skip should be
set to (bs * skip should equal 512 * staring block as reported by
fdisk).

Realize, however, that this isn't exactly the same as creating a
"dangerously dedicated" disk from the start. You're just moving the
first (or whatever slice you need) to the start of the drive along
with any data that follows. You will not reclaim any disk space this
way, though you may be able to use bsdlabel and growfs later to expand
your partitions.

Good luck!
- Max

P.S. Once again would like to emphasize that I would never do this on
any real data because of the risks involved, but it was a fun exercise
to try :)



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