Formatting External HD

I need to format a 250GB external HD. I've spent the last 4hrs reading the literature (man pages, other forum posts, etc), but nothing seems to be working for me.

I've gotten errors using this guide: http://www.freebsd.org/doc/en_US.ISO8859-1/articles/formatting-media/
And other guides are similarly frustrating.

I just need a single partition that can be mounted at boot, and I need real file permissions (namely, no msdosfs).
ZFS would be best, but UFS would also be fine.

Is there an extremely user-friendly partitioning program somewhere?

Normally I'd keep soldiering on, but I need this finished in a hurry – I'm graduating in two days, and I need this project finished by then.

Thanks so much!
-Peter
 
Lets assume that Your drive is detected as /dev/da0 ...

1. Destroy any previous MBR table:
[cmd=]# dd < /dev/zero > /dev/da0 count=1[/cmd]

2. Create single partition on whole disk:
[cmd=]# fdisk -I /dev/da0[/cmd]

3. Create UFS filesystem:
Code:
# newfs -m 1 /dev/da0s1
# glabel label ext da0s1a
# mkdir -p /mnt/ext
# mount /dev/label/ext /mnt/ext

3a. Create ZFS zpool:
Code:
# glabel label ext da0s1
# zpool create ext /dev/label/ext
# zfs list
 
For example, I follow a series of steps and see the following:
Code:
FreeBSD-ThinClient# gpart create -s gpt da0
da0 created

FreeBSD-ThinClient# gpart show da0
=>       34  488397101  da0  GPT  (233G)
         34  488397101       - free -  (233G)

FreeBSD-ThinClient# gpart add -t freebsd da0
da0s1 added

FreeBSD-ThinClient# newfs /dev/da0s1
/dev/da0s1: 238475.1MB (488397100 sectors) block size 16384, fragment size 2048
	using 1298 cylinder groups of 183.77MB, 11761 blks, 23552 inodes.
super-block backups (for fsck -b #) at:
 160, 376512, 752864, 1129216, 1505568, 1881920, 2258272, 2634624, 3010976,
 3387328, 3763680, 4140032, 4516384, 4892736, 5269088, 5645440, 6021792,
...ETCETERA...

FreeBSD-ThinClient# fsck da0
fsck: Could not determine filesystem type

FreeBSD-ThinClient# fsck da0s1
fsck: Could not determine filesystem type

FreeBSD-ThinClient# gpart show da0
=>       34  488397101  da0  GPT  (233G)
         34  488397101    1  freebsd  (233G)

FreeBSD-ThinClient# mount -t freebsd /dev/da0s1 /mnt
mount: /dev/da0s1 : Operation not supported by device

Hmm... why doesn't it work? :p
-Peter
 
Whoops, hadn't seen your post.

Your second step:
Code:
FreeBSD-ThinClient# fdisk -I /dev/da0
******* Working on device /dev/da0 *******
fdisk: invalid fdisk partition table found
fdisk: Class not found

Is that normal?
-Peter
 
After doing some research on ZFS, I think I want to stick with UFS.
More straightforward and easier for me to understand, I figure.

-Peter
 
This is what I would do (assuming ZFS). The instructions are the same for the single disk pool.

e.g.
  • Use dmesg to determine which device node it is (e.g. /dev/ada2)
    # dmesg
  • At this point, it's probably a good idea to zero the drive so we start from a clean slate.
    # dd if=/dev/zero of=/dev/ada2 bs=1m
  • glabel the HDD (e.g. external_disk). It is a good idea to physically label the HDD with the glabel as well.
    # glabel label -v external_disk /dev/ada2
  • Test.
    # glabel list
  • Create the zpool:
    # zpool create backup01 /dev/label/external_disk
  • Test.
    # zpool status

It should be automatically mounted under /external_disk. Let me know if you have problems.

I use ZFS exclusively, and love it. It is very intuitive once you grok it. Unless you have a particular reason (e.g. boot drives etc.), I would not use partitions either.
 
"man fdisk" has examples although it is not as clear as "man gjournal" the latter of which establishes a journalling filesystem.
p 3 165 * 200G
(above line, the file.fdisk)
Code:
fdisk -f file.fdisk /dev/da0
Good chance that puts a UFS2 "partition" on the 3rd "partition", size 200g though you'd want to double check.
Sorry no time to get out the notes on setting up gjournalling nor precise instructions on the fdisk file result.
(Those are only two bits of information, I keep local notes but would have to
spend a long time making them presentable and accurate to post them here.)
 
Progress!

Well, I was able to mount the drive after following those "Disk Setup On FreeBSD" instructions!

I did the following:
Code:
dd if=/dev/zero of=/dev/da0         <--- For a few seconds
gpart create -s gpt /dev/da0
gpart add -l MediaExternal -t freebsd-ufs -b 2048 -s 230G da0
newfs da0p1
mount /dev/da0p1 /mnt

Now I can mount the drive with:
Code:
mount /dev/da0p1 /mnt
but my /mnt directory contains a weird file called .snap
Code:
FreeBSD-ThinClient# pwd
/mnt
FreeBSD-ThinClient# ls -l
total 2
drwxrwxr-x  2 root  operator  512 Jun  1 21:43 .snap
Oh SNAP!

Not a show stopper by any means, but strange nonetheless.
Next, I'll try the ZFS instructions.

Thanks for all the help thusfar! You guys are much more helpful than the folks on the Windows forums! :e

-Peter

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

edit: Just tried with ZFS

That was really straightforward! And it's going to be insanely convenient!
Now, do I have to edit fstab? Will the drive stay mounted after a reboot?
 
PeterStory said:
edit: Just tried with ZFS

That was really straightforward! And it's going to be insanely convenient!
Oh yes. ZFS is truly a thing of beauty.
PeterStory said:
Now, do I have to edit fstab?
No.
PeterStory said:
Will the drive stay mounted after a reboot?
It should stay mounted (or rather, imported*) after a reboot. The only reason why it might not is if you accidentally disconnect it. In which case:
# zpool status
Will show that it's not there.
# zpool import
Will show that it is connected, waiting to be imported. In which case you would:
# zpool import external_disk
You might need to forcibly import it in that case too. Just add the -f option, I think it is. I highly recommend printing off the zfs and zpool man pages.

Actually, I take it this is a USB HDD? In which case, I'm not sure whether it is automounted, I would guess so, but can't tell you offhand. Just test it. If it disconnects, just use the instructions above. I use e-SATA HDD docks exclusively for HDDs I keep outside the case.

* "Imported" maps to pool level. "Mounted" maps to filesystem level. I also recommend keeping your actual data within filesystems within the pool. e.g.
# zfs create -o copies=2 -o compression=on external_disk/my_data

Assuming that the reason this disk is external is because you desire portability, then I think the options I specify are good. e.g. copies=2 will prevent most data loss barring a head crash, while having some compression saves you some space (and may also speed up transfers, since less data gets transferred over something slow like USB).
 
Mission Accomplished!

I just wanted to thank all of you for your great help!
I've graduated, so I can't access my machines anymore... but I hope they keep working (they are now)! :)

I even gave a glowing review of FreeBSD to my school's Linux IT guy!

-Peter Story
 
Back
Top