On Tue, May 08, 2007 at 09:27:56PM +0800, Zhang Weiwu wrote:
> Actually this is not solved. I have discovered that it will not be easy
> to solve this problem and decided to accept the lose of data, that's how
> it "solved"/
>
> Basically the accident took place because one line in /etc/fstab was
> wrong.
>
> in /etc/fstab /dev/ad6s1c is used as swap, when FreeBSD boots, it
> use /dev/ad6s1c as swap, destroying data blocks around these sectors.
>
> [EMAIL PROTECTED] /var/backups]# disklabel /dev/ad6s1
> # /dev/ad6s1:
> 8 partitions:
> #size offsetfstype [fsize bsize bps/cpg]
> c: 3125766420unused0 0 # "raw" part, don't
> edit
> d: 31257664204.2BSD 2048 16384 28552
>
> So in this case the 'c' partition as far as I can understand should not
> be used for any purpose. I didn't intentionally create 'c' partition,
> nor can I see this partition in Disk Label Editor of sysinstall. I don't
> know why it's there.
There is always a c: partition. Note that it is marked 'unused' in
the fstype column. That is the way it should be. The c: partition
is how the system keeps track of the whole slice regardless of the
other partitions - and as such needs to be left alone. I think sysinstall
just leaves it out of the display to reduce confusion for newbies.
But, it is really there and bsdlabel (disklabel in old systems) shows it.
If you used sysinstall and it assigned 'c:' to some data or swap partition
in the slice, then something bad happened that should never happen. If
you can reproduce it, then you should report it as a serious bug using
sendpr.
Something is definitely wrong if your /etc/fstab lists ad6s1c as
a swap partition. If you did that, you will have to undo it and
create a different partition for swap. 'b:' is commonly the identifier
used for swap. If sysinstall did it, try to reproduce the error
and make a Problem Report.
>
> Zhang Weiwu
>
> On Tue, 2007-05-08 at 16:42 +0800, Zhang Weiwu wrote:
> > Dear list. I added a 160 GB harddisk to the FreeBSD server several days
> > ago. I have setup only one slice on it (/dev/ad6s1) and it has two
> > partitions on it.
> >
> > /dev/ad6s1c is used as swap
> > /dev/ad6s1d is used as /var
Well, that means you or something did something wrong. As indicated
above, 'c:' should not be used here.If you divided the s1 slice
in to two partitions with one being assigned to swap, then you
should see three partitions indicated in a bsdlabel display.
They should be 'c:' which refers to the entire slice, plus the
partition you created for swap and the other partition you created.
Likely those two would be either 'a:' and 'b:' or 'b:' and 'd:'
with either a or d being the data partition and b being the swap.
First thing to do is get that line that specifiec partition 'c:'
as swap.Then, I don't know if you will be able to recover
anything from d: or not. If the swapper wrote over it already -
which it looks like it did - then just start over with the building
of that disk. It looks like no filesystem as created by newfs is
on the d: partition which could possibly be the result of the swapper
overwriting the slice - eg c: partition.
Once you have reproduced the error and made the Problem Report, then
I would suggest manually recreating the disk system.
First, use dd to wipe out the mess.
dd if=/dev/zero of=/dev/ad6 bs=512 count=28780514
Then fdisk the drive and create one slice.
fdisk -I ad6
Initialize a base label in the slice
bsdlabel -w ad6s1
Now, edit the slice label and make your two partitions.
bsdlabel -e ad6s1
You will be put in to an edit session - probably 'vi' depending on
which editor is your default. Ignore anything above the line that
says '8 partitions'
Below that you should have one line with the c: info looking something like:
> 8 partitions:
> # sizeoffset fstype [fsize bsize bps/cpg]
> c: 312576642 0unused 0 0 # "raw" part, don't edit
Duplicate that line so there are three of them.
Edit the first one so it is called 'b:' and replace 'unused' with 'swap'
and make the size you want to use for swap on this disk.
Then edit the third line so it is 'd:' and make it contain all
of the remainder of the slice and have reasonable fsize, bsize and bps/cpg.
I think if you leave them blank, the system will calculate reasonable
values for fsize, bsize and bps/cpg, but I haven't tried it that way.
It will look something like:
8 partitions:
#size offsetfstype [fsize bsize bps/cpg]
b: 20971520 swap
c: 3125766420unused 0 0 # "raw" part, don't edit
d: **4.2BSD2048 16384 8
(By using the '*' for size and offset the system will calculate offset
for you (which, in this case would be 2097152) and make the size the
rest of the usable space in the slice)
Then, write and exit the editor.
Modify your /etc/fsta