External USB Drives in Linux: Difference between revisions

From Edgar BV Wiki
Jump to navigation Jump to search
New page: Adding external USB drives in Linux is easy. Etch uses hotplug to detect it. Using dmesg you can find out what mountpoint it is (Linux creates a SCSI device to mount to /dev/sdb and the dr...
 
No edit summary
Line 1: Line 1:
Adding external USB drives in Linux is easy. Etch uses hotplug to detect it. Using dmesg you can find out what mountpoint it is (Linux creates a SCSI device to mount to /dev/sdb and the drive will probably be /dev/sdb1).
Adding external USB drives in Linux is easy. Etch uses hotplug to detect it. Using dmesg you can find out what mountpoint it is (Linux creates a SCSI device to mount to /dev/sdb and the drive will probably be /dev/sdb1).
/proc/bus/usb/devices shows you information about the connected USB device.
/proc/bus/usb/devices shows you information about the connected USB device.
Most USB devices are formatted FAT32 which has a file size limit of 4GB. Because I'm using mine for Netvault backups and the virtual library media is created at sizes much larger than that, there are 2 choices:
Most USB devices are formatted FAT32 which has a file size limit of 4GB. Because I'm using mine for Netvault backups and the virtual library media is created at sizes much larger than that, there are 2 choices:
ntfs-3G (which Etch doesn't support) and ext3 (which etch does).
ntfs-3G (which Etch doesn't support) and ext3 (which etch does).
Format to ext3 using
Format to ext3 using
mke2fs -T ext3 /dev/sdb1
mke2fs -T ext3 /dev/sdb1
Then create an /etc/fstab entry
Then create an /etc/fstab entry
and mount
and mount


Test the (unmounted) disk for bad blocks using
Test the (unmounted) disk for bad blocks using
badblocks -c 10240 -s -w -t random -v /dev/sdb
badblocks -c 10240 -s -w -t random -v /dev/sdb


In order to encrypt the whole disk I used this tutorial [http://www.hermann-uwe.de/blog/howto-disk-encryption-with-dm-crypt-luks-and-debian.]
In order to encrypt the whole disk I used this tutorial [http://www.hermann-uwe.de/blog/howto-disk-encryption-with-dm-crypt-luks-and-debian.]
apt-get install cryptsetup hashalot
apt-get install cryptsetup hashalot
cfdisk /dev/sdb (if you still need to partition the disk, unlikely though)
cfdisk /dev/sdb (if you still need to partition the disk, unlikely though)
cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb1
cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb1
Open the encrypted device and assign it to a virtual /dev/mapper/YOURNAME device:
Open the encrypted device and assign it to a virtual /dev/mapper/YOURNAME device:
cryptsetup luksOpen /dev/sdb1 YOURNAME
cryptsetup luksOpen /dev/sdb1 YOURNAME
mkfs.ext3 -m 1 -O dir_index,filetype,sparse_super /dev/mapper/YOURNAME
mkfs.ext3 -m 1 -O dir_index,filetype,sparse_super /dev/mapper/YOURNAME


To mount
To mount
mount /dev/mapper/YOURNAME /mnt/
mount /dev/mapper/YOURNAME /mnt/


Now it's transparently encrypted
Now it's transparently encrypted


To unmount
To unmount
umount /mnt/YOURNAME
umount /mnt/YOURNAME
cryptsetup luksClose /dev/mapper/YOURNAME
cryptsetup luksClose /dev/mapper/YOURNAME

Revision as of 14:15, 29 August 2007

Adding external USB drives in Linux is easy. Etch uses hotplug to detect it. Using dmesg you can find out what mountpoint it is (Linux creates a SCSI device to mount to /dev/sdb and the drive will probably be /dev/sdb1).

/proc/bus/usb/devices shows you information about the connected USB device.

Most USB devices are formatted FAT32 which has a file size limit of 4GB. Because I'm using mine for Netvault backups and the virtual library media is created at sizes much larger than that, there are 2 choices:

ntfs-3G (which Etch doesn't support) and ext3 (which etch does).

Format to ext3 using

mke2fs -T ext3 /dev/sdb1

Then create an /etc/fstab entry

and mount


Test the (unmounted) disk for bad blocks using

badblocks -c 10240 -s -w -t random -v /dev/sdb

In order to encrypt the whole disk I used this tutorial [1]

apt-get install cryptsetup hashalot

cfdisk /dev/sdb (if you still need to partition the disk, unlikely though)

cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb1

Open the encrypted device and assign it to a virtual /dev/mapper/YOURNAME device:

cryptsetup luksOpen /dev/sdb1 YOURNAME

mkfs.ext3 -m 1 -O dir_index,filetype,sparse_super /dev/mapper/YOURNAME


To mount

mount /dev/mapper/YOURNAME /mnt/


Now it's transparently encrypted


To unmount

umount /mnt/YOURNAME

cryptsetup luksClose /dev/mapper/YOURNAME