Format and Mount Disk

info via: https://help.ubuntu.com/community/InstallingANewHardDrive

Get the logical name:

  • $ sudo lshw -C disk

*-disk
description: ATA Disk
product: WDC WD1600JB-00D
vendor: Western Digital
physical id: 0.0.0
bus info: scsi@0:0.0.0
logical name: /dev/sda
version: 75.1
serial: WD-WMACK2068123
size: 149GiB (160GB)
capabilities: partitioned partitioned:dos
configuration: ansiversion=5 signature=00031122
*-cdrom
description: DVD writer
product: DVD_RW ND-3550A
vendor: _NEC
physical id: 0.1.0
bus info: scsi@0:0.1.0
logical name: /dev/cdrom
logical name: /dev/cdrw
logical name: /dev/dvd
logical name: /dev/dvdrw
logical name: /dev/scd0
logical name: /dev/sr0
version: 1.05
serial: [
capabilities: removable audio cd-r cd-rw dvd dvd-r
configuration: ansiversion=5 status=ready
*-medium
physical id: 0
logical name: /dev/cdrom
*-disk
description: ATA Disk
product: WDC WD15EARS-00M
vendor: Western Digital
physical id: 0.0.0
bus info: scsi@2:0.0.0
logical name: /dev/sdb
version: 51.0
serial: WD-WMAZA3997903
size: 1397GiB (1500GB)
capabilities: partitioned partitioned:dos
configuration: ansiversion=5 signature=474f0d94

Partition disk less than 2TB:

  • $ sudo fdisk /dev/sdb

n = new part (may need to delete first)

p = partition

w = write changes

Partition disk greater than 2TB:

sudo parted /dev/sdX # substitute with your drive (and you prolly need sudo)
> mklabel gpt # makes a new gpt partition table, afaik needed for >2TB
> mkpart pri 1 -1 # makes a new primary partition from start to end,
# note there are only primary partitions on gpt

>quit

Format disk:

  • $ sudo mkfs -t ext4 /dev/sdx1

Regain some disk:

  • $ sudo tune2fs -m 1 /dev/sdx1

Get the UUID of the disk:

  • $ sudo blkid

/dev/sda1: UUID="a491df4c-8870-4f68-bb12-fb3411c14141" TYPE="ext4"
/dev/sda5: UUID="8b9ce164-3b75-48c0-a115-c73522eea519" TYPE="swap"
/dev/sdb1: UUID="1be03f9f-b068-41a2-994f-ff790307ff2c" SEC_TYPE="ext2" TYPE="ext3"

Play it safe, make a backup

cp /etc/fstab ~

Auto Mount disk:

  • $ sudo pico /etc/fstab

UUID=1be03f9f-b068-41a2-994f-ff790307ff2c /mnt/local/sdx1 ext4 defaults,errors=remount-ro 0 1

  • $ sudo mkdir -p /mnt/local/sdx1
Prevent write to local
  • $ sudo chmod 000 /mnt/local/sdx1
Mount disk
  • $ sudo mount -a
  • $ sudo mount -l

Auto Mount Network disk:

  • $ sudo pico /etc/fstab


# Network share
//192.168.1.20/d /media/qbw-srv smbfs username=%user%,password=%password%,umask=000 0 0

  • $ sudo mkdir /media/qbw-srv
  • $ sudo mount -a

Temp Mount Network disk:

  • $ sudo mount -t smbfs -o username=<username> //<win-box>/<share> /mnt/<name-of-mountpoint>

Format the disk NTFS (Not such a good ideal, does not support user:group)

sudo apt-get install ntfsprogs

sudo mkntfs /dev/sdx1 -f -L Tera -v


Tag Cloud