# Mounting USB External Hard drive



## mallen324 (Oct 23, 2012)

Hello all,

I appreciate all the help Ive gotten so far on these forums. Maybe you can do it again!

I recently had my backup server crash, so I am resorting to just copying our files to a 3TB USB drive until the back up is up and running again. However, I am having troubles mounting it. I have it plugged in, and have figured out that it is device /dev/da1 or dev/da1s1, I think it is da1s1, because If I remember correctly, thats the specific partition Im trying to mount. 

Anyways, I know I need ntfs-3g installed, but I get an error when I try and install it by going to :

```
cd /usr/ports/sysutils/fusefs-ntfs
```

and running :

```
sudo make clean install
```

I get the following error :

```
===>   fusefs-ntfs-2011.4.12_1 depends on package: fusefs-libs>=2.7.2 - found
===>   fusefs-ntfs-2011.4.12_1 depends on package: libtool>=2.4 - not found
===>   Found libtool-2.2.10, but you need to upgrade to libtool>=2.4.
*** Error code 1

Stop in /usr/ports/sysutils/fusefs-ntfs.
*** Error code 1

Stop in /usr/ports/sysutils/fusefs-ntfs.
```

Could someone help me update libtools? And would that affect anything on the system?

Thanks!

Also, using FreeBSD 8.1 Release


----------



## mallen324 (Oct 23, 2012)

I should also note, I do not care if it is NTFS formatted. Nothing is on the external HDD right now. If Someone could help me format it to EXT or something that freebsd likes better, that is fine by me. 

Thanks again!


----------



## wblock@ (Oct 23, 2012)

Use UFS, FreeBSD's native filesystem.  NTFS through FUSE is shaky and untrustworthy.


----------



## jb_fvwm2 (Oct 23, 2012)

In the past, I've started with man gjournal (the EXAMPLES) but more better ways could exist... even a method maybe posted this week to the freebsd-questions list (IIRC).


----------



## mallen324 (Oct 23, 2012)

Can someone help me format it to UFS? It is currently NTFS. Am I going to have to mount it first? I dont have anything on there I need to keep.

Sorry this is such a basic question, I really suck at freeBSD...

I have found a tutorial here : http://www.freebsd.org/doc/handbook/disks-adding.html , and it suggests this:


```
# dd if=/dev/zero of=/dev/da1 bs=1k count=1
# bsdlabel -Bw da1 auto
# bsdlabel -e da1				# create the `e' partition
# newfs /dev/da1e
# mkdir -p /1
# vi /etc/fstab				# add an entry for /dev/da1e
# mount /1
```

Does that seem right to you guys? Im worried about using it, because I have no idea what the /dev/zero is, or what the count=1 is supposed to do.


----------



## xeube (Oct 23, 2012)

You could use *gpart* as well no? Assuming that your usb device is da0, you could do something like this:

```
#gpart destroy -F da0
#gpart create -s gpt da0
#gpart add -t freebsd-ufs da0
#newfs -O2 -U -j /dev/da0p1
```

Since it is a new drive, I don't think that the use of *dd* would be required.


----------



## mallen324 (Oct 23, 2012)

When i try 
	
	



```
#gpart destroy -F da0
```

I get:

```
$ gpart destroy -F da1
gpart: illegal option -- F
usage: gpart add [-b start] [-s size] -t type [-i index] [-l label] [-f flags] geom
       gpart bootcode [-b bootcode] [-p partcode] [-i index] [-f flags] geom
       gpart commit geom
       gpart create -s scheme [-n entries] [-f flags] provider
       gpart delete -i index [-f flags] geom
       gpart destroy [-f flags] geom
       gpart modify -i index [-l label] [-t type] [-f flags] geom
       gpart set -a attrib -i index [-f flags] geom
       gpart show [-lr] [geom ...]
       gpart undo geom
       gpart unset -a attrib -i index [-f flags] geom
       gpart help
       gpart list [name ...]
       gpart status [-s] [name ...]
       gpart load [-v]
       gpart unload [-v]
```


Maybe its an older version of gpart?


----------



## mallen324 (Oct 23, 2012)

Also if I try and go ahead with the next line:


```
$ sudo gpart create -s gpt da1
gpart: geom 'da1': File exists
```


----------



## xeube (Oct 23, 2012)

Can you give the output of the follwoing command:

```
#gpart show
```

Depending on that output, you should do the following:

```
#gpart delete -i 2 da0
#gpart delete -i 1 da0
#gpart destroy -F da0
```

The you could procede with what I wrote above. A good how to written by ~wblock@ can be found here.


----------



## wblock@ (Oct 24, 2012)

Older versions of gpart(8) don't have -F.  They won't let a partition table be destroyed until all the individual partitions have been deleted.

I would not enable soft updates journaling with -j to newfs(8).  -O2 is the default, so just -U is enough.


----------



## mallen324 (Oct 24, 2012)

```
$ gpart show
=>       63  156301425  ad16  MBR  (75G)
         63  156301425     1  freebsd  [active]  (75G)

=>        0  156301425  ad16s1  BSD  (75G)
          0    1048576       1  freebsd-ufs  (512M)
    1048576    8388608       2  freebsd-swap  (4.0G)
    9437184   10446848       4  freebsd-ufs  (5.0G)
   19884032    1048576       5  freebsd-ufs  (512M)
   20932608  135368817       6  freebsd-ufs  (65G)

=>        34  5859311549  da0  GPT  (2.7T)
          34  5859311549    1  freebsd-ufs  (2.7T)

=>       63  732566520  da1  MBR  (2.7T)
         63       1985       - free -  (7.8M)
       2048  732563456    1  !7  (2.7T)
```

da1 is what I need to format. Sorry, wblock, not sure what you meant by the "I would not enable soft updates journaling with -j to newfs(8). -O2 is the default, so just -U is enough." part of your post. Are you saying I should put in 


```
newfs -U /dev/da0p1
```

instead of 


```
newfs -O2 -U -j /dev/da0p1
```

Thanks to all so far!


----------



## wblock@ (Oct 24, 2012)

mallen324 said:
			
		

> Sorry, wblock, not sure what you meant by the "I would not enable soft updates journaling with -j to newfs(8). -O2 is the default, so just -U is enough." part of your post. Are you saying I should put in
> 
> 
> ```
> ...



Yes, -O2 is not needed, and I would not use -j for a backup drive.


----------



## mallen324 (Oct 25, 2012)

Sorry for the late response/update. I am going to put FreeBSD 9 on a laptop and get it formatted that way. Didn't feel comfortable working on formatting HDs on our production server.

I'll update asap.

Thanks again all!


----------



## mallen324 (Oct 26, 2012)

After having a terrible time getting a live cd to work, I'm just gonna buckle down and do it on our production machine. I know the HDD is da1 anyways. I plugged the HDD into a windows machine and deleted the NTFS partition, so in my /dev list it only pops up as da1, no da1s1 anymore.

Here's my output of the suggestions so far:


```
$ sudo gpart create -s gpt da1
gpart: geom 'da1': File exists
$ sudo gpart delete -i 2 da1
gpart: index '2': No such file or directory
$ sudo gpart delete -i 1 da1
gpart: index '1': No such file or directory
$ sudo newfs -U /dev/da1p1
newfs: /dev/da1p1: could not find special device
```

Any suggestions? I wish my gpart could use the -F flag.


----------



## SirDice (Oct 26, 2012)

mallen324 said:
			
		

> Any suggestions? I wish my gpart could use the -F flag.



Upgrade to 8.3, that does have that flag. FreeBSD 8.1 has been End-of-Life since July 2012.


----------



## mallen324 (Oct 26, 2012)

UPDATE!:

I used what I had found earlier, tweaked it a bit and I now have it mounted. Here is what I did:


```
# bsdlabel -Bw da1 auto
# newfs /dev/da1a
# mkdir -/mnt/seagate
# mount /dev/da1a /mnt/seagate
```

Now when I show df -h:


```
Filesystem      Size    Used   Avail Capacity  Mounted on
*** Other stuff editted out ***
/dev/da1a       2.7T    8.0K    2.5T     0%    /mnt/seagate
```

So I guess success right? Now I just gotta figure out a good backup plan. I'm thinking rsync...


----------



## mallen324 (Oct 26, 2012)

SirDice said:
			
		

> Upgrade to 8.3, that does have that flag. FreeBSD 8.1 has been End-of-Life since July 2012.



Could you provide me some a link to documentation on upgrading / how to upgrade? I'd like to read what I'm getting into before jumping in. Thanks!


----------



## jem (Oct 26, 2012)

One other thing to consider:

Being a 3TB hard disk, it is certainly an "Advanced Format" disk, which uses 4KB-sized sectors internally (although still probably reports 512B sectors when queried).

Because of this, it's important to ensure that your partitions are aligned to a multiple of 4KB for optimal performance.  The 'gpart' instructions you were given earlier didn't take that into account.

Assuming this is the current partitioning of your disk...


```
=>        34  5859311549  da0  GPT  (2.7T)
          34  5859311549    1  freebsd-ufs  (2.7T)
```

and assuming that you've not yet copied any files onto the disk, do the following:

`# gpart delete -i 1 da0`
`# gpart add -b 64 -t freebsd-ufs da0`
`# newfs -U /dev/da0p1`

This will delete the partition, then create a new one with an offset of 64 512B sectors, which will be aligned to the underlying 4KB sectors.

EDIT: I've just noticed you've switched to using bsdlabel partitions, which makes my suggestion moot.


----------



## mallen324 (Oct 26, 2012)

Thanks Jem!

Just did so, and remounting it now!

This look like the right command to backup my /home directory to my backup drive?

```
sudo rsync -av --delete /home /mnt/seagate/backup
```


----------



## SirDice (Oct 26, 2012)

mallen324 said:
			
		

> Could you provide me some a link to documentation on upgrading / how to upgrade? I'd like to read what I'm getting into before jumping in.



http://www.freebsd.org/releases/8.3R/relnotes-detailed.html#UPGRADE


----------



## wblock@ (Oct 26, 2012)

mallen324 said:
			
		

> UPDATE!:
> 
> I used what I had found earlier, tweaked it a bit and I now have it mounted. Here is what I did:
> 
> ...



The problem with using bsdlabel(8) on large drives is that it doesn't align partitions to 4K blocks.  So performance can be reduced drastically, like by half.  It's worth fixing that before copying data to that drive.  The way you fix it is to use gpart(8) with -a.  You were already there in a previous post.


----------



## mallen324 (Oct 26, 2012)

wblock@ said:
			
		

> The problem with using bsdlabel(8) on large drives is that it doesn't align partitions to 4K blocks.  So performance can be reduced drastically, like by half.  It's worth fixing that before copying data to that drive.  The way you fix it is to use gpart(8) with -a.  You were already there in a previous post.



As Jem suggested, I did the following:


```
# gpart delete -i 1 da1
# gpart add -b 64 -t freebsd-ufs da1
# newfs -U /dev/da1a
```

Do you think I should redo it again with the -a flag? and would I do that in the 2nd line there, like so?:


```
# gpart add -[B]a[/B]b 64 -t freebsd-ufs da1
```

Is there a way to check if this has already been done? As in, see if is in 4K blocks already. I would also like to check and see if my/home directory ( a raid array) is set up that way. Thing kinda has performance issues, but it's also got like 30+ users pounding it all the time.


----------



## wblock@ (Oct 26, 2012)

Use
`% gpart show da1`

Here's an example:

```
% gpart show ada1
=>        34  1953525101  ada1  GPT  (931G)
          34           6        - free -  (3.0k)
          40  1953525088     1  freebsd-ufs  (931G)
  1953525128           7        - free -  (3.5k)
```

There is 3K of unused space, and then the single partition starts at block 40.  40*512 is 20480, evenly divisible by 4096, so that partition is aligned.  There's nothing magic about block 40, it was just the next even 4K alignment after the first 34 blocks were used for the partition table.  The partition size is also an even multiple of 4K.

-a isn't magic, either.  It takes a numeric value and rounds partition starting locations and sizes to even multiples of that value.  If those values are already even multiples, they are not changed.

So this partition is most easily created with
`# gpart add -t freebsd-ufs -a4k ada1`

But it could also have been done like this:
`# gpart add -t freebsd-ufs -b40 -s1953525088 ada1`

Both ways produce the same partition, starting at an 4K-aligned block and an even multiple of 4K in size.


----------



## User7 (Jun 7, 2015)

How to do NTFS file system?


----------



## wblock@ (Jun 7, 2015)

User7 said:


> How to do NTFS file system?



Please start a new thread for that, it is not specific to external USB drives.


----------



## User7 (Jun 11, 2015)

I was use mkfs.ntfs from /compat/linux/sbin/mkfs.ntfs By this way:


```
1. Download Ununtu x86 ISO and mount it (assume, it is /mnt)
2. cd /compat
3. unsquashfs -d linux /mnt/ubuntu/casper/filesystem.squashfs Take squash utils here sysutils/squashfs-tools
4. chroot /compat/linux /bin/sh and chmod -R u+rwX /bin /sbin /lib /usr/bin /usr/sbin /usr/lib
5. Delete /compat/linux/etc/passwd
```


----------



## tobik@ (Jun 11, 2015)

User7 said:


> How to do NTFS file system?


Use `mkntfs` from sysutils/fusefs-ntfs.


----------

